From 7728adfc5ab04f520fb53827cabed6dcd017d343 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 14 Jun 2018 17:23:47 -0400 Subject: [PATCH 1/2] Eliminates repetition of the `10` constant. --- Machines/AmstradCPC/AmstradCPC.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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_; }; /*! From 15deef50c8855810506db991134a79c94772325b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 14 Jun 2018 17:24:16 -0400 Subject: [PATCH 2/2] Adds a key reset upon screen mode changes in SDL. --- OSBindings/SDL/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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; }