From 90e6bef6d7182dda1a2a5a061a33dec8dc4ff551 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 1 Mar 2020 21:47:28 -0500 Subject: [PATCH] Adds virtual keys for F2, F4, F6 and F8. --- Machines/Commodore/Vic-20/Keyboard.cpp | 10 ++++++++-- Machines/Commodore/Vic-20/Keyboard.hpp | 4 ++++ Machines/Commodore/Vic-20/Vic20.cpp | 19 ++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Machines/Commodore/Vic-20/Keyboard.cpp b/Machines/Commodore/Vic-20/Keyboard.cpp index 2d4152b7b..017c47cb2 100644 --- a/Machines/Commodore/Vic-20/Keyboard.cpp +++ b/Machines/Commodore/Vic-20/Keyboard.cpp @@ -56,8 +56,6 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { BIND(Right, KeyRight); BIND(Down, KeyDown); - BIND(Left, KeyLeft); - BIND(Up, KeyUp); BIND(Enter, KeyReturn); BIND(Space, KeySpace); @@ -68,6 +66,14 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { BIND(F3, KeyF3); BIND(F5, KeyF5); BIND(F7, KeyF7); + + // Mappings to virtual keys. + BIND(Left, KeyLeft); + BIND(Up, KeyUp); + BIND(F2, KeyF2); + BIND(F4, KeyF4); + BIND(F6, KeyF6); + BIND(F8, KeyF8); } #undef BIND return KeyboardMachine::MappedMachine::KeyNotMapped; diff --git a/Machines/Commodore/Vic-20/Keyboard.hpp b/Machines/Commodore/Vic-20/Keyboard.hpp index ec775fd96..8e66d2278 100644 --- a/Machines/Commodore/Vic-20/Keyboard.hpp +++ b/Machines/Commodore/Vic-20/Keyboard.hpp @@ -37,6 +37,10 @@ enum Key: uint16_t { // Virtual keys. KeyUp = 0xfff0, KeyLeft = 0xfff1, + KeyF2 = 0xfff2, + KeyF4 = 0xfff3, + KeyF6 = 0xfff4, + KeyF8 = 0xfff5, // Physical keys not within the usual matrix. KeyRestore = 0xfffd, diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 5123f394d..94e328c00 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -486,14 +486,19 @@ class ConcreteMachine: case KeyRestore: user_port_via_.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !is_pressed); break; - case KeyUp: - keyboard_via_port_handler_->set_key_state(KeyLShift, is_pressed); - keyboard_via_port_handler_->set_key_state(KeyDown, is_pressed); - break; - case KeyLeft: - keyboard_via_port_handler_->set_key_state(KeyLShift, is_pressed); - keyboard_via_port_handler_->set_key_state(KeyRight, is_pressed); +#define ShiftedMap(source, target) \ + case source: \ + keyboard_via_port_handler_->set_key_state(KeyLShift, is_pressed); \ + keyboard_via_port_handler_->set_key_state(target, is_pressed); \ break; + + ShiftedMap(KeyUp, KeyDown); + ShiftedMap(KeyLeft, KeyRight); + ShiftedMap(KeyF2, KeyF1); + ShiftedMap(KeyF4, KeyF3); + ShiftedMap(KeyF6, KeyF5); + ShiftedMap(KeyF8, KeyF7); +#undef ShiftedMap } } }