Skip to content

Commit

Permalink
SDL input filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 8, 2023
1 parent 89c320f commit 566d9f6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Windows/DinputDevice.cpp
Expand Up @@ -204,12 +204,13 @@ DinputDevice::~DinputDevice() {
}

void SendNativeAxis(InputDeviceID deviceId, int value, int &lastValue, InputAxis axisId) {
AxisInput axis;
axis.deviceId = deviceId;
axis.axisId = axisId;
axis.value = (float)value * (1.0f / 10000.0f); // Convert axis to normalised float
NativeAxis(&axis, 1);

if (value != lastValue) {
AxisInput axis;
axis.deviceId = deviceId;
axis.axisId = axisId;
axis.value = (float)value * (1.0f / 10000.0f); // Convert axis to normalised float
NativeAxis(&axis, 1);
}
lastValue = value;
}

Expand Down Expand Up @@ -286,7 +287,7 @@ void DinputDevice::ApplyButtons(DIJOYSTATE2 &state) {

// Now the POV hat, which can technically go in any degree but usually does not.
if (LOWORD(state.rgdwPOV[0]) != lastPOV_[0]) {
KeyInput dpad[4];
KeyInput dpad[4]{};
for (int i = 0; i < 4; ++i) {
dpad[i].deviceId = DEVICE_ID_PAD_0 + pDevNum;
dpad[i].flags = KEY_UP;
Expand Down

0 comments on commit 566d9f6

Please sign in to comment.