From 737f0c42a45a6ef5fae8b8ca1caa6a2263f5a7c2 Mon Sep 17 00:00:00 2001 From: nastys Date: Sat, 26 Dec 2020 22:48:59 +0100 Subject: [PATCH] [TLAC] Fix crash when an Xinput is connected, the slider emulator is disabled, and rumble is enabled --- .../plugins/TLAC/Components/Input/TouchSliderEmulator.cpp | 2 ++ .../source/plugins/TLAC/Components/Input/TouchSliderEmulator.h | 2 ++ source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp index 4c7a47a..1e9a340 100644 --- a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp +++ b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.cpp @@ -47,6 +47,8 @@ namespace TLAC::Components componentsManager = manager; sliderState = (TouchSliderState*)SLIDER_CTRL_TASK_ADDRESS; + touchSliderEmulatorIsEnabled = true; + LeftSideSlideLeft = new Binding(); LeftSideSlideRight = new Binding(); diff --git a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.h b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.h index 126210d..abc437c 100644 --- a/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.h +++ b/source-code/source/plugins/TLAC/Components/Input/TouchSliderEmulator.h @@ -60,5 +60,7 @@ namespace TLAC::Components void ApplyContactPoint(ContactPoint &contactPoint, int section); void ApplyBitfieldState(uint32_t state); }; + + inline bool touchSliderEmulatorIsEnabled = false; } diff --git a/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp b/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp index 152d9ac..23c9164 100644 --- a/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp +++ b/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp @@ -252,7 +252,7 @@ namespace TLAC::Input SetTapStates(i, elapsed); } - if (rumble && TLAC::Components::TouchSliderEmulator::LatestInstance->isSliderTouched() && TLAC::Components::TargetInspector::ShouldVibrate) + if (rumble && TLAC::Components::touchSliderEmulatorIsEnabled && TLAC::Components::TouchSliderEmulator::LatestInstance->isSliderTouched() && TLAC::Components::TargetInspector::ShouldVibrate) { XINPUT_VIBRATION vibration; ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));