From 75bcf4dd965ada74df7f40503c65b5693155a571 Mon Sep 17 00:00:00 2001 From: Frederik Walk Date: Sat, 2 Dec 2023 22:11:24 +0100 Subject: [PATCH] Release buttons when entering menu --- include/utils/InputState.h | 2 ++ src/main.cpp | 3 +++ src/utils/InputState.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/include/utils/InputState.h b/include/utils/InputState.h index 73671fd..fe88e90 100644 --- a/include/utils/InputState.h +++ b/include/utils/InputState.h @@ -61,6 +61,8 @@ struct InputState { usb_report_t getReport(usb_mode_t mode); + void releaseAll(); + bool checkHotkey(); }; diff --git a/src/main.cpp b/src/main.cpp index 5816986..7e48c9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,6 +157,9 @@ int main() { } else if (input_state.checkHotkey()) { menu.activate(); + input_state.releaseAll(); + usb_driver_send_and_receive_report(input_state.getReport(mode)); + ControlMessage ctrl_message{ControlCommand::EnterMenu, {}}; queue_add_blocking(&control_queue, &ctrl_message); } else { diff --git a/src/utils/InputState.cpp b/src/utils/InputState.cpp index 280ccf9..0c65f7a 100644 --- a/src/utils/InputState.cpp +++ b/src/utils/InputState.cpp @@ -290,6 +290,11 @@ usb_report_t InputState::getDebugReport() { return {(uint8_t *)m_debug_report.c_str(), static_cast(m_debug_report.size() + 1)}; } +void InputState::releaseAll() { + drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}}; + controller = {{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}}; +} + bool InputState::checkHotkey() { static uint32_t hold_since = 0; static bool hold_active = false;