1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Adds an interface allowing keyboard mappers to declare modifiers that are 'essential'.

i.e. ones that, if not delivered reliably, will cause the related machine to behave unexpectedly.
This commit is contained in:
Thomas Harte 2019-09-22 13:14:09 -04:00
parent e78b1dcf3c
commit a416bc0058
3 changed files with 14 additions and 1 deletions

View File

@ -86,3 +86,13 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) {
#undef Bind
}
}
std::set<Inputs::Keyboard::Key> KeyboardMapper::get_essential_modifiers() {
// Control is fairly optional for a Mac, but option, meta and shift
// are essential.
return {
Inputs::Keyboard::Key::LeftShift, Inputs::Keyboard::Key::RightShift,
Inputs::Keyboard::Key::LeftOption, Inputs::Keyboard::Key::RightOption,
Inputs::Keyboard::Key::LeftMeta, Inputs::Keyboard::Key::RightMeta,
};
}

View File

@ -291,7 +291,8 @@ class Keyboard {
Provides a mapping from idiomatic PC keys to Macintosh keys.
*/
class KeyboardMapper: public KeyboardMachine::MappedMachine::KeyboardMapper {
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) override;
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) final;
std::set<Inputs::Keyboard::Key> get_essential_modifiers() final;
};
}

View File

@ -11,6 +11,7 @@
#include <cstdint>
#include <string>
#include <set>
#include "../Inputs/Keyboard.hpp"
@ -65,6 +66,7 @@ class MappedMachine: public Inputs::Keyboard::Delegate, public Machine {
class KeyboardMapper {
public:
virtual uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) = 0;
virtual std::set<Inputs::Keyboard::Key> get_essential_modifiers() { return {}; }
};
/// Terminates a key sequence from the character mapper.