mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-07 20:30:52 +00:00
Adds a virtual delete key to the ZX80 and ZX81.
This commit is contained in:
parent
560394fead
commit
0705a99ea0
@ -28,6 +28,9 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) {
|
||||
BIND(FullStop, KeyDot);
|
||||
BIND(Enter, KeyEnter);
|
||||
BIND(Space, KeySpace);
|
||||
|
||||
// Virtual keys follow.
|
||||
BIND(Backspace, KeyDelete);
|
||||
}
|
||||
#undef BIND
|
||||
return KeyboardMachine::MappedMachine::KeyNotMapped;
|
||||
|
@ -23,6 +23,9 @@ enum Key: uint16_t {
|
||||
KeyP = 0x0500 | 0x01, KeyO = 0x0500 | 0x02, KeyI = 0x0500 | 0x04, KeyU = 0x0500 | 0x08, KeyY = 0x0500 | 0x10,
|
||||
KeyEnter = 0x0600 | 0x01, KeyL = 0x0600 | 0x02, KeyK = 0x0600 | 0x04, KeyJ = 0x0600 | 0x08, KeyH = 0x0600 | 0x10,
|
||||
KeySpace = 0x0700 | 0x01, KeyDot = 0x0700 | 0x02, KeyM = 0x0700 | 0x04, KeyN = 0x0700 | 0x08, KeyB = 0x0700 | 0x10,
|
||||
|
||||
// Add some virtual keys; these do not exist on a real ZX80 or ZX81. They're just a convenience.
|
||||
KeyDelete = 0x0801,
|
||||
};
|
||||
|
||||
struct KeyboardMapper: public KeyboardMachine::MappedMachine::KeyboardMapper {
|
||||
|
@ -349,10 +349,23 @@ template<bool is_zx81> class ConcreteMachine:
|
||||
|
||||
// MARK: - Keyboard
|
||||
void set_key_state(uint16_t key, bool is_pressed) final {
|
||||
if(is_pressed)
|
||||
key_states_[key >> 8] &= static_cast<uint8_t>(~key);
|
||||
else
|
||||
key_states_[key >> 8] |= static_cast<uint8_t>(key);
|
||||
const auto line = key >> 8;
|
||||
|
||||
// Check for special cases.
|
||||
if(line == 8) {
|
||||
switch(key) {
|
||||
case KeyDelete:
|
||||
// Map delete to shift+0.
|
||||
set_key_state(KeyShift, is_pressed);
|
||||
set_key_state(Key0, is_pressed);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(is_pressed)
|
||||
key_states_[line] &= uint8_t(~key);
|
||||
else
|
||||
key_states_[line] |= uint8_t(key);
|
||||
}
|
||||
}
|
||||
|
||||
void clear_all_keys() final {
|
||||
|
Loading…
x
Reference in New Issue
Block a user