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:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user