int joy_numbuttons;
int *joy_axis_keydown;
int joy_hat_down;
+ unsigned int joy_axis_as_btn; // bitmask; vs axes of centered sticks
unsigned int redraw:1;
unsigned int abs_to_udlr:1;
unsigned int hat_warned:1;
const char * const * key_names = in_sdl_keys;
struct in_sdl_state *state;
SDL_Joystick *joy;
- int i, joycount;
+ int i, a, joycount;
char name[256];
if (pdata->key_names)
state->joy_id = i;
state->joy_numbuttons = SDL_JoystickNumButtons(joy);
state->drv = drv;
+ for (a = 0; a < state->joy_numaxes; a++)
+ if (SDL_JoystickGetAxis(joy, a) < -16384)
+ state->joy_axis_as_btn |= 1u << a;
snprintf(name, sizeof(name), IN_SDL_PREFIX "%s", SDL_JoystickName(i));
in_register(name, -1, state, SDLK_LAST, key_names, 0);
+
+ printf(" %s: %d buttons %d axes %d hat(s), "
+ "guessed axis_as_btn mask: %x\n",
+ name, state->joy_numbuttons, state->joy_numaxes,
+ SDL_JoystickNumHats(joy), state->joy_axis_as_btn);
}
if (joycount > 0)
// some pressure sensitive buttons appear as an axis that goes
// from -32768 (released) to 32767 (pressed) and there is no
// way to distinguish from ones centered at 0? :(
- //else
- // kc = kc_axis_base + event->jaxis.axis * 2;
+ else if (!(state->joy_axis_as_btn & (1u << event->jaxis.axis)))
+ kc = kc_axis_base + event->jaxis.axis * 2;
down = 1;
}
else if (event->jaxis.value > 16384) {