From ad52ebf985bdeec339f3bc46cbdc7dc43b5f3062 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Jul 2025 20:56:41 -0700
Subject: [PATCH] Fixed build
---
src/joystick/hidapi/SDL_hidapi_sinput.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_sinput.c b/src/joystick/hidapi/SDL_hidapi_sinput.c
index 6a616821e69fd..bc4aa79845e26 100644
--- a/src/joystick/hidapi/SDL_hidapi_sinput.c
+++ b/src/joystick/hidapi/SDL_hidapi_sinput.c
@@ -295,10 +295,10 @@ static void ProcessSDLFeaturesResponse(SDL_HIDAPI_Device *device, Uint8 *data)
}
// Convert DPAD to hat
- const DPAD_MASK = (1 << SINPUT_BUTTON_IDX_DPAD_UP) |
- (1 << SINPUT_BUTTON_IDX_DPAD_DOWN) |
- (1 << SINPUT_BUTTON_IDX_DPAD_LEFT) |
- (1 << SINPUT_BUTTON_IDX_DPAD_RIGHT);
+ const int DPAD_MASK = (1 << SINPUT_BUTTON_IDX_DPAD_UP) |
+ (1 << SINPUT_BUTTON_IDX_DPAD_DOWN) |
+ (1 << SINPUT_BUTTON_IDX_DPAD_LEFT) |
+ (1 << SINPUT_BUTTON_IDX_DPAD_RIGHT);
if ((ctx->usage_masks[0] & DPAD_MASK) == DPAD_MASK) {
ctx->dpad_supported = true;
ctx->usage_masks[0] &= ~DPAD_MASK;
@@ -711,7 +711,7 @@ static void HIDAPI_DriverSInput_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
if (ctx->last_state[SINPUT_REPORT_IDX_PLUG_STATUS] != data[SINPUT_REPORT_IDX_PLUG_STATUS] ||
ctx->last_state[SINPUT_REPORT_IDX_CHARGE_LEVEL] != data[SINPUT_REPORT_IDX_CHARGE_LEVEL]) {
- SDL_PowerState state = SDL_POWERSTATE_NO_BATTERY;
+ SDL_PowerState state = SDL_POWERSTATE_UNKNOWN;
Uint8 status = data[SINPUT_REPORT_IDX_PLUG_STATUS];
int percent = data[SINPUT_REPORT_IDX_CHARGE_LEVEL];
@@ -732,13 +732,11 @@ static void HIDAPI_DriverSInput_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
case 4:
state = SDL_POWERSTATE_ON_BATTERY;
break;
- default: // Wired/No Battery Supported
- state = SDL_POWERSTATE_UNKNOWN;
- percent = 0;
+ default:
break;
}
- if (state > 0) {
+ if (state != SDL_POWERSTATE_UNKNOWN) {
SDL_SendJoystickPowerInfo(joystick, state, percent);
}
}