From 1be56837aa1081ac1f3e578e5c8b026ce4a0febe Mon Sep 17 00:00:00 2001 From: kareltucek Date: Mon, 9 Nov 2020 00:11:14 +0100 Subject: [PATCH] Fix toggle mouse states --- right/src/mouse_controller.c | 11 ++++++++--- right/src/mouse_controller.h | 1 + right/src/usb_report_updater.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/right/src/mouse_controller.c b/right/src/mouse_controller.c index d23794397..56ce1790c 100644 --- a/right/src/mouse_controller.c +++ b/right/src/mouse_controller.c @@ -19,8 +19,7 @@ static uint32_t mouseUsbReportUpdateTime = 0; static uint32_t mouseElapsedTime; uint8_t ActiveMouseStates[ACTIVE_MOUSE_STATES_COUNT]; - -static bool toggledMouseStates[ACTIVE_MOUSE_STATES_COUNT]; +uint8_t ToggledMouseStates[ACTIVE_MOUSE_STATES_COUNT]; bool CompensateDiagonalSpeed = false; @@ -314,5 +313,11 @@ void MouseController_ProcessMouseActions() void ToggleMouseState(serialized_mouse_action_t action, bool activate) { - toggledMouseStates[action] = activate; + if (activate) { + ToggledMouseStates[action]++; + MouseController_ActivateDirectionSigns(action); + } + else{ + ToggledMouseStates[action] -= ToggledMouseStates[action] > 0 ? 1 : 0; + } } diff --git a/right/src/mouse_controller.h b/right/src/mouse_controller.h index e126ce357..723d8c7bd 100644 --- a/right/src/mouse_controller.h +++ b/right/src/mouse_controller.h @@ -45,6 +45,7 @@ extern mouse_kinetic_state_t MouseScrollState; extern uint8_t ActiveMouseStates[ACTIVE_MOUSE_STATES_COUNT]; + extern uint8_t ToggledMouseStates[ACTIVE_MOUSE_STATES_COUNT]; extern bool CompensateDiagonalSpeed; diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 6b75cbc4d..56c39b4a6 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -399,7 +399,7 @@ static void updateActiveUsbReports(void) Macros_ContinueMacro(); } - memset(ActiveMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT); + memcpy(ActiveMouseStates, ToggledMouseStates, ACTIVE_MOUSE_STATES_COUNT); basicScancodeIndex = 0; mediaScancodeIndex = 0;