1 #ifndef __PAD_H__
2 #define __PAD_H__
3 
4 #include <gctypes.h>
5 
6 #define PAD_CHAN0					0
7 #define PAD_CHAN1					1
8 #define PAD_CHAN2					2
9 #define PAD_CHAN3					3
10 #define PAD_CHANMAX					4
11 
12 #define PAD_MOTOR_STOP				0
13 #define PAD_MOTOR_RUMBLE			1
14 #define PAD_MOTOR_STOP_HARD			2
15 
16 #define PAD_ERR_NONE				0
17 #define PAD_ERR_NO_CONTROLLER		-1
18 #define PAD_ERR_NOT_READY			-2
19 #define PAD_ERR_TRANSFER			-3
20 
21 #define PAD_BUTTON_LEFT				0x0001
22 #define PAD_BUTTON_RIGHT			0x0002
23 #define PAD_BUTTON_DOWN				0x0004
24 #define PAD_BUTTON_UP				0x0008
25 #define PAD_TRIGGER_Z				0x0010
26 #define PAD_TRIGGER_R				0x0020
27 #define PAD_TRIGGER_L				0x0040
28 #define PAD_BUTTON_A				0x0100
29 #define PAD_BUTTON_B				0x0200
30 #define PAD_BUTTON_X				0x0400
31 #define PAD_BUTTON_Y				0x0800
32 #define PAD_BUTTON_MENU				0x1000
33 #define PAD_BUTTON_START			0x1000
34 
35 #define PAD_CHAN0_BIT				0x80000000
36 #define PAD_CHAN1_BIT				0x40000000
37 #define PAD_CHAN2_BIT				0x20000000
38 #define PAD_CHAN3_BIT				0x10000000
39 /*+----------------------------------------------------------------------------------------------+*/
40 /*+----------------------------------------------------------------------------------------------+*/
41 /*+----------------------------------------------------------------------------------------------+*/
42 #ifdef __cplusplus
43    extern "C" {
44 #endif /* __cplusplus */
45 /*+----------------------------------------------------------------------------------------------+*/
46 typedef struct _padstatus {
47 	u16 button;
48 	s8 stickX;
49 	s8 stickY;
50 	s8 substickX;
51 	s8 substickY;
52 	u8 triggerL;
53 	u8 triggerR;
54 	u8 analogA;
55 	u8 analogB;
56 	s8 err;
57 } PADStatus;
58 
59 typedef void (*sampling_callback)(void);
60 /*+----------------------------------------------------------------------------------------------+*/
61 /*+----------------------------------------------------------------------------------------------+*/
62 /*+----------------------------------------------------------------------------------------------+*/
63 
64 u32 PAD_Init();
65 u32 PAD_Sync();
66 u32 PAD_Read(PADStatus *status);
67 u32 PAD_Reset(u32 mask);
68 u32 PAD_Recalibrate(u32 mask);
69 void PAD_Clamp(PADStatus *status);
70 void PAD_ControlMotor(s32 chan,u32 cmd);
71 void PAD_SetSpec(u32 spec);
72 
73 u32 PAD_ScanPads();
74 
75 u16 PAD_ButtonsUp(int pad);
76 u16 PAD_ButtonsDown(int pad);
77 u16 PAD_ButtonsHeld(int pad);
78 
79 s8 PAD_SubStickX(int pad);
80 s8 PAD_SubStickY(int pad);
81 
82 s8 PAD_StickX(int pad);
83 s8 PAD_StickY(int pad);
84 
85 u8 PAD_TriggerL(int pad);
86 u8 PAD_TriggerR(int pad);
87 
88 sampling_callback PAD_SetSamplingCallback(sampling_callback cb);
89 
90 /*+----------------------------------------------------------------------------------------------+*/
91 
92 #ifdef __cplusplus
93    }
94 #endif /* __cplusplus */
95 
96 #endif
97