PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
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
122extern "C" {
123#endif
124
129int padInit(int mode);
130
140int padPortInit(int mode);
141
149int padEnd(void);
150
158int padPortOpen(int port, int slot, void *padArea);
159
167int padPortClose(int port, int slot);
168
175unsigned char padRead(int port, int slot, struct padButtonStatus *data);
176
180int padGetState(int port, int slot);
181
183unsigned char padGetReqState(int port, int slot);
184
188int padSetReqState(int port, int slot, int state);
189
190/*
191 * Debug print functions
192 */
193void padStateInt2String(int state, char buf[16]);
194void padReqStateInt2String(int state, char buf[16]);
195
198int padGetPortMax(void);
199
203int padGetSlotMax(int port);
204
208int padGetModVersion();
209
214int padInfoMode(int port, int slot, int infoMode, int index);
215
220int padSetMainMode(int port, int slot, int mode, int lock);
221
223int padInfoPressMode(int port, int slot);
224
226int padEnterPressMode(int port, int slot);
227
231int padExitPressMode(int port, int slot);
232
233/*
234 * Dunno if these need to be exported
235 */
236int padGetButtonMask(int port, int slot);
237int padSetButtonInfo(int port, int slot, int buttonInfo);
238
243unsigned char padInfoAct(int port, int slot, int word, int byte);
244
250int padSetActAlign(int port, int slot, const char act_align[6]);
251
256int padSetActDirect(int port, int slot, char act_align[6]);
257
264int padGetConnection(int port, int slot);
265
266#ifdef __cplusplus
267}
268#endif
269
270#endif /* __LIBPAD_H__ */
int padGetPortMax(void)
Definition libpad.c:550
int padPortOpen(int port, int slot, void *padArea)
Definition libpad.c:394
int padPortInit(int mode)
Definition libpad.c:338
int padSetActAlign(int port, int slot, const char act_align[6])
Definition libpad.c:779
unsigned char padRead(int port, int slot, struct padButtonStatus *data)
Definition libpad.c:472
int padInfoMode(int port, int slot, int infoMode, int index)
Definition libpad.c:590
int padExitPressMode(int port, int slot)
Definition libpad.c:698
int padGetModVersion()
Definition libpad.c:575
int padSetActDirect(int port, int slot, char act_align[6])
Definition libpad.c:802
int padInit(int mode)
Definition libpad.c:297
int padGetConnection(int port, int slot)
Definition libpad.c:825
int padSetReqState(int port, int slot, int state)
Definition libpad.c:523
int padPortClose(int port, int slot)
Definition libpad.c:451
int padEnd(void)
Definition libpad.c:374
int padGetState(int port, int slot)
Definition libpad.c:484
unsigned char padInfoAct(int port, int slot, int word, int byte)
Definition libpad.c:740
unsigned char padGetReqState(int port, int slot)
Definition libpad.c:513
int padInfoPressMode(int port, int slot)
Definition libpad.c:677
int padSetMainMode(int port, int slot, int mode, int lock)
Definition libpad.c:658
int padEnterPressMode(int port, int slot)
Definition libpad.c:692
int padGetSlotMax(int port)
Definition libpad.c:562