From cfdd8a614abc6f5c5647886553a8acdc8b20915a Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 11 Aug 2020 19:38:36 +1000 Subject: [PATCH] TLAC: ps4 slider support: try to fix issues --- .../TLAC/Components/Input/TouchSliderEmulator.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp index b6f4f73..24865a9 100644 --- a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp +++ b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp @@ -100,10 +100,12 @@ namespace TLAC::Components //Joystick rs = Joystick((float)(0b10000001) / 255 * 2.0f - 1.0f, (float)(0b11001100) / 255 * 2.0f - 1.0f); uint32_t state = 0; - state |= (uint8_t)((ls.XAxis + 1.0) * 127.5) ^ 0b10000000; - state |= ((uint8_t)((ls.YAxis + 1.0) * 127.5) ^ 0b10000000) << 8; - state |= ((uint8_t)((rs.XAxis + 1.0) * 127.5) ^ 0b10000000) << 16; - state |= ((uint8_t)((rs.YAxis + 1.0) * 127.5) ^ 0b10000000) << 24; + state |= (uint8_t)((ls.XAxis + 1.0 + 0.001) * 127.5) ^ 0b10000000; // 0.001 to hopefully fix zero-point (and maybe some rounding errors) + if (state == 0xffffffff) + printf("Joy neutral pos: %6.4f", ls.XAxis); + state |= ((uint8_t)((ls.YAxis + 1.0 + 0.001) * 127.5) ^ 0b10000000) << 8; + state |= ((uint8_t)((rs.XAxis + 1.0 + 0.001) * 127.5) ^ 0b10000000) << 16; + state |= ((uint8_t)((rs.YAxis + 1.0 + 0.001) * 127.5) ^ 0b10000000) << 24; ApplyBitfieldState(state); }