PS2SDK
PS2 Homebrew Libraries
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 extern int padInit(int mode);
130 
140 extern int padPortInit(int mode);
141 
149 extern int padEnd(void);
150 
158 extern int padPortOpen(int port, int slot, void *padArea);
159 
167 extern int padPortClose(int port, int slot);
168 
175 extern unsigned char padRead(int port, int slot, struct padButtonStatus *data);
176 
180 extern int padGetState(int port, int slot);
181 
183 extern unsigned char padGetReqState(int port, int slot);
184 
188 extern int padSetReqState(int port, int slot, int state);
189 
190 /*
191  * Debug print functions
192  */
193 extern void padStateInt2String(int state, char buf[16]);
194 extern void padReqStateInt2String(int state, char buf[16]);
195 
198 extern int padGetPortMax(void);
199 
203 extern int padGetSlotMax(int port);
204 
208 extern int padGetModVersion();
209 
214 extern int padInfoMode(int port, int slot, int infoMode, int index);
215 
220 extern int padSetMainMode(int port, int slot, int mode, int lock);
221 
223 extern int padInfoPressMode(int port, int slot);
224 
226 extern int padEnterPressMode(int port, int slot);
227 
231 extern int padExitPressMode(int port, int slot);
232 
233 /*
234  * Dunno if these need to be exported
235  */
236 extern int padGetButtonMask(int port, int slot);
237 extern int padSetButtonInfo(int port, int slot, int buttonInfo);
238 
243 extern unsigned char padInfoAct(int port, int slot, int actuator, int cmd);
244 
250 extern int padSetActAlign(int port, int slot, const char actAlign[6]);
251 
256 extern int padSetActDirect(int port, int slot, const char actAlign[6]);
257 
264 extern int padGetConnection(int port, int slot);
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif /* __LIBPAD_H__ */
padSetReqState
int padSetReqState(int port, int slot, int state)
Definition: libpad.c:706
padExitPressMode
int padExitPressMode(int port, int slot)
Definition: libpad.c:909
padPortClose
int padPortClose(int port, int slot)
Definition: libpad.c:574
padEnterPressMode
int padEnterPressMode(int port, int slot)
Definition: libpad.c:903
padSetActAlign
int padSetActAlign(int port, int slot, const char actAlign[6])
Definition: libpad.c:1025
padRead
unsigned char padRead(int port, int slot, struct padButtonStatus *data)
Definition: libpad.c:612
padInit
int padInit(int mode)
Definition: libpad.c:300
padPortOpen
int padPortOpen(int port, int slot, void *padArea)
Definition: libpad.c:462
padPortInit
int padPortInit(int mode)
Definition: libpad.c:386
padInfoMode
int padInfoMode(int port, int slot, int infoMode, int index)
Definition: libpad.c:805
padGetSlotMax
int padGetSlotMax(int port)
Definition: libpad.c:766
padGetPortMax
int padGetPortMax(void)
Definition: libpad.c:741
padGetState
int padGetState(int port, int slot)
Definition: libpad.c:645
padGetReqState
unsigned char padGetReqState(int port, int slot)
Definition: libpad.c:687
padGetConnection
int padGetConnection(int port, int slot)
Definition: libpad.c:1088
padEnd
int padEnd(void)
Definition: libpad.c:431
padSetMainMode
int padSetMainMode(int port, int slot, int mode, int lock)
Definition: libpad.c:866
padSetActDirect
int padSetActDirect(int port, int slot, const char actAlign[6])
Definition: libpad.c:1056
__attribute__
Definition: gif_registers.h:38
padInfoAct
unsigned char padInfoAct(int port, int slot, int actuator, int cmd)
Definition: libpad.c:972
padInfoPressMode
int padInfoPressMode(int port, int slot)
Definition: libpad.c:897
padButtonStatus
Definition: libpad.h:95
padGetModVersion
int padGetModVersion()
Definition: libpad.c:792