mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-24 21:11:08 +00:00
Fixed centering the D-pad on some joysticks
Fixes https://github.com/libsdl-org/SDL/issues/6767
This commit is contained in:
parent
bcccbbd894
commit
d1b4810542
|
@ -1454,6 +1454,7 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
||||||
for (i = 0; i < nhats; ++i) {
|
for (i = 0; i < nhats; ++i) {
|
||||||
HIDP_DATA *item = GetData(ctx->hat_indices[i], ctx->data, data_length);
|
HIDP_DATA *item = GetData(ctx->hat_indices[i], ctx->data, data_length);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
Uint8 hat = SDL_HAT_CENTERED;
|
||||||
const Uint8 hat_states[] = {
|
const Uint8 hat_states[] = {
|
||||||
SDL_HAT_CENTERED,
|
SDL_HAT_CENTERED,
|
||||||
SDL_HAT_UP,
|
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_DOWN | SDL_HAT_LEFT,
|
||||||
SDL_HAT_LEFT,
|
SDL_HAT_LEFT,
|
||||||
SDL_HAT_UP | SDL_HAT_LEFT,
|
SDL_HAT_UP | SDL_HAT_LEFT,
|
||||||
|
SDL_HAT_CENTERED,
|
||||||
};
|
};
|
||||||
ULONG state = item->RawValue;
|
ULONG state = item->RawValue;
|
||||||
|
|
||||||
|
@ -1471,8 +1473,9 @@ static void RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int
|
||||||
#ifdef SDL_JOYSTICK_RAWINPUT_MATCHING
|
#ifdef SDL_JOYSTICK_RAWINPUT_MATCHING
|
||||||
match_state = (match_state & ~HAT_MASK) | hat_map[state];
|
match_state = (match_state & ~HAT_MASK) | hat_map[state];
|
||||||
#endif
|
#endif
|
||||||
SDL_PrivateJoystickHat(joystick, i, hat_states[state]);
|
hat = hat_states[state];
|
||||||
}
|
}
|
||||||
|
SDL_PrivateJoystickHat(joystick, i, hat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue