Skip to content

Commit

Permalink
Merge pull request #679 from doczi-dominik/master
Browse files Browse the repository at this point in the history
DirectInput POV Hat Handling for Windows Backend
  • Loading branch information
RobDangerous authored Jan 28, 2022
2 parents 3f7cd28 + 8854e0f commit e69a590
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Backends/System/Windows/Sources/kinc/backend/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,20 @@ bool handleDirectInputPad(int padIndex) {
}
}

for (int povIndex = 0; povIndex < 4; ++povIndex) {
DWORD *now = &di_padState[padIndex].rgdwPOV[povIndex];
DWORD *last = &di_lastPadState[padIndex].rgdwPOV[povIndex];

if (*now != *last) {
// Maybe this could use fewer conditionals with some clever math
// cardinal press || cardinal + counter-clockwise || cardinal + clockwise
kinc_internal_gamepad_trigger_button(padIndex, 12, (*now == 0 || *now == 31500 || *now == 4500));
kinc_internal_gamepad_trigger_button(padIndex, 13, (*now == 18000 || *now == 13500 || *now == 22500));
kinc_internal_gamepad_trigger_button(padIndex, 14, (*now == 27000 || *now == 22500 || *now == 31500));
kinc_internal_gamepad_trigger_button(padIndex, 15, (*now == 9000 || *now == 4500 || *now == 13500));
}
}

kinc_memcpy(&di_lastPadState[padIndex], &di_padState[padIndex], sizeof(DIJOYSTATE2));
break;
}
Expand Down

0 comments on commit e69a590

Please sign in to comment.