mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-02 20:11:15 +00:00
🩹 fix: forgot to enable gamepad, and ignore small axis value
This commit is contained in:
parent
87d481d80b
commit
28d9ee70d5
@ -276,7 +276,7 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
|||||||
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
||||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)) {
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD)) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
SDL_snprintf(
|
SDL_snprintf(
|
||||||
buffer,
|
buffer,
|
||||||
@ -500,14 +500,19 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION: {
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION: {
|
||||||
|
MxS16 axisValue = 0;
|
||||||
|
if (event->gaxis.value < -8000 || event->gaxis.value > 8000) {
|
||||||
|
// Ignore small axis values
|
||||||
|
axisValue = event->gaxis.value;
|
||||||
|
}
|
||||||
if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTX) {
|
if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTX) {
|
||||||
g_lastJoystickMouseX = ((float) event->gaxis.value) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity();
|
g_lastJoystickMouseX = ((float) axisValue) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity();
|
||||||
}
|
}
|
||||||
else if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTY) {
|
else if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTY) {
|
||||||
g_lastJoystickMouseY = ((float) event->gaxis.value) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity();
|
g_lastJoystickMouseY = ((float) axisValue) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity();
|
||||||
}
|
}
|
||||||
else if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) {
|
else if (event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) {
|
||||||
if (event->gaxis.value != 0) {
|
if (axisValue != 0) {
|
||||||
g_mousedown = TRUE;
|
g_mousedown = TRUE;
|
||||||
|
|
||||||
if (InputManager()) {
|
if (InputManager()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user