The gamepad event structures caxis, cbutton, cdevice, ctouchpad, and csensor have been renamed gaxis, gbutton, gdevice, gtouchpad, and gsensor.

Fixes https://github.com/libsdl-org/SDL/issues/7375
This commit is contained in:
Sam Lantinga 2023-03-01 09:13:01 -08:00
parent 8d8b3d3a9a
commit d5775f6708
8 changed files with 137 additions and 74 deletions

View File

@ -2467,3 +2467,53 @@ expression e2;
- SDL_IsScreenSaverEnabled - SDL_IsScreenSaverEnabled
+ SDL_ScreenSaverEnabled + SDL_ScreenSaverEnabled
(...) (...)
@@
SDL_Event e1;
@@
- e1.caxis
+ e1.gaxis
@@
SDL_Event e1;
@@
- e1.cbutton
+ e1.gbutton
@@
SDL_Event e1;
@@
- e1.cdevice
+ e1.gdevice
@@
SDL_Event e1;
@@
- e1.ctouchpad
+ e1.gtouchpad
@@
SDL_Event e1;
@@
- e1.csensor
+ e1.gsensor
@@
SDL_Event *e1;
@@
- e1->caxis
+ e1->gaxis
@@
SDL_Event *e1;
@@
- e1->cbutton
+ e1->gbutton
@@
SDL_Event *e1;
@@
- e1->cdevice
+ e1->gdevice
@@
SDL_Event *e1;
@@
- e1->ctouchpad
+ e1->gtouchpad
@@
SDL_Event *e1;
@@
- e1->csensor
+ e1->gsensor

View File

@ -148,6 +148,8 @@ The SDL_EVENT_WINDOW_RESIZED event is always sent, even in response to SDL_SetWi
The SDL_EVENT_WINDOW_SIZE_CHANGED event has been removed, and you can use SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED to detect window backbuffer size changes. The SDL_EVENT_WINDOW_SIZE_CHANGED event has been removed, and you can use SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED to detect window backbuffer size changes.
The gamepad event structures caxis, cbutton, cdevice, ctouchpad, and csensor have been renamed gaxis, gbutton, gdevice, gtouchpad, and gsensor.
SDL_QUERY, SDL_IGNORE, SDL_ENABLE, and SDL_DISABLE have been removed. You can use the functions SDL_SetEventEnabled() and SDL_EventEnabled() to set and query event processing state. SDL_QUERY, SDL_IGNORE, SDL_ENABLE, and SDL_DISABLE have been removed. You can use the functions SDL_SetEventEnabled() and SDL_EventEnabled() to set and query event processing state.
The following symbols have been renamed: The following symbols have been renamed:

View File

