|
|
@@ -26,6 +26,38 @@ void IZ_JoystickHandleDeviceEvents(IZ_JoystickState* state, SDL_Event e) { |
|
|
|
|
|
|
|
void IZ_JoystickHandleAxisEvents(IZ_JoystickState* state, IZ_Action* action, SDL_Event e) { |
|
|
|
if (e.type == SDL_JOYAXISMOTION) { |
|
|
|
// XInput handling |
|
|
|
u8 control_index; |
|
|
|
for (control_index = 4; control_index < IZ_CONTROLS; control_index += 1) { |
|
|
|
if (e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_LEFT_SHOULDER && state->config.control_mapping[control_index] == 10) { |
|
|
|
const u16 bitflag = (0x1 << control_index); |
|
|
|
|
|
|
|
if (e.jaxis.value > state->config.axis_threshold) { |
|
|
|
*action |= bitflag; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (e.jaxis.value <= state->config.axis_threshold) { |
|
|
|
*action &= ~bitflag; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_RIGHT_SHOULDER && state->config.control_mapping[control_index] == 11) { |
|
|
|
const u16 bitflag = (0x1 << control_index); |
|
|
|
|
|
|
|
if (e.jaxis.value > state->config.axis_threshold) { |
|
|
|
*action |= bitflag; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (e.jaxis.value <= state->config.axis_threshold) { |
|
|
|
*action &= ~bitflag; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( |
|
|
|
e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 |
|
|
|
|| e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_HORIZONTAL2 |
|
|
@@ -72,6 +104,7 @@ void IZ_JoystickHandleHatEvents(IZ_Action* action, SDL_Event e) { |
|
|
|
|
|
|
|
void IZ_JoystickHandleButtonEvents(IZ_JoystickState* state, IZ_Action* action, SDL_Event e) { |
|
|
|
u8 control_index; |
|
|
|
|
|
|
|
for (control_index = 4; control_index < IZ_CONTROLS; control_index += 1) { |
|
|
|
if (e.jbutton.button == state->config.control_mapping[control_index]) { |
|
|
|
const u16 bitflag = (0x1 << control_index); |
|
|
|