ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
input.h
Go to the documentation of this file.
1 
6 #ifndef __INPUT_H__
7 #define __INPUT_H__
8 
9 #include <libpad.h>
10 
11 #define MODE_DIGITAL 0
12 #define MODE_ANALOG 1
13 
14 #define MODE_UNLOCKED 0
15 #define MODE_LOCKED 1
16 
17 #define PAD_LEFT 0x0080
18 #define PAD_DOWN 0x0040
19 #define PAD_RIGHT 0x0020
20 #define PAD_UP 0x0010
21 #define PAD_START 0x0008
22 #define PAD_R3 0x0004
23 #define PAD_L3 0x0002
24 #define PAD_SELECT 0x0001
25 #define PAD_SQUARE 0x8000
26 #define PAD_CROSS 0x4000
27 #define PAD_CIRCLE 0x2000
28 #define PAD_TRIANGLE 0x1000
29 #define PAD_R1 0x0800
30 #define PAD_L1 0x0400
31 #define PAD_R2 0x0200
32 #define PAD_L2 0x0100
33 
34 typedef struct {
35  char small;
36  unsigned char large;
37  char status[6];
38 } actuator_t;
39 
40 typedef struct {
41 
42  char port;
43  char slot;
44  char mode;
45  char lock;
46 
47  int type;
48 
49  char state;
50  char last_state;
51  char exec_cmd;
52  char num_modes;
54 
56 
58  char *buffer;
59 
60 } pad_t;
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
67 pad_t *pad_open(unsigned int port, unsigned int slot, unsigned int mode, unsigned int lock);
68 
70 static inline void pad_get_buttons(pad_t *pad)
71 {
72  padRead(pad->port,pad->slot,pad->buttons);
73 }
74 
76 void pad_close(pad_t *pad);
77 
79 void pad_wait(pad_t *pad);
80 
81 #ifdef DEBUG
83 void pad_print_state(pad_t *pad);
84 
86 void pad_print_supported_modes(pad_t *pad);
87 #endif
89 void pad_set_mode(pad_t *pad, int mode, int lock);
90 
92 void pad_set_sensitivity(pad_t *pad, int enable);
93 
95 void pad_init_actuators(pad_t *pad);
96 
98 void pad_set_actuators(pad_t *pad, int small, unsigned char large);
99 
101 int pad_get_state(pad_t *pad);
102 
104 int pad_get_num_modes(pad_t *pad);
105 
107 int pad_has_type(pad_t *pad, int type);
108 
110 int pad_get_type(pad_t *pad);
111 
113 int pad_get_mode(pad_t *pad);
114 
115 #ifdef __cplusplus
116 };
117 #endif
118 
119 #endif /* __INPUT_H__ */
void pad_close(pad_t *pad)
Definition: input.c:82
int pad_has_type(pad_t *pad, int type)
Definition: input.c:178
void pad_wait(pad_t *pad)
Definition: input.c:122
int pad_get_state(pad_t *pad)
Definition: input.c:103
int pad_get_type(pad_t *pad)
Definition: input.c:206
void pad_set_actuators(pad_t *pad, int small, unsigned char large)
Definition: input.c:326
static void pad_get_buttons(pad_t *pad)
Definition: input.h:70
pad_t * pad_open(unsigned int port, unsigned int slot, unsigned int mode, unsigned int lock)
Definition: input.c:10
void pad_set_sensitivity(pad_t *pad, int enable)
Definition: input.c:261
void pad_init_actuators(pad_t *pad)
Definition: input.c:288
int pad_get_mode(pad_t *pad)
void pad_set_mode(pad_t *pad, int mode, int lock)
Definition: input.c:215
int pad_get_num_modes(pad_t *pad)
Definition: input.c:145
s32 slot
Definition: libpad.c:176
s32 lock
Definition: libpad.c:200
s32 port
Definition: libpad.c:176
unsigned char padRead(int port, int slot, struct padButtonStatus *data)
Definition: libpad.c:470
s32 mode
Definition: rpc_client.c:15
char small
Definition: input.h:35
unsigned char large
Definition: input.h:36
Definition: input.h:40
int type
Definition: input.h:47
char slot
Definition: input.h:43
char lock
Definition: input.h:45
char * buffer
Definition: input.h:58
char last_state
Definition: input.h:50
char exec_cmd
Definition: input.h:51
actuator_t * actuator
Definition: input.h:57
char num_modes
Definition: input.h:52
char mode
Definition: input.h:44
char state
Definition: input.h:49
char port
Definition: input.h:42
char sensitivity
Definition: input.h:53
struct padButtonStatus * buttons
Definition: input.h:55