@ -405,7 +405,7 @@ typedef struct SDL_JoyBatteryEvent
} SDL_JoyBatteryEvent; } SDL_JoyBatteryEvent;
/** /**
* \brief Gamepad axis motion event structure (event.caxis.*) * \brief Gamepad axis motion event structure (event.gaxis.*)
*/ */
typedef struct SDL_GamepadAxisEvent typedef struct SDL_GamepadAxisEvent
{ {
@ -422,7 +422,7 @@ typedef struct SDL_GamepadAxisEvent
/** /**
* \brief Gamepad button event structure (event.cbutton.*) * \brief Gamepad button event structure (event.gbutton.*)
*/ */
typedef struct SDL_GamepadButtonEvent typedef struct SDL_GamepadButtonEvent
{ {
@ -437,7 +437,7 @@ typedef struct SDL_GamepadButtonEvent
/** /**
* \brief Gamepad device event structure (event.cdevice.*) * \brief Gamepad device event structure (event.gdevice.*)
*/ */
typedef struct SDL_GamepadDeviceEvent typedef struct SDL_GamepadDeviceEvent
{ {
@ -447,7 +447,7 @@ typedef struct SDL_GamepadDeviceEvent
} SDL_GamepadDeviceEvent; } SDL_GamepadDeviceEvent;
/** /**
* \brief Gamepad touchpad event structure (event.ctouchpad.*) * \brief Gamepad touchpad event structure (event.gtouchpad.*)
*/ */
typedef struct SDL_GamepadTouchpadEvent typedef struct SDL_GamepadTouchpadEvent
{ {
@ -462,7 +462,7 @@ typedef struct SDL_GamepadTouchpadEvent
} SDL_GamepadTouchpadEvent; } SDL_GamepadTouchpadEvent;
/** /**
* \brief Gamepad sensor event structure (event.csensor.*) * \brief Gamepad sensor event structure (event.gsensor.*)
*/ */
typedef struct SDL_GamepadSensorEvent typedef struct SDL_GamepadSensorEvent
{ {
@ -602,11 +602,11 @@ typedef union SDL_Event
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */ SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
SDL_GamepadAxisEvent caxis; /**< Gamepad axis event data */ SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */
SDL_GamepadButtonEvent cbutton; /**< Gamepad button event data */ SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */
SDL_GamepadDeviceEvent cdevice; /**< Gamepad device event data */ SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */
SDL_GamepadTouchpadEvent ctouchpad; /**< Gamepad touchpad event data */ SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */
SDL_GamepadSensorEvent csensor; /**< Gamepad sensor event data */ SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */
SDL_AudioDeviceEvent adevice; /**< Audio device event data */ SDL_AudioDeviceEvent adevice; /**< Audio device event data */
SDL_SensorEvent sensor; /**< Sensor event data */ SDL_SensorEvent sensor; /**< Sensor event data */
SDL_QuitEvent quit; /**< Quit request event data */ SDL_QuitEvent quit; /**< Quit request event data */

View File

@ -346,14 +346,14 @@ static void SDL_LogEvent(const SDL_Event *event)
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_AXIS_MOTION) SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_AXIS_MOTION)
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)", (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
(uint)event->caxis.timestamp, (int)event->caxis.which, (uint)event->gaxis.timestamp, (int)event->gaxis.which,
(uint)event->caxis.axis, (int)event->caxis.value); (uint)event->gaxis.axis, (int)event->gaxis.value);
break; break;
#define PRINT_CBUTTON_EVENT(event) \ #define PRINT_CBUTTON_EVENT(event) \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
(uint)event->cbutton.timestamp, (int)event->cbutton.which, \ (uint)event->gbutton.timestamp, (int)event->gbutton.which, \
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") (uint)event->gbutton.button, event->gbutton.state == SDL_PRESSED ? "pressed" : "released")
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_BUTTON_DOWN) SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_BUTTON_DOWN)
PRINT_CBUTTON_EVENT(event); PRINT_CBUTTON_EVENT(event);
break; break;
@ -362,7 +362,7 @@ static void SDL_LogEvent(const SDL_Event *event)
break; break;
#undef PRINT_CBUTTON_EVENT #undef PRINT_CBUTTON_EVENT
#define PRINT_GAMEPADDEV_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->cdevice.timestamp, (int)event->cdevice.which) #define PRINT_GAMEPADDEV_EVENT(event) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d)", (uint)event->gdevice.timestamp, (int)event->gdevice.which)
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_ADDED) SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_ADDED)
PRINT_GAMEPADDEV_EVENT(event); PRINT_GAMEPADDEV_EVENT(event);
break; break;
@ -376,9 +376,9 @@ static void SDL_LogEvent(const SDL_Event *event)
#define PRINT_CTOUCHPAD_EVENT(event) \ #define PRINT_CTOUCHPAD_EVENT(event) \
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d touchpad=%d finger=%d x=%f y=%f pressure=%f)", \
(uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \ (uint)event->gtouchpad.timestamp, (int)event->gtouchpad.which, \
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \ (int)event->gtouchpad.touchpad, (int)event->gtouchpad.finger, \
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure) event->gtouchpad.x, event->gtouchpad.y, event->gtouchpad.pressure)
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN) SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN)
PRINT_CTOUCHPAD_EVENT(event); PRINT_CTOUCHPAD_EVENT(event);
break; break;
@ -392,8 +392,8 @@ static void SDL_LogEvent(const SDL_Event *event)
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_SENSOR_UPDATE) SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_SENSOR_UPDATE)
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)", (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d sensor=%d data[0]=%f data[1]=%f data[2]=%f)",
(uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor, (uint)event->gsensor.timestamp, (int)event->gsensor.which, (int)event->gsensor.sensor,
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]); event->gsensor.data[0], event->gsensor.data[1], event->gsensor.data[2]);
break; break;
#define PRINT_FINGER_EVENT(event) \ #define PRINT_FINGER_EVENT(event) \

View File

