Fixed centering the D-pad on some joysticks Fixes https://github.com/libsdl-org/SDL/issues/6767
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 8421ef4..d50823f 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -1454,6 +1454,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
for (i = 0; i < nhats; ++i) {
HIDP_DATA *item = GetData(ctx->hat_indices[i], ctx->data, data_length);
if (item) {
+ Uint8 hat = SDL_HAT_CENTERED;
const Uint8 hat_states[] = {
SDL_HAT_CENTERED,
SDL_HAT_UP,
@@ -1464,6 +1465,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
SDL_HAT_DOWN | SDL_HAT_LEFT,
SDL_HAT_LEFT,
SDL_HAT_UP | SDL_HAT_LEFT,
+ SDL_HAT_CENTERED,
};
ULONG state = item->RawValue;
@@ -1471,8 +1473,9 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
#ifdef SDL_JOYSTICK_RAWINPUT_MATCHING
match_state = (match_state & ~HAT_MASK) | hat_map[state];
#endif
- SDL_PrivateJoystickHat(joystick, i, hat_states[state]);
+ hat = hat_states[state];
}
+ SDL_PrivateJoystickHat(joystick, i, hat);
}
}