Avoid potential overflow in gamepad sensor report rate period

This commit is contained in:
Cameron Gutman committed 2026-11-15 01:02:12 -06:00
1 parent 136610d5fd
commit dab3e23cc4
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -931,7 +931,7 @@ void SdlInputHandler::setMotionEventState(uint16_t controllerNumber, uint8_t mot
#if SDL_VERSION_ATLEAST(2, 0, 14)
if (m_GamepadState[controllerNumber].controller != nullptr) {
uint8_t reportPeriodMs = reportRateHz ? (1000 / reportRateHz) : 0;
uint32_t reportPeriodMs = reportRateHz ? SDL_max(1000U / reportRateHz, 1U) : 0;
switch (motionType) {
case LI_MOTION_TYPE_ACCEL:
+2 -2
View File
@@ -23,11 +23,11 @@ struct GamepadState {
bool emulatedClickpadButtonDown;
#if SDL_VERSION_ATLEAST(2, 0, 14)
uint8_t gyroReportPeriodMs;
uint16_t gyroReportPeriodMs;
float lastGyroEventData[SDL_arraysize(SDL_ControllerSensorEvent::data)];
uint32_t lastGyroEventTime;
uint8_t accelReportPeriodMs;
uint16_t accelReportPeriodMs;
float lastAccelEventData[SDL_arraysize(SDL_ControllerSensorEvent::data)];
uint32_t lastAccelEventTime;
#endif