@ -419,7 +419,7 @@ static int SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
deviceevent.type = SDL_EVENT_GAMEPAD_ADDED; deviceevent.type = SDL_EVENT_GAMEPAD_ADDED;
deviceevent.common.timestamp = 0; deviceevent.common.timestamp = 0;
deviceevent.cdevice.which = event->jdevice.which; deviceevent.gdevice.which = event->jdevice.which;
SDL_PushEvent(&deviceevent); SDL_PushEvent(&deviceevent);
} }
} break; } break;
@ -440,7 +440,7 @@ static int SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
deviceevent.type = SDL_EVENT_GAMEPAD_REMOVED; deviceevent.type = SDL_EVENT_GAMEPAD_REMOVED;
deviceevent.common.timestamp = 0; deviceevent.common.timestamp = 0;
deviceevent.cdevice.which = event->jdevice.which; deviceevent.gdevice.which = event->jdevice.which;
SDL_PushEvent(&deviceevent); SDL_PushEvent(&deviceevent);
} }
} break; } break;
@ -1214,7 +1214,7 @@ static void SDL_PrivateRefreshGamepadMapping(GamepadMapping_t *pGamepadMapping)
event.type = SDL_EVENT_GAMEPAD_REMAPPED; event.type = SDL_EVENT_GAMEPAD_REMAPPED;
event.common.timestamp = 0; event.common.timestamp = 0;
event.cdevice.which = gamepad->joystick->instance_id; event.gdevice.which = gamepad->joystick->instance_id;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
} }
@ -1901,7 +1901,7 @@ int SDL_InitGamepads(void)
SDL_Event deviceevent; SDL_Event deviceevent;
deviceevent.type = SDL_EVENT_GAMEPAD_ADDED; deviceevent.type = SDL_EVENT_GAMEPAD_ADDED;
deviceevent.common.timestamp = 0; deviceevent.common.timestamp = 0;
deviceevent.cdevice.which = joysticks[i]; deviceevent.gdevice.which = joysticks[i];
SDL_PushEvent(&deviceevent); SDL_PushEvent(&deviceevent);
} }
} }
@ -3060,9 +3060,9 @@ static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gamep
SDL_Event event; SDL_Event event;
event.type = SDL_EVENT_GAMEPAD_AXIS_MOTION; event.type = SDL_EVENT_GAMEPAD_AXIS_MOTION;
event.common.timestamp = timestamp; event.common.timestamp = timestamp;
event.caxis.which = gamepad->joystick->instance_id; event.gaxis.which = gamepad->joystick->instance_id;
event.caxis.axis = axis; event.gaxis.axis = axis;
event.caxis.value = value; event.gaxis.value = value;
posted = SDL_PushEvent(&event) == 1; posted = SDL_PushEvent(&event) == 1;
} }
#endif /* !SDL_EVENTS_DISABLED */ #endif /* !SDL_EVENTS_DISABLED */
@ -3120,9 +3120,9 @@ static int SDL_SendGamepadButton(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gam
#if !SDL_EVENTS_DISABLED #if !SDL_EVENTS_DISABLED
if (SDL_EventEnabled(event.type)) { if (SDL_EventEnabled(event.type)) {
event.common.timestamp = timestamp; event.common.timestamp = timestamp;
event.cbutton.which = gamepad->joystick->instance_id; event.gbutton.which = gamepad->joystick->instance_id;
event.cbutton.button = button; event.gbutton.button = button;
event.cbutton.state = state; event.gbutton.state = state;
posted = SDL_PushEvent(&event) == 1; posted = SDL_PushEvent(&event) == 1;
} }
#endif /* !SDL_EVENTS_DISABLED */ #endif /* !SDL_EVENTS_DISABLED */

View File

@ -2959,12 +2959,12 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch
SDL_Event event; SDL_Event event;
event.type = event_type; event.type = event_type;
event.common.timestamp = timestamp; event.common.timestamp = timestamp;
event.ctouchpad.which = joystick->instance_id; event.gtouchpad.which = joystick->instance_id;
event.ctouchpad.touchpad = touchpad; event.gtouchpad.touchpad = touchpad;
event.ctouchpad.finger = finger; event.gtouchpad.finger = finger;
event.ctouchpad.x = x; event.gtouchpad.x = x;
event.ctouchpad.y = y; event.gtouchpad.y = y;
event.ctouchpad.pressure = pressure; event.gtouchpad.pressure = pressure;
posted = SDL_PushEvent(&event) == 1; posted = SDL_PushEvent(&event) == 1;
} }
#endif /* !SDL_EVENTS_DISABLED */ #endif /* !SDL_EVENTS_DISABLED */
@ -2999,12 +2999,15 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT
SDL_Event event; SDL_Event event;
event.type = SDL_EVENT_GAMEPAD_SENSOR_UPDATE; event.type = SDL_EVENT_GAMEPAD_SENSOR_UPDATE;
event.common.timestamp = timestamp; event.common.timestamp = timestamp;
event.csensor.which = joystick->instance_id; event.gsensor.which = joystick->instance_id;
event.csensor.sensor = type; event.gsensor.sensor = type;
num_values = SDL_min(num_values, SDL_arraysize(event.csensor.data)); num_values = SDL_min(num_values,
SDL_memset(event.csensor.data, 0, sizeof(event.csensor.data)); SDL_arraysize(event.gsensor.data));
SDL_memcpy(event.csensor.data, data, num_values * sizeof(*data)); SDL_memset(event.gsensor.data, 0,
event.csensor.sensor_timestamp = sensor_timestamp; sizeof(event.gsensor.data));
SDL_memcpy(event.gsensor.data, data,
num_values * sizeof(*data));
event.gsensor.sensor_timestamp = sensor_timestamp;
posted = SDL_PushEvent(&event) == 1; posted = SDL_PushEvent(&event) == 1;
} }
#endif /* !SDL_EVENTS_DISABLED */ #endif /* !SDL_EVENTS_DISABLED */

