mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-20 08:41:45 +00:00
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:
@@ -346,14 +346,14 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
|
||||
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_AXIS_MOTION)
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d axis=%u value=%d)",
|
||||
(uint)event->caxis.timestamp, (int)event->caxis.which,
|
||||
(uint)event->caxis.axis, (int)event->caxis.value);
|
||||
(uint)event->gaxis.timestamp, (int)event->gaxis.which,
|
||||
(uint)event->gaxis.axis, (int)event->gaxis.value);
|
||||
break;
|
||||
|
||||
#define PRINT_CBUTTON_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%d button=%u state=%s)", \
|
||||
(uint)event->cbutton.timestamp, (int)event->cbutton.which, \
|
||||
(uint)event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
(uint)event->gbutton.timestamp, (int)event->gbutton.which, \
|
||||
(uint)event->gbutton.button, event->gbutton.state == SDL_PRESSED ? "pressed" : "released")
|
||||
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_BUTTON_DOWN)
|
||||
PRINT_CBUTTON_EVENT(event);
|
||||
break;
|
||||
@@ -362,7 +362,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
break;
|
||||
#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)
|
||||
PRINT_GAMEPADDEV_EVENT(event);
|
||||
break;
|
||||
@@ -376,9 +376,9 @@ static void SDL_LogEvent(const SDL_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)", \
|
||||
(uint)event->ctouchpad.timestamp, (int)event->ctouchpad.which, \
|
||||
(int)event->ctouchpad.touchpad, (int)event->ctouchpad.finger, \
|
||||
event->ctouchpad.x, event->ctouchpad.y, event->ctouchpad.pressure)
|
||||
(uint)event->gtouchpad.timestamp, (int)event->gtouchpad.which, \
|
||||
(int)event->gtouchpad.touchpad, (int)event->gtouchpad.finger, \
|
||||
event->gtouchpad.x, event->gtouchpad.y, event->gtouchpad.pressure)
|
||||
SDL_EVENT_CASE(SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN)
|
||||
PRINT_CTOUCHPAD_EVENT(event);
|
||||
break;
|
||||
@@ -392,8 +392,8 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
|
||||
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)",
|
||||
(uint)event->csensor.timestamp, (int)event->csensor.which, (int)event->csensor.sensor,
|
||||
event->csensor.data[0], event->csensor.data[1], event->csensor.data[2]);
|
||||
(uint)event->gsensor.timestamp, (int)event->gsensor.which, (int)event->gsensor.sensor,
|
||||
event->gsensor.data[0], event->gsensor.data[1], event->gsensor.data[2]);
|
||||
break;
|
||||
|
||||
#define PRINT_FINGER_EVENT(event) \
|
||||
|
@@ -419,7 +419,7 @@ static int SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
|
||||
|
||||
deviceevent.type = SDL_EVENT_GAMEPAD_ADDED;
|
||||
deviceevent.common.timestamp = 0;
|
||||
deviceevent.cdevice.which = event->jdevice.which;
|
||||
deviceevent.gdevice.which = event->jdevice.which;
|
||||
SDL_PushEvent(&deviceevent);
|
||||
}
|
||||
} break;
|
||||
@@ -440,7 +440,7 @@ static int SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
|
||||
|
||||
deviceevent.type = SDL_EVENT_GAMEPAD_REMOVED;
|
||||
deviceevent.common.timestamp = 0;
|
||||
deviceevent.cdevice.which = event->jdevice.which;
|
||||
deviceevent.gdevice.which = event->jdevice.which;
|
||||
SDL_PushEvent(&deviceevent);
|
||||
}
|
||||
} break;
|
||||
@@ -1214,7 +1214,7 @@ static void SDL_PrivateRefreshGamepadMapping(GamepadMapping_t *pGamepadMapping)
|
||||
|
||||
event.type = SDL_EVENT_GAMEPAD_REMAPPED;
|
||||
event.common.timestamp = 0;
|
||||
event.cdevice.which = gamepad->joystick->instance_id;
|
||||
event.gdevice.which = gamepad->joystick->instance_id;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
}
|
||||
@@ -1901,7 +1901,7 @@ int SDL_InitGamepads(void)
|
||||
SDL_Event deviceevent;
|
||||
deviceevent.type = SDL_EVENT_GAMEPAD_ADDED;
|
||||
deviceevent.common.timestamp = 0;
|
||||
deviceevent.cdevice.which = joysticks[i];
|
||||
deviceevent.gdevice.which = joysticks[i];
|
||||
SDL_PushEvent(&deviceevent);
|
||||
}
|
||||
}
|
||||
@@ -3060,9 +3060,9 @@ static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_Gamep
|
||||
SDL_Event event;
|
||||
event.type = SDL_EVENT_GAMEPAD_AXIS_MOTION;
|
||||
event.common.timestamp = timestamp;
|
||||
event.caxis.which = gamepad->joystick->instance_id;
|
||||
event.caxis.axis = axis;
|
||||
event.caxis.value = value;
|
||||
event.gaxis.which = gamepad->joystick->instance_id;
|
||||
event.gaxis.axis = axis;
|
||||
event.gaxis.value = value;
|
||||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
#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_EventEnabled(event.type)) {
|
||||
event.common.timestamp = timestamp;
|
||||
event.cbutton.which = gamepad->joystick->instance_id;
|
||||
event.cbutton.button = button;
|
||||
event.cbutton.state = state;
|
||||
event.gbutton.which = gamepad->joystick->instance_id;
|
||||
event.gbutton.button = button;
|
||||
event.gbutton.state = state;
|
||||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
|
@@ -2959,12 +2959,12 @@ int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touch
|
||||
SDL_Event event;
|
||||
event.type = event_type;
|
||||
event.common.timestamp = timestamp;
|
||||
event.ctouchpad.which = joystick->instance_id;
|
||||
event.ctouchpad.touchpad = touchpad;
|
||||
event.ctouchpad.finger = finger;
|
||||
event.ctouchpad.x = x;
|
||||
event.ctouchpad.y = y;
|
||||
event.ctouchpad.pressure = pressure;
|
||||
event.gtouchpad.which = joystick->instance_id;
|
||||
event.gtouchpad.touchpad = touchpad;
|
||||
event.gtouchpad.finger = finger;
|
||||
event.gtouchpad.x = x;
|
||||
event.gtouchpad.y = y;
|
||||
event.gtouchpad.pressure = pressure;
|
||||
posted = SDL_PushEvent(&event) == 1;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
@@ -2999,12 +2999,15 @@ int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorT
|
||||
SDL_Event event;
|
||||
event.type = SDL_EVENT_GAMEPAD_SENSOR_UPDATE;
|
||||
event.common.timestamp = timestamp;
|
||||
event.csensor.which = joystick->instance_id;
|
||||
event.csensor.sensor = type;
|
||||
num_values = SDL_min(num_values, SDL_arraysize(event.csensor.data));
|
||||
SDL_memset(event.csensor.data, 0, sizeof(event.csensor.data));
|
||||
SDL_memcpy(event.csensor.data, data, num_values * sizeof(*data));
|
||||
event.csensor.sensor_timestamp = sensor_timestamp;
|
||||
event.gsensor.which = joystick->instance_id;
|
||||
event.gsensor.sensor = type;
|
||||
num_values = SDL_min(num_values,
|
||||
SDL_arraysize(event.gsensor.data));
|
||||
SDL_memset(event.gsensor.data, 0,
|
||||
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;
|
||||
}
|
||||
#endif /* !SDL_EVENTS_DISABLED */
|
||||
|
@@ -1681,28 +1681,28 @@ static void SDLTest_PrintEvent(SDL_Event *event)
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
SDL_Log("SDL EVENT: Gamepad index %" SDL_PRIu32 " attached",
|
||||
event->cdevice.which);
|
||||
event->gdevice.which);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " removed",
|
||||
event->cdevice.which);
|
||||
event->gdevice.which);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " axis %d ('%s') value: %d",
|
||||
event->caxis.which,
|
||||
event->caxis.axis,
|
||||
GamepadAxisName((SDL_GamepadAxis)event->caxis.axis),
|
||||
event->caxis.value);
|
||||
event->gaxis.which,
|
||||
event->gaxis.axis,
|
||||
GamepadAxisName((SDL_GamepadAxis)event->gaxis.axis),
|
||||
event->gaxis.value);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 "button %d ('%s') down",
|
||||
event->cbutton.which, event->cbutton.button,
|
||||
GamepadButtonName((SDL_GamepadButton)event->cbutton.button));
|
||||
event->gbutton.which, event->gbutton.button,
|
||||
GamepadButtonName((SDL_GamepadButton)event->gbutton.button));
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
SDL_Log("SDL EVENT: Gamepad %" SDL_PRIu32 " button %d ('%s') up",
|
||||
event->cbutton.which, event->cbutton.button,
|
||||
GamepadButtonName((SDL_GamepadButton)event->cbutton.button));
|
||||
event->gbutton.which, event->gbutton.button,
|
||||
GamepadButtonName((SDL_GamepadButton)event->gbutton.button));
|
||||
break;
|
||||
case SDL_EVENT_CLIPBOARD_UPDATE:
|
||||
SDL_Log("SDL EVENT: Clipboard updated");
|
||||
|
Reference in New Issue
Block a user