From 566d9f67f6dec4cd19f5f1a3a3aa6d606413dd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Nov 2023 14:38:34 +0100 Subject: [PATCH] SDL input filtering --- Windows/DinputDevice.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index 0581f522e3..8cfdbeb64b 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -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; } @@ -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;