ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
libpad.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #ifndef __LIBPAD_H__
17 #define __LIBPAD_H__
18 
19 /*
20  * Button bits
21  */
22 #ifndef __INPUT_H__
23 #define PAD_LEFT 0x0080
24 #define PAD_DOWN 0x0040
25 #define PAD_RIGHT 0x0020
26 #define PAD_UP 0x0010
27 #define PAD_START 0x0008
28 #define PAD_R3 0x0004
29 #define PAD_L3 0x0002
30 #define PAD_SELECT 0x0001
31 #define PAD_SQUARE 0x8000
32 #define PAD_CROSS 0x4000
33 #define PAD_CIRCLE 0x2000
34 #define PAD_TRIANGLE 0x1000
35 #define PAD_R1 0x0800
36 #define PAD_L1 0x0400
37 #define PAD_R2 0x0200
38 #define PAD_L2 0x0100
39 #endif
40 /*
41  * Pad states
42  */
43 #define PAD_STATE_DISCONN 0x00
44 #define PAD_STATE_FINDPAD 0x01
45 #define PAD_STATE_FINDCTP1 0x02
46 #define PAD_STATE_EXECCMD 0x05
47 #define PAD_STATE_STABLE 0x06
48 #define PAD_STATE_ERROR 0x07
49 
50 /*
51  * Pad request states
52  */
53 #define PAD_RSTAT_COMPLETE 0x00
54 #define PAD_RSTAT_FAILED 0x01
55 #define PAD_RSTAT_BUSY 0x02
56 
57 /*
58  * Connected pad type
59  */
60 #define PAD_TYPE_NEJICON 0x2
61 #define PAD_TYPE_KONAMIGUN 0x3
62 #define PAD_TYPE_DIGITAL 0x4
63 #define PAD_TYPE_ANALOG 0x5
64 #define PAD_TYPE_NAMCOGUN 0x6
65 #define PAD_TYPE_DUALSHOCK 0x7
66 #define PAD_TYPE_JOGCON 0xE
67 #define PAD_TYPE_EX_TSURICON 0x100
68 #define PAD_TYPE_EX_JOGCON 0x300
69 /*
70  * padInfoMode values
71  */
72 #define PAD_MODECURID 1
73 #define PAD_MODECUREXID 2
74 #define PAD_MODECUROFFS 3
75 #define PAD_MODETABLE 4
76 
77 /*
78  * padSetMainMode
79  */
80 #define PAD_MMODE_DIGITAL 0
81 #define PAD_MMODE_DUALSHOCK 1
82 
83 #define PAD_MMODE_UNLOCK 2
84 #define PAD_MMODE_LOCK 3
85 
86 /*
87  * padInfoAct cmds
88  */
89 #define PAD_ACTFUNC 1
90 #define PAD_ACTSUB 2
91 #define PAD_ACTSIZE 3
92 #define PAD_ACTCURR 4
93 
96 {
97  unsigned char ok;
98  unsigned char mode;
99  unsigned short btns;
100  // joysticks
101  unsigned char rjoy_h;
102  unsigned char rjoy_v;
103  unsigned char ljoy_h;
104  unsigned char ljoy_v;
105  // pressure mode
106  unsigned char right_p;
107  unsigned char left_p;
108  unsigned char up_p;
109  unsigned char down_p;
110  unsigned char triangle_p;
111  unsigned char circle_p;
112  unsigned char cross_p;
113  unsigned char square_p;
114  unsigned char l1_p;
115  unsigned char r1_p;
116  unsigned char l2_p;
117  unsigned char r2_p;
118  unsigned char unkn16[12];
119 } __attribute__((packed));
120 
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124 
129 int padInit(int mode);
130 
140 int padPortInit(int mode);
141 
149 int padEnd(void);
150 
158 int padPortOpen(int port, int slot, void *padArea);
159 
167 int padPortClose(int port, int slot);
168 
175 unsigned char padRead(int port, int slot, struct padButtonStatus *data);
176 
180 int padGetState(int port, int slot);
181 
183 unsigned char padGetReqState(int port, int slot);
184 
188 int padSetReqState(int port, int slot, int state);
189 
190 /*
191  * Debug print functions
192  */
193 void padStateInt2String(int state, char buf[16]);
194 void padReqStateInt2String(int state, char buf[16]);
195 
198 int padGetPortMax(void);
199 
203 int padGetSlotMax(int port);
204 
208 int padGetModVersion();
209 
214 int padInfoMode(int port, int slot, int infoMode, int index);
215 
220 int padSetMainMode(int port, int slot, int mode, int lock);
221 
223 int padInfoPressMode(int port, int slot);
224 
226 int padEnterPressMode(int port, int slot);
227 
231 int padExitPressMode(int port, int slot);
232 
233 /*
234  * Dunno if these need to be exported
235  */
236 int padGetButtonMask(int port, int slot);
237 int padSetButtonInfo(int port, int slot, int buttonInfo);
238 
243 unsigned char padInfoAct(int port, int slot, int word, int byte);
244 
250 int padSetActAlign(int port, int slot, char act_align[6]);
251 
256 int padSetActDirect(int port, int slot, char act_align[6]);
257 
264 int padGetConnection(int port, int slot);
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif /* __LIBPAD_H__ */
u32 data
Definition: libmouse.c:36
s32 buttonInfo
Definition: libpad.c:213
s32 index
Definition: libpad.c:194
s32 infoMode
Definition: libpad.c:193
s32 slot
Definition: libpad.c:176
void * padArea
Definition: libpad.c:178
s32 lock
Definition: libpad.c:200
s32 port
Definition: libpad.c:176
int padGetPortMax(void)
Definition: libpad.c:548
int padPortOpen(int port, int slot, void *padArea)
Definition: libpad.c:392
int padPortInit(int mode)
Definition: libpad.c:338
unsigned char padRead(int port, int slot, struct padButtonStatus *data)
Definition: libpad.c:470
int padInfoMode(int port, int slot, int infoMode, int index)
Definition: libpad.c:588
int padGetButtonMask(int port, int slot)
Definition: libpad.c:703
int padExitPressMode(int port, int slot)
Definition: libpad.c:696
int padGetModVersion()
Definition: libpad.c:573
int padSetActAlign(int port, int slot, char act_align[6])
Definition: libpad.c:777
int padSetActDirect(int port, int slot, char act_align[6])
Definition: libpad.c:800
int padInit(int mode)
Definition: libpad.c:297
int padSetButtonInfo(int port, int slot, int buttonInfo)
Definition: libpad.c:717
int padGetConnection(int port, int slot)
Definition: libpad.c:823
void padReqStateInt2String(int state, char buf[16])
Definition: libpad.c:541
int padSetReqState(int port, int slot, int state)
Definition: libpad.c:521
int padPortClose(int port, int slot)
Definition: libpad.c:449
int padEnd(void)
Definition: libpad.c:372
int padGetState(int port, int slot)
Definition: libpad.c:482
unsigned char padInfoAct(int port, int slot, int word, int byte)
Definition: libpad.c:738
unsigned char padGetReqState(int port, int slot)
Definition: libpad.c:511
int padInfoPressMode(int port, int slot)
Definition: libpad.c:675
void padStateInt2String(int state, char buf[16])
Definition: libpad.c:532
int padSetMainMode(int port, int slot, int mode, int lock)
Definition: libpad.c:656
int padEnterPressMode(int port, int slot)
Definition: libpad.c:690
int padGetSlotMax(int port)
Definition: libpad.c:560
s32 mode
Definition: rpc_client.c:15
int word
Definition: standard.h:48
unsigned char l1_p
Definition: libpad.h:114
unsigned char down_p
Definition: libpad.h:109
unsigned char right_p
Definition: libpad.h:106
unsigned char mode
Definition: libpad.h:98
unsigned char left_p
Definition: libpad.h:107
unsigned short btns
Definition: libpad.h:99
unsigned char l2_p
Definition: libpad.h:116
unsigned char circle_p
Definition: libpad.h:111
unsigned char square_p
Definition: libpad.h:113
unsigned char rjoy_v
Definition: libpad.h:102
unsigned char up_p
Definition: libpad.h:108
unsigned char ok
Definition: libpad.h:97
unsigned char unkn16[12]
Definition: libpad.h:118
unsigned char r2_p
Definition: libpad.h:117
unsigned char r1_p
Definition: libpad.h:115
unsigned char triangle_p
Definition: libpad.h:110
unsigned char cross_p
Definition: libpad.h:112
unsigned char ljoy_h
Definition: libpad.h:103
unsigned char ljoy_v
Definition: libpad.h:104
unsigned char rjoy_h
Definition: libpad.h:101