10 #define JS_EVENT_BUTTON 0x01
11 #define JS_EVENT_AXIS 0x02
12 #define JS_EVENT_INIT 0x80
21 #define JSIOCGVERSION _IOR('j', 0x01, unsigned int)
32 FBCALL int fb_GfxGetJoystick(
int id, ssize_t *buttons,
float *a1,
float *a2,
float *a3,
float *a4,
float *a5,
float *a6,
float *a7,
float *a8)
34 const char *device[] = {
"/dev/input/js",
40 int i, j, k, count = 0;
45 for (i = 0; i < 16; i++)
48 for (i = 0; device[i] && (count < 16); i++) {
49 for (j = 0; (j < 16) && (count < 16); j++) {
50 sprintf(device_name,
"%s%d", device[i], j);
51 joy->
fd = open(device_name, O_NONBLOCK);
54 if (version < 0x10000) {
58 for (k = 0; k < 8; k++)
59 joy->
axis[k] = -1000.0;
69 *a1 = *a2 = *a3 = *a4 = *a5 = *a6 = *a7 = *a8 = -1000.0;
71 if ((
id < 0) || (
id > 15))
78 while (read(joy->
fd, &event,
sizeof(event)) > 0) {
83 joy->
axis[
event.number] = (float)event.
value / 32767.0;
89 joy->
buttons |= (1 <<
event.number);
91 joy->
buttons &= ~(1 <<
event.number);