diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index a9f91d1c0..ba58a5f76 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -115,13 +115,36 @@ class ConcreteMachine: } void set_key_state(uint16_t key, bool isPressed) final { - if(key == KeyBreak) { - m6502_.set_reset_line(isPressed); - } else { - if(isPressed) - key_states_[key >> 4] |= key&0xf; - else - key_states_[key >> 4] &= ~(key&0xf); + switch(key) { + default: + if(isPressed) + key_states_[key >> 4] |= key&0xf; + else + key_states_[key >> 4] &= ~(key&0xf); + break; + + case KeyBreak: + m6502_.set_reset_line(isPressed); + break; + +#define ShiftedKey(source, dest) \ + case source: \ + set_key_state(KeyShift, isPressed); \ + set_key_state(dest, isPressed); \ + break; + + ShiftedKey(KeyF1, Key1); + ShiftedKey(KeyF2, Key2); + ShiftedKey(KeyF3, Key3); + ShiftedKey(KeyF4, Key4); + ShiftedKey(KeyF5, Key5); + ShiftedKey(KeyF6, Key6); + ShiftedKey(KeyF7, Key7); + ShiftedKey(KeyF8, Key8); + ShiftedKey(KeyF9, Key9); + ShiftedKey(KeyF0, Key0); + +#undef ShiftedKey } } diff --git a/Machines/Electron/Keyboard.cpp b/Machines/Electron/Keyboard.cpp index 3ed607ead..26611d81b 100644 --- a/Machines/Electron/Keyboard.cpp +++ b/Machines/Electron/Keyboard.cpp @@ -52,6 +52,18 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { BIND(KeypadMinus, KeyMinus); BIND(KeypadPlus, KeyColon); BIND(Space, KeySpace); + + // Virtual mappings. + BIND(F1, KeyF1); + BIND(F2, KeyF2); + BIND(F3, KeyF3); + BIND(F4, KeyF4); + BIND(F5, KeyF5); + BIND(F6, KeyF6); + BIND(F7, KeyF7); + BIND(F8, KeyF8); + BIND(F9, KeyF9); + BIND(F10, KeyF0); } #undef BIND return KeyboardMachine::MappedMachine::KeyNotMapped; diff --git a/Machines/Electron/Keyboard.hpp b/Machines/Electron/Keyboard.hpp index 39c36d3ac..38a5baa4f 100644 --- a/Machines/Electron/Keyboard.hpp +++ b/Machines/Electron/Keyboard.hpp @@ -30,6 +30,9 @@ enum Key: uint16_t { KeyZ = 0x00c0 | 0x08, KeyA = 0x00c0 | 0x04, KeyQ = 0x00c0 | 0x02, Key1 = 0x00c0 | 0x01, KeyShift = 0x00d0 | 0x08, KeyControl = 0x00d0 | 0x04, KeyFunc = 0x00d0 | 0x02, KeyEscape = 0x00d0 | 0x01, + // Virtual keys. + KeyF1 = 0xfff0, KeyF2, KeyF3, KeyF4, KeyF5, KeyF6, KeyF7, KeyF8, KeyF9, KeyF0, + KeyBreak = 0xfffd, };