psl1ght
A free SDK for Sony's PS3 console
pad.h
Go to the documentation of this file.
1 
5 #ifndef __LV2_PAD_H__
6 #define __LV2_PAD_H__
7 
8 #include <ppu-types.h>
9 
10 #define MAX_PADS (127)
11 #define MAX_PAD_CODES (64)
12 #define MAX_PORT_NUM (7)
13 #define MAX_PAD_CAPABILITY_INFO (32)
14 #define MAX_PAD_ACTUATOR (2)
16 #define PAD_TYPE_STANDARD (0)
17 #define PAD_TYPE_REMOTE (4)
18 #define PAD_TYPE_LDD (5)
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
25 typedef struct _pad_info
26 {
27  u32 max;
28  u32 connected;
29  u32 info;
33 } padInfo;
34 
36 typedef struct _pad_info2
37 {
38  u32 max;
39  u32 connected;
40  u32 info;
45 } padInfo2;
46 
50 typedef struct _pad_data
51 {
52  s32 len;
53  union{
55  struct {
56  u16 zeroes;
57  unsigned int : 8;
58  unsigned int seven : 4;
59  unsigned int halflen : 4;
60  unsigned int : 8;
61  /* Button information */
62  /* 0: UP, 1: DOWN */
63  unsigned int BTN_LEFT : 1;
64  unsigned int BTN_DOWN : 1;
65  unsigned int BTN_RIGHT : 1;
66  unsigned int BTN_UP : 1;
67  unsigned int BTN_START : 1;
68  unsigned int BTN_R3 : 1;
69  unsigned int BTN_L3 : 1;
70  unsigned int BTN_SELECT : 1;
72  unsigned int : 8;
73  unsigned int BTN_SQUARE : 1;
74  unsigned int BTN_CROSS : 1;
75  unsigned int BTN_CIRCLE : 1;
76  unsigned int BTN_TRIANGLE : 1;
77  unsigned int BTN_R1 : 1;
78  unsigned int BTN_L1 : 1;
79  unsigned int BTN_R2 : 1;
80  unsigned int BTN_L2 : 1;
82  /* Analog nub information */
83  /* 0x0000 - 0x00FF */
85  unsigned int ANA_R_H : 16;
87  unsigned int ANA_R_V : 16;
89  unsigned int ANA_L_H : 16;
91  unsigned int ANA_L_V : 16;
92 
93  /* Pressure-sensitive information */
94  /* 0x0000 - 0x00FF */
96  unsigned int PRE_RIGHT : 16;
98  unsigned int PRE_LEFT : 16;
100  unsigned int PRE_UP : 16;
102  unsigned int PRE_DOWN : 16;
104  unsigned int PRE_TRIANGLE : 16;
106  unsigned int PRE_CIRCLE : 16;
108  unsigned int PRE_CROSS : 16;
110  unsigned int PRE_SQUARE : 16;
112  unsigned int PRE_L1 : 16;
114  unsigned int PRE_R1 : 16;
116  unsigned int PRE_L2 : 16;
118  unsigned int PRE_R2 : 16;
119 
120  /* Sensor information */
121  /* 0x0000 - 0x03FF */
123  unsigned int SENSOR_X : 16;
125  unsigned int SENSOR_Y : 16;
127  unsigned int SENSOR_Z : 16;
129  unsigned int SENSOR_G : 16;
130 
131  /* BD remote information */
132  unsigned int BTN_BDLEN : 16;
134  unsigned int BTN_BDCODE : 16;
137  u8 reserved[76];
138  };
139  };
140 } padData;
141 
145 typedef struct _pad_capability_info
146 {
147  union {
150  struct {
151  unsigned int ps3spec : 1;
152  unsigned int has_pressure : 1;
153  unsigned int has_sensors : 1;
154  unsigned int has_hps : 1;
155  unsigned int has_vibrate : 1;
156  unsigned int : 27;
158  };
159  };
161 
163 typedef struct _pad_act_param
164 {
165  union {
168  struct {
173  };
174  };
176  u8 reserved[6];
177 } padActParam;
178 
180 typedef struct _pad_periph_info
181 {
182  u32 max;
183  u32 connected;
184  u32 info;
199 } padPeriphInfo;
200 
202 typedef struct _pad_periph_data
203 {
206  s32 len;
208 } padPeriphData;
209 
211 typedef enum _io_pad_bd_code
212 {
213  BTN_BD_KEY_1 = 0x00,
214  BTN_BD_KEY_2 = 0x01,
215  BTN_BD_KEY_3 = 0x02,
216  BTN_BD_KEY_4 = 0x03,
217  BTN_BD_KEY_5 = 0x04,
218  BTN_BD_KEY_6 = 0x05,
219  BTN_BD_KEY_7 = 0x06,
220  BTN_BD_KEY_8 = 0x07,
221  BTN_BD_KEY_9 = 0x08,
222  BTN_BD_KEY_0 = 0x09,
223  BTN_BD_ENTER = 0x0b,
224  BTN_BD_RETURN = 0x0e,
225  BTN_BD_CLEAR = 0x0f,
226  BTN_BD_EJECT = 0x16,
227  BTN_BD_TOPMENU = 0x1a,
228  BTN_BD_TIME = 0x28,
229  BTN_BD_PREV = 0x30,
230  BTN_BD_NEXT = 0x31,
231  BTN_BD_PLAY = 0x32,
232  BTN_BD_SCAN_REV = 0x33,
233  BTN_BD_SCAN_FWD = 0x34,
234  BTN_BD_STOP = 0x38,
235  BTN_BD_PAUSE = 0x39,
236  BTN_BD_POPUP_MENU = 0x40,
237  BTN_BD_SELECT = 0x50,
238  BTN_BD_L3 = 0x51,
239  BTN_BD_R3 = 0x52,
240  BTN_BD_START = 0x53,
241  BTN_BD_UP = 0x54,
242  BTN_BD_RIGHT = 0x55,
243  BTN_BD_DOWN = 0x56,
244  BTN_BD_LEFT = 0x57,
245  BTN_BD_L2 = 0x58,
246  BTN_BD_R2 = 0x59,
247  BTN_BD_L1 = 0x5a,
248  BTN_BD_R1 = 0x5b,
249  BTN_BD_TRIANGLE = 0x5c,
250  BTN_BD_CIRCLE = 0x5d,
251  BTN_BD_CROSS = 0x5e,
252  BTN_BD_SQUARE = 0x5f,
253  BTN_BD_SLOW_REV = 0x60,
254  BTN_BD_SLOW_FWD = 0x61,
255  BTN_BD_SUBTITLE = 0x63,
256  BTN_BD_AUDIO = 0x64,
257  BTN_BD_ANGLE = 0x65,
258  BTN_BD_DISPLAY = 0x70,
259  BTN_BD_BLUE = 0x80,
260  BTN_BD_RED = 0x81,
261  BTN_BD_GREEN = 0x82,
262  BTN_BD_YELLOW = 0x83,
263  BTN_BD_RELEASE = 0xff,
264 
265  /* TV controller */
266  BTN_BD_NUMBER_11 = 0x101e,
267  BTN_BD_NUMBER_12 = 0x101f,
268  BTN_BD_NUMBER_PERIOD = 0x102a,
269  BTN_BD_PROGRAM_UP = 0x1030,
270  BTN_BD_PROGRAM_DOWN = 0x1031,
271  BTN_BD_PREV_CHANNEL = 0x1032,
272  BTN_BD_PROGRAM_GUIDE = 0x1053
273 } ioPadBdCode;
274 
279 s32 ioPadInit(u32 max);
280 
284 s32 ioPadEnd();
285 
290 s32 ioPadGetInfo(padInfo* info);
291 
296 s32 ioPadClearBuf(u32 port);
297 
303 s32 ioPadGetCapabilityInfo(u32 port, padCapabilityInfo* capabilities);
304 
310 s32 ioPadGetData(u32 port, padData* data);
311 
318 s32 ioPadGetDataExtra(u32 port, u32* type, padData* data);
319 
324 s32 ioPadInfoPressMode(u32 port);
325 
331 s32 ioPadSetPressMode(u32 port, u32 mode);
332 
337 s32 ioPadInfoSensorMode(u32 port);
338 
344 s32 ioPadSetSensorMode(u32 port, u32 mode);
345 
351 u32 ioPadSetActDirect(u32 port, padActParam* actParam);
352 
359 u32 ioPadLddDataInsert(s32 handle, padData* data);
360 
365 s32 ioPadLddGetPortNo(s32 handle);
366 
371 
376 s32 ioPadLddUnregisterController(s32 handle);
377 
378 /* new in 3.41 */
383 s32 ioPadGetInfo2(padInfo2* info);
384 
389 s32 ioPadPeriphGetInfo(padPeriphInfo* periphInfo);
390 
396 s32 ioPadPeriphGetData(u32 port, padPeriphData* periphData);
397 
404 s32 ioPadSetPortSetting(u32 port, u32 setting);
405 
406 #ifdef __cplusplus
407  }
408 #endif
409 
410 #endif
#define MAX_PAD_ACTUATOR
Definition: pad.h:14
unsigned int
reserved
Definition: pad.h:57
s32 ioPadGetInfo2(padInfo2 *info)
Get pad information (new format).
u32 connected
how many pads connected
Definition: pad.h:39
unsigned int ANA_L_H
left analog nub horizontal position (0x0000 - 0x00FF)
Definition: pad.h:89
unsigned int ps3spec
controller meets ps3 specifications
Definition: pad.h:151
unsigned int SENSOR_Z
Z sensor information (0x0000 - 0x03FF)
Definition: pad.h:127
u32 pclass_profile
Pas class profile.
Definition: pad.h:205
unsigned int SENSOR_G
G sensor information (0x0000 - 0x03FF)
Definition: pad.h:129
unsigned int SENSOR_Y
Y sensor information (0x0000 - 0x03FF)
Definition: pad.h:125
struct _pad_periph_data padPeriphData
Pad peripheral data data structure.
struct _pad_periph_info padPeriphInfo
Pad peripheral information data structure.
s32 ioPadSetSensorMode(u32 port, u32 mode)
Set pad sensor mode.
unsigned int PRE_CROSS
cross button pressure information (0x0000 - 0x00FF)
Definition: pad.h:108
u32 ioPadLddDataInsert(s32 handle, padData *data)
Insert pad data into virtual pad.
unsigned int PRE_SQUARE
square button pressure information (0x0000 - 0x00FF)
Definition: pad.h:110
unsigned int ANA_R_V
right analog nub vertical position (0x0000 - 0x00FF)
Definition: pad.h:87
unsigned int PRE_L1
L1 button pressure information (0x0000 - 0x00FF)
Definition: pad.h:112
s32 ioPadEnd()
End of Pad IO management.
unsigned int ANA_R_H
right analog nub horizontal position (0x0000 - 0x00FF)
Definition: pad.h:85
unsigned int PRE_L2
L2 button pressure information (0x0000 - 0x00FF)
Definition: pad.h:116
#define MAX_PADS
Definition: pad.h:10
u32 pclass_type
Pad class type.
Definition: pad.h:204
unsigned int ANA_L_V
left analog nub vertical position (0x0000 - 0x00FF)
Definition: pad.h:91
unsigned int BTN_TRIANGLE
triangle button
Definition: pad.h:76
unsigned int BTN_R2
R2 button.
Definition: pad.h:79
s32 len
Length of button array.
Definition: pad.h:206
unsigned int PRE_TRIANGLE
triangle button pressure information (0x0000 - 0x00FF)
Definition: pad.h:104
unsigned int BTN_DOWN
down button
Definition: pad.h:64
u32 pclass_profile[MAX_PORT_NUM]
Pad class profile.
Definition: pad.h:198
struct _pad_capability_info padCapabilityInfo
Pad capability information data structure. All 1-bit values are 1 when the capability is present,...
u32 info
bit 0 lets the system intercept pad? other bits are reserved
Definition: pad.h:29
unsigned int BTN_SELECT
select button
Definition: pad.h:70
u32 port_status[MAX_PORT_NUM]
Bit 0: Connected (0: Disconnected, 1: Connected), Bit 1: assign changes?
Definition: pad.h:185
#define MAX_PAD_CAPABILITY_INFO
Definition: pad.h:13
u32 max
max pads allowed to connect
Definition: pad.h:27
u32 device_type[MAX_PORT_NUM]
0: Standard, 4: Bluray Remote, 5: LDD
Definition: pad.h:196
unsigned int BTN_R3
R3 button.
Definition: pad.h:68
unsigned int BTN_L2
L2 button.
Definition: pad.h:80
u32 info[MAX_PAD_CAPABILITY_INFO]
The whole capabilities in an array of 32-bit integers.
Definition: pad.h:149
unsigned int BTN_R1
R1 button.
Definition: pad.h:77
_io_pad_bd_code
BD remote button codes.
Definition: pad.h:211
Pad peripheral data data structure.
Definition: pad.h:202
s32 ioPadInfoPressMode(u32 port)
Get pad press mode.
#define MAX_PORT_NUM
Definition: pad.h:12
s32 ioPadInit(u32 max)
Initialize Pad IO management.
unsigned int BTN_CROSS
cross button
Definition: pad.h:74
u32 connected
how many pads connected
Definition: pad.h:183
unsigned int BTN_CIRCLE
circle button
Definition: pad.h:75
u16 zeroes
zero bits
Definition: pad.h:56
s32 ioPadGetDataExtra(u32 port, u32 *type, padData *data)
Get pad data.
unsigned int has_vibrate
controller has inbuilt vibration motor
Definition: pad.h:155
u32 reserved[MAX_PAD_CAPABILITY_INFO-1]
reserved
Definition: pad.h:157
unsigned int seven
always 0x7
Definition: pad.h:58
u8 reserved[76]
BD remote code information see ioPadBdCode for values.
Definition: pad.h:137
Pad capability information data structure. All 1-bit values are 1 when the capability is present,...
Definition: pad.h:145
u32 max
max pads allowed to connect
Definition: pad.h:182
unsigned int PRE_R1
R1 button pressure information (0x0000 - 0x00FF)
Definition: pad.h:114
unsigned int PRE_RIGHT
right button pressure information (0x0000 - 0x00FF)
Definition: pad.h:96
unsigned int BTN_SQUARE
square button
Definition: pad.h:73
u8 motor[MAX_PAD_ACTUATOR]
All motors statuses.
Definition: pad.h:167
Pad info data structure (old format).
Definition: pad.h:25
unsigned int BTN_LEFT
left button
Definition: pad.h:63
u32 device_type[MAX_PORT_NUM]
0: Standard, 4: Bluray Remote, 5: LDD
Definition: pad.h:44
u8 reserved[6]
reserved
Definition: pad.h:176
s32 ioPadGetCapabilityInfo(u32 port, padCapabilityInfo *capabilities)
Get pad capability information.
s32 ioPadPeriphGetData(u32 port, padPeriphData *periphData)
Get pad peripheral data.
u32 connected
how many pads connected
Definition: pad.h:28
struct _pad_info padInfo
Pad info data structure (old format).
s32 ioPadGetInfo(padInfo *info)
Get pad information.
struct _pad_data padData
Pad data data structure. All 1-bit button fields are zero when inctive, and 1 when active.
unsigned int BTN_RIGHT
right button
Definition: pad.h:65
unsigned int PRE_UP
up button pressure information (0x0000 - 0x00FF)
Definition: pad.h:100
unsigned int BTN_START
start button
Definition: pad.h:67
struct _pad_act_param padActParam
Pad action parameters data structure.
s32 ioPadInfoSensorMode(u32 port)
Get pad sensor mode.
unsigned int BTN_L3
L3 button.
Definition: pad.h:69
u16 button[MAX_PAD_CODES]
array of button values
Definition: pad.h:54
Pad peripheral information data structure.
Definition: pad.h:180
s32 ioPadSetPressMode(u32 port, u32 mode)
Set pad press mode.
u32 info
bit 0 lets the system intercept pad? other bits are reserved
Definition: pad.h:184
unsigned int PRE_LEFT
left button pressure information (0x0000 - 0x00FF)
Definition: pad.h:98
unsigned int SENSOR_X
X sensor information (0x0000 - 0x03FF)
Definition: pad.h:123
u16 button[MAX_PAD_CODES]
Button array.
Definition: pad.h:207
s32 len
structure length
Definition: pad.h:52
u32 port_setting[MAX_PORT_NUM]
Bit 1: Pressure sensitivity turned on, Bit 2: Sensors turned on.
Definition: pad.h:42
s32 ioPadLddUnregisterController(s32 handle)
Unregister a virtual pad.
unsigned int BTN_UP
up button
Definition: pad.h:66
enum _io_pad_bd_code ioPadBdCode
BD remote button codes.
u32 device_capability[MAX_PORT_NUM]
See: PadCapabilityInfo. Bit 0: PS3SPEC, Bit 1: has_pressure, Bit 2: has_sensor, Bit 3: has_hps,...
Definition: pad.h:43
unsigned int PRE_CIRCLE
circle button pressure information (0x0000 - 0x00FF)
Definition: pad.h:106
s32 ioPadSetPortSetting(u32 port, u32 setting)
Set pad port setting.
s32 ioPadLddGetPortNo(s32 handle)
Get port number from registered virtual pad handle.
unsigned int has_pressure
controller has pressure-sensitive buttons
Definition: pad.h:152
unsigned int PRE_R2
R2 button pressure information (0x0000 - 0x00FF)
Definition: pad.h:118
unsigned int has_hps
controller has high precision stick
Definition: pad.h:154
s32 ioPadPeriphGetInfo(padPeriphInfo *periphInfo)
Get pad peripheral information.
u32 ioPadSetActDirect(u32 port, padActParam *actParam)
Set pad action (rumble) data.
struct _pad_info2 padInfo2
Pad info data structure (new format).
unsigned int halflen
len/2
Definition: pad.h:59
#define MAX_PAD_CODES
Definition: pad.h:11
unsigned int BTN_L1
L1 button.
Definition: pad.h:78
u32 port_setting[MAX_PORT_NUM]
Bit 1: Pressure sensitivity turned on, Bit 2: Sensors turned on.
Definition: pad.h:186
s32 ioPadGetData(u32 port, padData *data)
Get pad data.
Pad info data structure (new format).
Definition: pad.h:36
unsigned int BTN_BDCODE
BD remote len information.
Definition: pad.h:134
unsigned int has_sensors
controller has sensors, e.g. sixaxis, X,Y,Z,G
Definition: pad.h:153
s32 ioPadLddRegisterController()
Register a new virtual pad.
u8 status[MAX_PADS]
array of pad statuses
Definition: pad.h:32
u8 small_motor
Small Motor parameter 0: OFF, 1: On.
Definition: pad.h:170
u32 info
Bit 0 lets the system intercept pad? other bits are reserved.
Definition: pad.h:40
u8 large_motor
Large Motor 0: OFF, 1-255: Motor Speed, higher == faster.
Definition: pad.h:172
u32 pclass_type[MAX_PORT_NUM]
Pad class type.
Definition: pad.h:197
u32 port_status[MAX_PORT_NUM]
Bit 0: Connected (0: Disconnected, 1: Connected), Bit 1: assign changes?
Definition: pad.h:41
u32 max
max pads allowed to connect
Definition: pad.h:38
Pad action parameters data structure.
Definition: pad.h:163
unsigned int
reserved
Definition: pad.h:156
u16 vendor_id[MAX_PADS]
array of vendor ids
Definition: pad.h:30
unsigned int PRE_DOWN
down button pressure information (0x0000 - 0x00FF)
Definition: pad.h:102
u32 device_capability[MAX_PORT_NUM]
Pad capability.
Definition: pad.h:195
Pad data data structure. All 1-bit button fields are zero when inctive, and 1 when active.
Definition: pad.h:50
s32 ioPadClearBuf(u32 port)
Clear pad buffer.
u16 product_id[MAX_PADS]
array of product ids
Definition: pad.h:31