RetroArch
wpad.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------
2 
3 wpad.h -- Wiimote Application Programmers Interface
4 
5 Copyright (C) 2008
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
8 Hector Martin (marcan)
9 
10 This software is provided 'as-is', without any express or implied
11 warranty. In no event will the authors be held liable for any
12 damages arising from the use of this software.
13 
14 Permission is granted to anyone to use this software for any
15 purpose, including commercial applications, and to alter it and
16 redistribute it freely, subject to the following restrictions:
17 
18 1. The origin of this software must not be misrepresented; you
19 must not claim that you wrote the original software. If you use
20 this software in a product, an acknowledgment in the product
21 documentation would be appreciated but is not required.
22 
23 2. Altered source versions must be plainly marked as such, and
24 must not be misrepresented as being the original software.
25 
26 3. This notice may not be removed or altered from any source
27 distribution.
28 
29 -------------------------------------------------------------*/
30 
31 #ifndef __WPAD_H__
32 #define __WPAD_H__
33 
34 #include <gctypes.h>
35 #include <wiiuse/wiiuse.h>
36 
37 #define WPAD_MAX_IR_DOTS 4
38 
39 enum {
47 };
48 
49 #define WPAD_BUTTON_2 0x0001
50 #define WPAD_BUTTON_1 0x0002
51 #define WPAD_BUTTON_B 0x0004
52 #define WPAD_BUTTON_A 0x0008
53 #define WPAD_BUTTON_MINUS 0x0010
54 #define WPAD_BUTTON_HOME 0x0080
55 #define WPAD_BUTTON_LEFT 0x0100
56 #define WPAD_BUTTON_RIGHT 0x0200
57 #define WPAD_BUTTON_DOWN 0x0400
58 #define WPAD_BUTTON_UP 0x0800
59 #define WPAD_BUTTON_PLUS 0x1000
60 
61 #define WPAD_NUNCHUK_BUTTON_Z (0x0001<<16)
62 #define WPAD_NUNCHUK_BUTTON_C (0x0002<<16)
63 
64 #define WPAD_CLASSIC_BUTTON_UP (0x0001<<16)
65 #define WPAD_CLASSIC_BUTTON_LEFT (0x0002<<16)
66 #define WPAD_CLASSIC_BUTTON_ZR (0x0004<<16)
67 #define WPAD_CLASSIC_BUTTON_X (0x0008<<16)
68 #define WPAD_CLASSIC_BUTTON_A (0x0010<<16)
69 #define WPAD_CLASSIC_BUTTON_Y (0x0020<<16)
70 #define WPAD_CLASSIC_BUTTON_B (0x0040<<16)
71 #define WPAD_CLASSIC_BUTTON_ZL (0x0080<<16)
72 #define WPAD_CLASSIC_BUTTON_FULL_R (0x0200<<16)
73 #define WPAD_CLASSIC_BUTTON_PLUS (0x0400<<16)
74 #define WPAD_CLASSIC_BUTTON_HOME (0x0800<<16)
75 #define WPAD_CLASSIC_BUTTON_MINUS (0x1000<<16)
76 #define WPAD_CLASSIC_BUTTON_FULL_L (0x2000<<16)
77 #define WPAD_CLASSIC_BUTTON_DOWN (0x4000<<16)
78 #define WPAD_CLASSIC_BUTTON_RIGHT (0x8000<<16)
79 
80 #define WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP (0x0001<<16)
81 #define WPAD_GUITAR_HERO_3_BUTTON_YELLOW (0x0008<<16)
82 #define WPAD_GUITAR_HERO_3_BUTTON_GREEN (0x0010<<16)
83 #define WPAD_GUITAR_HERO_3_BUTTON_BLUE (0x0020<<16)
84 #define WPAD_GUITAR_HERO_3_BUTTON_RED (0x0040<<16)
85 #define WPAD_GUITAR_HERO_3_BUTTON_ORANGE (0x0080<<16)
86 #define WPAD_GUITAR_HERO_3_BUTTON_PLUS (0x0400<<16)
87 #define WPAD_GUITAR_HERO_3_BUTTON_MINUS (0x1000<<16)
88 #define WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN (0x4000<<16)
89 
90 enum {
97 };
98 
99 enum {
103 };
104 
105 enum {
109 };
110 
111 #define WPAD_ERR_NONE 0
112 #define WPAD_ERR_NO_CONTROLLER -1
113 #define WPAD_ERR_NOT_READY -2
114 #define WPAD_ERR_TRANSFER -3
115 #define WPAD_ERR_NONEREGISTERED -4
116 #define WPAD_ERR_UNKNOWN -5
117 #define WPAD_ERR_BAD_CHANNEL -6
118 #define WPAD_ERR_QUEUE_EMPTY -7
119 #define WPAD_ERR_BADVALUE -8
120 #define WPAD_ERR_BADCONF -9
121 
122 #define WPAD_DATA_BUTTONS 0x01
123 #define WPAD_DATA_ACCEL 0x02
124 #define WPAD_DATA_EXPANSION 0x04
125 #define WPAD_DATA_IR 0x08
126 
127 #define WPAD_ENC_FIRST 0x00
128 #define WPAD_ENC_CONT 0x01
129 
130 #define WPAD_THRESH_IGNORE -1
131 #define WPAD_THRESH_ANY 0
132 #define WPAD_THRESH_DEFAULT_BUTTONS 0
133 #define WPAD_THRESH_DEFAULT_IR WPAD_THRESH_IGNORE
134 #define WPAD_THRESH_DEFAULT_ACCEL 20
135 #define WPAD_THRESH_DEFAULT_JOYSTICK 2
136 #define WPAD_THRESH_DEFAULT_BALANCEBOARD 60
137 #define WPAD_THRESH_DEFAULT_MOTION_PLUS 100
138 
139 #ifdef __cplusplus
140  extern "C" {
141 #endif /* __cplusplus */
142 
143 typedef struct _wpad_data
144 {
146 
149 
154 
155  struct ir_t ir;
156  struct vec3w_t accel;
157  struct orient_t orient;
158  struct gforce_t gforce;
159  struct expansion_t exp;
160 } WPADData;
161 
162 typedef struct _wpad_encstatus
163 {
164  u8 data[32];
166 
167 typedef void (*WPADDataCallback)(s32 chan, const WPADData *data);
168 typedef void (*WPADShutdownCallback)(s32 chan);
169 
170 s32 WPAD_Init();
174 s32 WPAD_Flush(s32 chan);
176 s32 WPAD_SetDataFormat(s32 chan, s32 fmt);
178 s32 WPAD_SetVRes(s32 chan,u32 xres,u32 yres);
180 s32 WPAD_Probe(s32 chan,u32 *type);
182 s32 WPAD_Disconnect(s32 chan);
184 s32 WPAD_SendStreamData(s32 chan,void *buf,u32 len);
185 void WPAD_Shutdown();
186 void WPAD_SetIdleTimeout(u32 seconds);
190 s32 WPAD_Rumble(s32 chan, int status);
191 s32 WPAD_SetIdleThresholds(s32 chan, s32 btns, s32 ir, s32 accel, s32 js, s32 wb, s32 mp);
192 void WPAD_EncodeData(WPADEncStatus *info,u32 flag,const s16 *pcmSamples,s32 numSamples,u8 *encData);
193 WPADData *WPAD_Data(int chan);
194 u8 WPAD_BatteryLevel(int chan);
195 u32 WPAD_ButtonsUp(int chan);
196 u32 WPAD_ButtonsDown(int chan);
197 u32 WPAD_ButtonsHeld(int chan);
198 void WPAD_IR(int chan, struct ir_t *ir);
199 void WPAD_Orientation(int chan, struct orient_t *orient);
200 void WPAD_GForce(int chan, struct gforce_t *gforce);
201 void WPAD_Accel(int chan, struct vec3w_t *accel);
202 void WPAD_Expansion(int chan, struct expansion_t *exp);
203 
204 #ifdef __cplusplus
205  }
206 #endif /* __cplusplus */
207 
208 #endif
void WPAD_SetPowerButtonCallback(WPADShutdownCallback cb)
Definition: wpad.c:881
void WPAD_Expansion(int chan, struct expansion_t *exp)
Definition: wpad.h:46
u32 btns_d
Definition: wpad.h:152
int32_t s32
32bit signed integer
Definition: gctypes.h:24
s32 WPAD_GetStatus()
Definition: wpad.c:812
void WPAD_GForce(int chan, struct gforce_t *gforce)
Definition: wpad.c:1096
Definition: wpad.h:107
u32 WPAD_ButtonsDown(int chan)
Definition: wpad.h:106
s32 WPAD_SetDataFormat(s32 chan, s32 fmt)
s32 WPAD_ScanPads()
Definition: wpad.h:42
s32 WPAD_DroppedEvents(s32 chan)
Data type definitions.
s32 WPAD_SetIdleThresholds(s32 chan, s32 btns, s32 ir, s32 accel, s32 js, s32 wb, s32 mp)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
Generic expansion device plugged into wiimote.
Definition: wiiuse.h:528
Definition: wpad.h:92
s32 WPAD_SetEventBufs(s32 chan, WPADData *bufs, u32 cnt)
Definition: libretro.h:2275
u32 WPAD_ButtonsUp(int chan)
GLenum GLsizei len
Definition: glext.h:7389
Definition: wpad.h:96
Definition: wpad.h:44
void WPAD_EncodeData(WPADEncStatus *info, u32 flag, const s16 *pcmSamples, s32 numSamples, u8 *encData)
void(* WPADDataCallback)(s32 chan, const WPADData *data)
Definition: wpad.h:167
Definition: wpad.h:102
GLboolean enable
Definition: glext.h:12027
void WPAD_SetBatteryDeadCallback(WPADShutdownCallback cb)
Definition: wpad.c:893
Definition: wpad.h:162
Definition: wpad.h:40
struct _wpad_encstatus WPADEncStatus
s16 err
Definition: wpad.h:145
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
#define exp(a)
Definition: math.h:32
Definition: ibxm.h:9
s32 WPAD_Flush(s32 chan)
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:6303
Gravity force struct.
Definition: wiiuse.h:317
struct orient_t orient
Definition: wpad.h:157
Definition: wiiuse.h:283
void WPAD_Accel(int chan, struct vec3w_t *accel)
Definition: wpad.c:1102
Definition: wpad.h:93
s32 WPAD_Disconnect(s32 chan)
Definition: wpad.c:902
s32 WPAD_ControlSpeaker(s32 chan, s32 enable)
u32 btns_l
Definition: wpad.h:151
Definition: wpad.h:100
u8 WPAD_BatteryLevel(int chan)
Definition: wpad.c:1078
s32 WPAD_ReadEvent(s32 chan, WPADData *data)
Definition: wpad.c:671
u32 btns_u
Definition: wpad.h:153
GLenum type
Definition: glext.h:6233
void WPAD_IR(int chan, struct ir_t *ir)
Definition: wpad.c:1084
IR struct. Hold all data related to the IR tracking.
Definition: wiiuse.h:377
s32 WPAD_SetVRes(s32 chan, u32 xres, u32 yres)
Definition: wpad.c:784
u32 WPAD_ButtonsHeld(int chan)
struct _wpad_data WPADData
s32 WPAD_SendStreamData(s32 chan, void *buf, u32 len)
Definition: wpad.h:101
struct ir_t ir
Definition: wpad.h:155
u32 btns_h
Definition: wpad.h:150
s32 WPAD_IsSpeakerEnabled(s32 chan)
void WPAD_Shutdown()
Definition: wpad.c:928
const GLenum * bufs
Definition: glext.h:6666
int16_t s16
16bit signed integer
Definition: gctypes.h:23
s32 WPAD_SetMotionPlus(s32 chan, u8 enable)
Definition: wpad.c:756
WPADData * WPAD_Data(int chan)
Definition: wpad.c:1072
struct vec3w_t accel
Definition: wpad.h:156
Definition: wpad.h:41
Definition: wpad.h:108
Definition: wpad.h:43
void(* WPADShutdownCallback)(s32 chan)
Definition: wpad.h:168
Definition: wpad.h:95
struct expansion_t exp
Definition: wpad.h:159
s32 WPAD_Rumble(s32 chan, int status)
struct gforce_t gforce
Definition: wpad.h:158
void WPAD_SetIdleTimeout(u32 seconds)
Definition: wpad.c:958
void WPAD_Orientation(int chan, struct orient_t *orient)
Definition: wpad.c:1090
Definition: wpad.h:94
s32 WPAD_Probe(s32 chan, u32 *type)
Definition: wpad.c:824
Orientation struct.
Definition: wiiuse.h:303
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
s32 WPAD_Init()
Definition: wpad.c:590
Definition: wpad.h:91
u32 data_present
Definition: wpad.h:147
Definition: wpad.h:45
s32 WPAD_ReadPending(s32 chan, WPADDataCallback datacb)
Definition: wpad.c:744
Definition: wpad.h:143
u8 battery_level
Definition: wpad.h:148