2017-10-13 02:25:02 +00:00
|
|
|
//
|
|
|
|
// KeyboardMachine.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/10/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-10-13 02:25:02 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "KeyboardMachine.hpp"
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
using namespace MachineTypes;
|
2017-10-13 02:25:02 +00:00
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
MachineTypes::MappedKeyboardMachine::MappedKeyboardMachine(const std::set<Inputs::Keyboard::Key> &essential_modifiers) : keyboard_(essential_modifiers) {
|
2017-10-13 02:25:02 +00:00
|
|
|
keyboard_.set_delegate(this);
|
|
|
|
}
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
bool MappedKeyboardMachine::keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed) {
|
2018-02-09 21:31:05 +00:00
|
|
|
uint16_t mapped_key = get_keyboard_mapper()->mapped_key_for_key(key);
|
2020-03-03 03:08:54 +00:00
|
|
|
if(mapped_key == KeyNotMapped) return false;
|
|
|
|
set_key_state(mapped_key, is_pressed);
|
|
|
|
return true;
|
2017-10-13 02:25:02 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
void MappedKeyboardMachine::reset_all_keys(Inputs::Keyboard *keyboard) {
|
2017-10-13 02:25:02 +00:00
|
|
|
// TODO: unify naming.
|
|
|
|
clear_all_keys();
|
|
|
|
}
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
Inputs::Keyboard &MappedKeyboardMachine::get_keyboard() {
|
2017-10-13 02:25:02 +00:00
|
|
|
return keyboard_;
|
|
|
|
}
|
2017-12-29 23:30:46 +00:00
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
void KeyboardMachine::type_string(const std::string &) {
|
2017-12-29 23:30:46 +00:00
|
|
|
}
|
2018-02-09 21:31:05 +00:00
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
MappedKeyboardMachine::KeyboardMapper *MappedKeyboardMachine::get_keyboard_mapper() {
|
2018-02-09 21:31:05 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|