mirror of https://github.com/encounter/SDL.git
Fixed centering the D-pad on some joysticks
Fixes https://github.com/libsdl-org/SDL/issues/6767 (cherry picked from commit d1b4810542183a415e42b11b516bf8d5b0a6d58c)
This commit is contained in:
parent
05b03032f1
commit
ce67788629
|
@ -1473,6 +1473,7 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size)
|
|||
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,
|
||||
|
@ -1483,6 +1484,7 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size)
|
|||
SDL_HAT_DOWN | SDL_HAT_LEFT,
|
||||
SDL_HAT_LEFT,
|
||||
SDL_HAT_UP | SDL_HAT_LEFT,
|
||||
SDL_HAT_CENTERED,
|
||||
};
|
||||
ULONG state = item->RawValue;
|
||||
|
||||
|
@ -1490,8 +1492,9 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size)
|
|||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue