PCem

view src/allegro-joystick.c @ 154:d0d530adce12

Initial port to Linux (using Allegro). 64-bit fixes. Some changes to aid portability. A few other tweaks.
author TomW
date Thu Sep 04 21:07:24 2014 +0100
parents
children
line source
1 #include "allegro-main.h"
2 #include "plat-joystick.h"
4 joystick_t joystick_state[2];
5 int joysticks_present;
7 void joystick_init()
8 {
9 install_joystick(JOY_TYPE_AUTODETECT);
10 joysticks_present = MIN(num_joysticks, 2);
11 }
12 void joystick_close()
13 {
14 }
15 void joystick_poll()
16 {
17 int c;
19 poll_joystick();
21 for (c = 0; c < MIN(num_joysticks, 2); c++)
22 {
23 joystick_state[c].x = joy[c].stick[0].axis[0].pos * 256;
24 joystick_state[c].y = joy[c].stick[0].axis[1].pos * 256;
25 joystick_state[c].b[0] = joy[c].button[0].b;
26 joystick_state[c].b[1] = joy[c].button[1].b;
27 joystick_state[c].b[2] = joy[c].button[2].b;
28 joystick_state[c].b[3] = joy[c].button[3].b;
29 }
30 }