diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index c484b7add..7d96c07c7 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -546,14 +546,14 @@ class KeyboardState: public GI::AY38910::PortHandler { Sets the row currently being reported to the AY. */ void set_row(int row) { - row_ = row; + row_ = static_cast(row); } /*! Reports the state of the currently-selected row as Port A to the AY. */ uint8_t get_port_input(bool port_b) { - if(!port_b && row_ < 10) { + if(!port_b && row_ < sizeof(rows_)) { return rows_[row_]; } @@ -565,7 +565,7 @@ class KeyboardState: public GI::AY38910::PortHandler { */ void set_is_pressed(bool is_pressed, int line, int key) { int mask = 1 << key; - assert(line < 10); + assert(static_cast(line) < sizeof(rows_)); if(is_pressed) rows_[line] &= ~mask; else rows_[line] |= mask; } @@ -573,12 +573,12 @@ class KeyboardState: public GI::AY38910::PortHandler { Sets all keys as currently unpressed. */ void clear_all_keys() { - memset(rows_, 0xff, 10); + memset(rows_, 0xff, sizeof(rows_)); } private: uint8_t rows_[10]; - int row_; + size_t row_; }; /*! diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 344a86eb9..8fa5f9abb 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -461,6 +461,12 @@ int main(int argc, char *argv[]) { fullscreen_mode ^= SDL_WINDOW_FULLSCREEN_DESKTOP; SDL_SetWindowFullscreen(window, fullscreen_mode); SDL_ShowCursor((fullscreen_mode&SDL_WINDOW_FULLSCREEN_DESKTOP) ? SDL_DISABLE : SDL_ENABLE); + + // Announce a potential discontinuity in keyboard input. + auto keyboard_machine = machine->keyboard_machine(); + if(keyboard_machine) { + keyboard_machine->get_keyboard().reset_all_keys(); + } break; }