mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-04 19:55:19 +00:00
Fix DirectInput POV handling for devices with extra hats
This commit is contained in:
parent
8549aae829
commit
7341f04a12
1 changed files with 5 additions and 1 deletions
|
|
@ -646,6 +646,10 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj
|
||||||
in->ofs = DIJOFS_BUTTON(in->num);
|
in->ofs = DIJOFS_BUTTON(in->num);
|
||||||
joystick->nbuttons++;
|
joystick->nbuttons++;
|
||||||
} else if (pDeviceObject->dwType & DIDFT_POV) {
|
} else if (pDeviceObject->dwType & DIDFT_POV) {
|
||||||
|
// DIJOYSTATE2.rgdwPOV only has room for 4 POVs, ignore any beyond that.
|
||||||
|
if (joystick->nhats >= 4) {
|
||||||
|
return DIENUM_CONTINUE;
|
||||||
|
}
|
||||||
in->type = HAT;
|
in->type = HAT;
|
||||||
in->num = (Uint8)joystick->nhats;
|
in->num = (Uint8)joystick->nhats;
|
||||||
in->ofs = DIJOFS_POV(in->num);
|
in->ofs = DIJOFS_POV(in->num);
|
||||||
|
|
@ -1070,7 +1074,7 @@ static void UpdateDINPUTJoystickState_Polled(SDL_Joystick *joystick)
|
||||||
break;
|
break;
|
||||||
case HAT:
|
case HAT:
|
||||||
{
|
{
|
||||||
Uint8 pos = TranslatePOV(state.rgdwPOV[in->ofs - DIJOFS_POV(0)]);
|
Uint8 pos = TranslatePOV(state.rgdwPOV[in->num]);
|
||||||
SDL_SendJoystickHat(timestamp, joystick, in->num, pos);
|
SDL_SendJoystickHat(timestamp, joystick, in->num, pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue