Fix DirectInput POV handling for devices with extra hats
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled

This commit is contained in:
Zizin13
2026-06-04 12:23:33 -07:00
committed by Sam Lantinga
parent 8549aae829
commit 7341f04a12
+5 -1
View File
@@ -646,6 +646,10 @@ static BOOL CALLBACK EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObj
in->ofs = DIJOFS_BUTTON(in->num);
joystick->nbuttons++;
} 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->num = (Uint8)joystick->nhats;
in->ofs = DIJOFS_POV(in->num);
@@ -1070,7 +1074,7 @@ static void UpdateDINPUTJoystickState_Polled(SDL_Joystick *joystick)
break;
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);
break;
}