diff --git a/include/utils/InputState.h b/include/utils/InputState.h index ffdc02d..d704793 100644 --- a/include/utils/InputState.h +++ b/include/utils/InputState.h @@ -20,7 +20,8 @@ struct InputState { }; Pad don_left, ka_left, don_right, ka_right; - uint16_t roll_counter; + uint16_t current_roll; + uint16_t previous_roll; }; struct Controller { diff --git a/src/peripherals/Display.cpp b/src/peripherals/Display.cpp index 232c2f0..e9b4907 100644 --- a/src/peripherals/Display.cpp +++ b/src/peripherals/Display.cpp @@ -58,8 +58,10 @@ void Display::drawIdleScreen() { ssd1306_draw_line(&m_display, 0, 10, 128, 10); // Roll counter - auto roll_str = std::to_string(m_input_state.drum.roll_counter) + " Roll"; + auto roll_str = std::to_string(m_input_state.drum.current_roll) + " Roll"; + auto prev_roll_str = "Last " + std::to_string(m_input_state.drum.previous_roll); ssd1306_draw_string(&m_display, (127 - (roll_str.length() * 12)) / 2, 20, 2, roll_str.c_str()); + ssd1306_draw_string(&m_display, (127 - (prev_roll_str.length() * 6)) / 2, 40, 1, prev_roll_str.c_str()); // Player "LEDs" if (m_player_id != 0) { diff --git a/src/peripherals/Drum.cpp b/src/peripherals/Drum.cpp index 4b59108..39ab970 100644 --- a/src/peripherals/Drum.cpp +++ b/src/peripherals/Drum.cpp @@ -102,9 +102,13 @@ void Drum::updateRollCounter(Utils::InputState &input_state) { static bool last_ka_left_state = false; static bool last_ka_right_state = false; static uint16_t roll_count = 0; + static uint16_t previous_roll = 0; uint32_t now = to_ms_since_boot(get_absolute_time()); if ((now - last_hit_time) > m_config.roll_counter_timeout_ms) { + if (roll_count > 1) { + previous_roll = roll_count; + } roll_count = 0; } @@ -130,7 +134,8 @@ void Drum::updateRollCounter(Utils::InputState &input_state) { last_ka_left_state = input_state.drum.ka_left.triggered; last_ka_right_state = input_state.drum.ka_right.triggered; - input_state.drum.roll_counter = roll_count; + input_state.drum.current_roll = roll_count; + input_state.drum.previous_roll = previous_roll; } void Drum::updateInputState(Utils::InputState &input_state) { diff --git a/src/utils/InputState.cpp b/src/utils/InputState.cpp index a98b184..43a015d 100644 --- a/src/utils/InputState.cpp +++ b/src/utils/InputState.cpp @@ -6,7 +6,7 @@ namespace Doncon::Utils { InputState::InputState() - : drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0}), + : drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0, 0}), controller( {{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}}), m_switch_report({}), m_ps3_report({}), m_ps4_report({}), m_keyboard_report({}), @@ -328,7 +328,7 @@ usb_report_t InputState::getDebugReport() { } void InputState::releaseAll() { - drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0}; + drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0, 0}; controller = {{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}}; }