mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-19 19:16:34 +00:00
Switch to map-based mapping.
This commit is contained in:
@@ -225,7 +225,7 @@ private:
|
||||
}
|
||||
} () & 0xfe; // Discard the first row.
|
||||
|
||||
Logger::info().append("CA2 to %d in mode %d", state, bool(latch_ & 8)).append_if(!(latch_ & 8), " for key %02x", port_a_output_ & 0x7f);
|
||||
// Logger::info().append("CA2 to %d in mode %d", state, bool(latch_ & 8)).append_if(!(latch_ & 8), " for key %02x", port_a_output_ & 0x7f);
|
||||
via_.set_control_line_input<MOS::MOS6522::Port::A, MOS::MOS6522::Line::Two>(state);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,29 +10,38 @@
|
||||
|
||||
#include "Machines/KeyboardMachine.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace BBCMicro {
|
||||
|
||||
struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper {
|
||||
|
||||
uint16_t mapped_key_for_key(const Inputs::Keyboard::Key key) const override {
|
||||
using Key = Inputs::Keyboard::Key;
|
||||
switch(key) {
|
||||
default: break;
|
||||
|
||||
case Key::Escape: return 0x70;
|
||||
case Key::Q: return 0x10;
|
||||
case Key::F10: return 0x20;
|
||||
case Key::k1: return 0x30;
|
||||
case Key::CapsLock: return 0x40;
|
||||
// case Key::CapsLock: return 0x40;
|
||||
case Key::Tab: return 0x60;
|
||||
case Key::LeftShift:
|
||||
case Key::RightShift: return 0x00;
|
||||
|
||||
uint16_t mapped_key_for_key(const Inputs::Keyboard::Key key) const override {
|
||||
const auto found = key_map.find(key);
|
||||
return found != key_map.end() ? found->second : MachineTypes::MappedKeyboardMachine::KeyNotMapped;
|
||||
// switch(key) {
|
||||
// default: break;
|
||||
//
|
||||
// case Key::Escape: return 0x70;
|
||||
// case Key::Q: return 0x10;
|
||||
// case Key::F10: return 0x20;
|
||||
// case Key::k1: return 0x30;
|
||||
// case Key::CapsLock: return 0x40;
|
||||
// case Key::Tab: return 0x60;
|
||||
// case Key::LeftShift:
|
||||
// case Key::RightShift: return 0x00;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return MachineTypes::MappedKeyboardMachine::KeyNotMapped;
|
||||
}
|
||||
|
||||
return MachineTypes::MappedKeyboardMachine::KeyNotMapped;
|
||||
}
|
||||
private:
|
||||
using Key = Inputs::Keyboard::Key;
|
||||
static inline const std::unordered_map<Key, uint16_t> key_map{
|
||||
{Key::Escape, 0x70}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user