Release buttons when entering menu

This commit is contained in:
Frederik Walk 2023-12-02 22:11:24 +01:00
parent 4244a4ff17
commit 75bcf4dd96
3 changed files with 10 additions and 0 deletions

View File

@ -61,6 +61,8 @@ struct InputState {
usb_report_t getReport(usb_mode_t mode); usb_report_t getReport(usb_mode_t mode);
void releaseAll();
bool checkHotkey(); bool checkHotkey();
}; };

View File

@ -157,6 +157,9 @@ int main() {
} else if (input_state.checkHotkey()) { } else if (input_state.checkHotkey()) {
menu.activate(); menu.activate();
input_state.releaseAll();
usb_driver_send_and_receive_report(input_state.getReport(mode));
ControlMessage ctrl_message{ControlCommand::EnterMenu, {}}; ControlMessage ctrl_message{ControlCommand::EnterMenu, {}};
queue_add_blocking(&control_queue, &ctrl_message); queue_add_blocking(&control_queue, &ctrl_message);
} else { } else {

View File

@ -290,6 +290,11 @@ usb_report_t InputState::getDebugReport() {
return {(uint8_t *)m_debug_report.c_str(), static_cast<uint16_t>(m_debug_report.size() + 1)}; return {(uint8_t *)m_debug_report.c_str(), static_cast<uint16_t>(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() { bool InputState::checkHotkey() {
static uint32_t hold_since = 0; static uint32_t hold_since = 0;
static bool hold_active = false; static bool hold_active = false;