1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-20 10:17:05 +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
+10
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,
};
}
+2 -1
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;
};
}
+2
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.