From 661761f047c287c08539cff8302e51aa44133ace Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Sun, 15 Dec 2024 22:22:28 -0300 Subject: [PATCH] Gamepad Gyro properly detected in SDL3 Using correct return value for SDL_SetGamepadSensorEnabled now. Added menu command for gamepad sticks. --- src/client/input/sdl3.c | 6 +++--- src/client/menu/menu.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/input/sdl3.c b/src/client/input/sdl3.c index 2bee5218..b4b61080 100644 --- a/src/client/input/sdl3.c +++ b/src/client/input/sdl3.c @@ -799,7 +799,7 @@ IN_Update(void) case SDL_EVENT_JOYSTICK_AXIS_MOTION : if ( !imu_joystick || event.gdevice.which != SDL_GetJoystickID(imu_joystick) ) { - break; // controller axes handled by SDL_CONTROLLERAXISMOTION + break; // gamepad axes handled by SDL_EVENT_GAMEPAD_AXIS_MOTION } int axis_value = event.gaxis.value; @@ -838,7 +838,7 @@ IN_Update(void) } gyro_pitch = event.gsensor.data[0] - gyro_calibration_x->value; #else // old "joystick" gyro - switch (event.gaxis.axis) // inside "case SDL_JOYAXISMOTION" here + switch (event.gaxis.axis) // inside "case SDL_EVENT_JOYSTICK_AXIS_MOTION" here { case IMU_JOY_AXIS_GYRO_PITCH: gyro_pitch = -(axis_value - gyro_calibration_x->value); @@ -2213,7 +2213,7 @@ IN_Controller_Init(qboolean notify_user) #ifdef NATIVE_SDL_GYRO if (SDL_GamepadHasSensor(controller, SDL_SENSOR_GYRO) - && !SDL_SetGamepadSensorEnabled(controller, SDL_SENSOR_GYRO, true) ) + && SDL_SetGamepadSensorEnabled(controller, SDL_SENSOR_GYRO, true) ) { show_gyro = true; Com_Printf( "Gyro sensor enabled at %.2f Hz\n", diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index a3484a29..3451a862 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -6373,6 +6373,7 @@ M_Init(void) Cmd_AddCommand("menu_gyro", M_Menu_Gyro_f); Cmd_AddCommand("menu_buttons", M_Menu_ControllerButtons_f); Cmd_AddCommand("menu_altbuttons", M_Menu_ControllerAltButtons_f); + Cmd_AddCommand("menu_sticks", M_Menu_Stick_f); Cmd_AddCommand("menu_quit", M_Menu_Quit_f); /* initialize the server address book cvars (adr0, adr1, ...)