View File

@ -1681,28 +1681,28 @@ static void SDLTest_PrintEvent(SDL_Event *event)
break; break;
case SDL_EVENT_GAMEPAD_ADDED: case SDL_EVENT_GAMEPAD_ADDED:
SDL_Log("SDL EVENT: Gamepad index %" SDL_PRIu32 " attached", SDL_Log("SDL EVENT: Gamepad index %" SDL_PRIu32 " attached",
event->cdevice.which); event->gdevice.which);
break; break;
case SDL_EVENT_GAMEPAD_REMOVED: case SDL_EVENT_GAMEPAD_REMOVED:
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " removed", SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " removed",
event->cdevice.which); event->gdevice.which);
break; break;
case SDL_EVENT_GAMEPAD_AXIS_MOTION: case SDL_EVENT_GAMEPAD_AXIS_MOTION:
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " axis %d ('%s') value: %d", SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " axis %d ('%s') value: %d",
event->caxis.which, event->gaxis.which,
event->caxis.axis, event->gaxis.axis,
GamepadAxisName((SDL_GamepadAxis)event->caxis.axis), GamepadAxisName((SDL_GamepadAxis)event->gaxis.axis),
event->caxis.value); event->gaxis.value);
break; break;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 "button %d ('%s') down", SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 "button %d ('%s') down",
event->cbutton.which, event->cbutton.button, event->gbutton.which, event->gbutton.button,
GamepadButtonName((SDL_GamepadButton)event->cbutton.button)); GamepadButtonName((SDL_GamepadButton)event->gbutton.button));
break; break;
case SDL_EVENT_GAMEPAD_BUTTON_UP: case SDL_EVENT_GAMEPAD_BUTTON_UP:
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " button %d ('%s') up", SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " button %d ('%s') up",
event->cbutton.which, event->cbutton.button, event->gbutton.which, event->gbutton.button,
GamepadButtonName((SDL_GamepadButton)event->cbutton.button)); GamepadButtonName((SDL_GamepadButton)event->gbutton.button));
break; break;
case SDL_EVENT_CLIPBOARD_UPDATE: case SDL_EVENT_CLIPBOARD_UPDATE:
SDL_Log("SDL EVENT: Clipboard updated"); SDL_Log("SDL EVENT: Clipboard updated");

View File

