From 015622bc22efec9f086aeae7f36333b526ce0451 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 14 Jan 2024 18:23:33 +0100 Subject: [PATCH] Kernel: Set correct KeyCode count The underlying value of the `KeyCode::Key_*` enum values starts at 0, so we should add 1 to `Key_Menu` to get the correct count. --- Kernel/API/KeyCode.h | 2 +- Userland/Applications/Piano/MainWidget.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/API/KeyCode.h b/Kernel/API/KeyCode.h index c7f191f515..cd1ddd8560 100644 --- a/Kernel/API/KeyCode.h +++ b/Kernel/API/KeyCode.h @@ -152,7 +152,7 @@ enum KeyCode : u8 { Key_Shift = Key_LeftShift, }; -int const key_code_count = Key_Menu; +size_t const key_code_count = Key_Menu + 1; enum KeyModifier { Mod_None = 0x00, diff --git a/Userland/Applications/Piano/MainWidget.cpp b/Userland/Applications/Piano/MainWidget.cpp index a97b99a62c..d0d7e842b8 100644 --- a/Userland/Applications/Piano/MainWidget.cpp +++ b/Userland/Applications/Piano/MainWidget.cpp @@ -189,7 +189,7 @@ void MainWidget::turn_off_pressed_keys() { if (m_keys_widget->mouse_note() != -1) m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), DSP::Keyboard::Switch::Off); - for (int i = 0; i < key_code_count; ++i) { + for (size_t i = 0u; i < key_code_count; ++i) { if (m_keys_pressed[i]) note_key_action(i, DSP::Keyboard::Switch::Off); } @@ -199,7 +199,7 @@ void MainWidget::turn_on_pressed_keys() { if (m_keys_widget->mouse_note() != -1) m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), DSP::Keyboard::Switch::On); - for (int i = 0; i < key_code_count; ++i) { + for (size_t i = 0u; i < key_code_count; ++i) { if (m_keys_pressed[i]) note_key_action(i, DSP::Keyboard::Switch::On); }