From 3d8420e39290d4bcbb2331ddd08cead66b40f63e Mon Sep 17 00:00:00 2001 From: lightmanLP <50497969+lightmanLP@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:55:22 +0700 Subject: [PATCH] fix buffed mapping (#767) --- .../controldevice/controller/ControllerButton.cpp | 8 ++++++-- .../controldevice/controller/ControllerStick.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/controller/controldevice/controller/ControllerButton.cpp b/src/controller/controldevice/controller/ControllerButton.cpp index 483e2a9dd..7fc139874 100644 --- a/src/controller/controldevice/controller/ControllerButton.cpp +++ b/src/controller/controldevice/controller/ControllerButton.cpp @@ -207,8 +207,12 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi bool ControllerButton::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) { if (mUseKeydownEventToCreateNewMapping && eventType == LUS_KB_EVENT_KEY_DOWN) { - mKeyboardScancodeForNewMapping = scancode; - return true; + if (eventType == LUS_KB_EVENT_KEY_DOWN) { + mKeyboardScancodeForNewMapping = scancode; + return true; + } else { + mKeyboardScancodeForNewMapping = LUS_KB_UNKNOWN; + } } bool result = false; diff --git a/src/controller/controldevice/controller/ControllerStick.cpp b/src/controller/controldevice/controller/ControllerStick.cpp index 655b66859..8aa11def6 100644 --- a/src/controller/controldevice/controller/ControllerStick.cpp +++ b/src/controller/controldevice/controller/ControllerStick.cpp @@ -319,9 +319,13 @@ void ControllerStick::UpdatePad(int8_t& x, int8_t& y) { } bool ControllerStick::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) { - if (mUseKeydownEventToCreateNewMapping && eventType == LUS_KB_EVENT_KEY_DOWN) { - mKeyboardScancodeForNewMapping = scancode; - return true; + if (mUseKeydownEventToCreateNewMapping) { + if (eventType == LUS_KB_EVENT_KEY_DOWN) { + mKeyboardScancodeForNewMapping = scancode; + return true; + } else { + mKeyboardScancodeForNewMapping = LUS_KB_UNKNOWN; + } } bool result = false;