@ -629,61 +629,69 @@ void loop(void *arg)
break; break;
case SDL_EVENT_GAMEPAD_ADDED: case SDL_EVENT_GAMEPAD_ADDED:
SDL_Log("Gamepad device %" SDL_PRIu32 " added.\n", event.cdevice.which); SDL_Log("Gamepad device %" SDL_PRIu32 " added.\n",
AddGamepad(event.cdevice.which, SDL_TRUE); event.gdevice.which);
AddGamepad(event.gdevice.which, SDL_TRUE);
break; break;
case SDL_EVENT_GAMEPAD_REMOVED: case SDL_EVENT_GAMEPAD_REMOVED:
SDL_Log("Gamepad device %" SDL_PRIu32 " removed.\n", event.cdevice.which); SDL_Log("Gamepad device %" SDL_PRIu32 " removed.\n",
DelGamepad(event.cdevice.which); event.gdevice.which);
DelGamepad(event.gdevice.which);
break; break;
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP: case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
SDL_Log("Gamepad %" SDL_PRIu32 " touchpad %" SDL_PRIs32 " finger %" SDL_PRIs32 " %s %.2f, %.2f, %.2f\n", SDL_Log("Gamepad %" SDL_PRIu32 " touchpad %" SDL_PRIs32 " finger %" SDL_PRIs32 " %s %.2f, %.2f, %.2f\n",
event.ctouchpad.which, event.gtouchpad.which,
event.ctouchpad.touchpad, event.gtouchpad.touchpad,
event.ctouchpad.finger, event.gtouchpad.finger,
(event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN ? "pressed at" : (event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_UP ? "released at" : "moved to")), (event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN ? "pressed at" : (event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_UP ? "released at" : "moved to")),
event.ctouchpad.x, event.gtouchpad.x,
event.ctouchpad.y, event.gtouchpad.y,
event.ctouchpad.pressure); event.gtouchpad.pressure);
break; break;
#define VERBOSE_SENSORS #define VERBOSE_SENSORS
#ifdef VERBOSE_SENSORS #ifdef VERBOSE_SENSORS
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
SDL_Log("Gamepad %" SDL_PRIu32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")\n", SDL_Log("Gamepad %" SDL_PRIu32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")\n",
event.csensor.which, event.gsensor.which,
GetSensorName((SDL_SensorType)event.csensor.sensor), GetSensorName((SDL_SensorType) event.gsensor.sensor),
event.csensor.data[0], event.gsensor.data[0],
event.csensor.data[1], event.gsensor.data[1],
event.csensor.data[2], event.gsensor.data[2],
event.csensor.sensor_timestamp); event.gsensor.sensor_timestamp);
break; break;
#endif /* VERBOSE_SENSORS */ #endif /* VERBOSE_SENSORS */
#define VERBOSE_AXES #define VERBOSE_AXES
#ifdef VERBOSE_AXES #ifdef VERBOSE_AXES
case SDL_EVENT_GAMEPAD_AXIS_MOTION: case SDL_EVENT_GAMEPAD_AXIS_MOTION:
if (event.caxis.value <= (-SDL_JOYSTICK_AXIS_MAX / 2) || event.caxis.value >= (SDL_JOYSTICK_AXIS_MAX / 2)) { if (event.gaxis.value <= (-SDL_JOYSTICK_AXIS_MAX / 2) || event.gaxis.value >= (SDL_JOYSTICK_AXIS_MAX / 2)) {
SetGamepad(event.caxis.which); SetGamepad(event.gaxis.which);
} }
SDL_Log("Gamepad %" SDL_PRIu32 " axis %s changed to %d\n", event.caxis.which, SDL_GetGamepadStringForAxis((SDL_GamepadAxis)event.caxis.axis), event.caxis.value); SDL_Log("Gamepad %" SDL_PRIu32 " axis %s changed to %d\n",
event.gaxis.which,
SDL_GetGamepadStringForAxis((SDL_GamepadAxis) event.gaxis.axis),
event.gaxis.value);
break; break;
#endif /* VERBOSE_AXES */ #endif /* VERBOSE_AXES */
case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
case SDL_EVENT_GAMEPAD_BUTTON_UP: case SDL_EVENT_GAMEPAD_BUTTON_UP:
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) { if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
SetGamepad(event.cbutton.which); SetGamepad(event.gbutton.which);
} }
SDL_Log("Gamepad %" SDL_PRIu32 " button %s %s\n", event.cbutton.which, SDL_GetGamepadStringForButton((SDL_GamepadButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); SDL_Log("Gamepad %" SDL_PRIu32 " button %s %s\n",
event.gbutton.which,
SDL_GetGamepadStringForButton((SDL_GamepadButton) event.gbutton.button),
event.gbutton.state ? "pressed" : "released");
/* Cycle PS5 trigger effects when the microphone button is pressed */ /* Cycle PS5 trigger effects when the microphone button is pressed */
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN && if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
event.cbutton.button == SDL_GAMEPAD_BUTTON_MISC1 && event.gbutton.button == SDL_GAMEPAD_BUTTON_MISC1 &&
SDL_GetGamepadType(gamepad) == SDL_GAMEPAD_TYPE_PS5) { SDL_GetGamepadType(gamepad) == SDL_GAMEPAD_TYPE_PS5) {
CyclePS5TriggerEffect(); CyclePS5TriggerEffect();
} }