/* * Update the controller's state. */ void xc_update(ALLEGRO_EVENT event) { // TODO: there has to be a better way to do this... ALLEGRO_JOYSTICK *id = event.joystick.id; XC_STATE *state = NULL; int i; for (i = 0; i<7; i++) { if (controllers[i] == NULL) continue; if (controllers[i]->joy == id) { state = controllers[i]; break; } } if (state == NULL) return; switch (event.type) { case XC_EVENT_AXIS: xc_update_axes(state, event); break; case XC_EVENT_BUTTON_DOWN: case XC_EVENT_BUTTON_UP: xc_update_buttons(state, event); break; default: fprintf(stderr, "[XC] Error: unrecognized event (%d)\n", event.type); break; } }
void xc_update(ALLEGRO_EVENT event,XC_STATE *controller) { switch (event.type) { case XC_EVENT_AXIS: xc_update_axes(controller, event); break; case XC_EVENT_BUTTON_DOWN: case XC_EVENT_BUTTON_UP: xc_update_buttons(controller, event); break; default: fprintf(stderr, "[XC] Error: unrecognized event (%d)\n", event.type); break; } }