2018-02-09 21:31:05 +00:00
|
|
|
//
|
|
|
|
// MultiKeyboardMachine.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 09/02/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-02-09 21:31:05 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef MultiKeyboardMachine_hpp
|
|
|
|
#define MultiKeyboardMachine_hpp
|
|
|
|
|
|
|
|
#include "../../../../Machines/DynamicMachine.hpp"
|
|
|
|
#include "../../../../Machines/KeyboardMachine.hpp"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Analyser {
|
|
|
|
namespace Dynamic {
|
|
|
|
|
2018-02-19 21:03:17 +00:00
|
|
|
/*!
|
|
|
|
Provides a class that multiplexes the keyboard machine interface to multiple machines.
|
|
|
|
|
|
|
|
Makes a static internal copy of the list of machines; makes no guarantees about the
|
|
|
|
order of delivered messages.
|
|
|
|
*/
|
2020-04-02 03:19:34 +00:00
|
|
|
class MultiKeyboardMachine: public MachineTypes::KeyboardMachine {
|
2018-10-25 02:20:58 +00:00
|
|
|
private:
|
2020-04-02 03:19:34 +00:00
|
|
|
std::vector<MachineTypes::KeyboardMachine *> machines_;
|
2018-10-25 02:20:58 +00:00
|
|
|
|
|
|
|
class MultiKeyboard: public Inputs::Keyboard {
|
|
|
|
public:
|
2020-04-02 03:19:34 +00:00
|
|
|
MultiKeyboard(const std::vector<MachineTypes::KeyboardMachine *> &machines);
|
2018-10-25 02:20:58 +00:00
|
|
|
|
2020-03-03 03:08:54 +00:00
|
|
|
bool set_key_pressed(Key key, char value, bool is_pressed) final;
|
2020-01-24 03:57:51 +00:00
|
|
|
void reset_all_keys() final;
|
|
|
|
const std::set<Key> &observed_keys() final;
|
|
|
|
bool is_exclusive() final;
|
2018-10-25 02:20:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-02 03:19:34 +00:00
|
|
|
const std::vector<MachineTypes::KeyboardMachine *> &machines_;
|
2018-10-25 02:20:58 +00:00
|
|
|
std::set<Key> observed_keys_;
|
|
|
|
bool is_exclusive_ = false;
|
|
|
|
};
|
|
|
|
MultiKeyboard keyboard_;
|
|
|
|
|
2018-02-09 21:31:05 +00:00
|
|
|
public:
|
|
|
|
MultiKeyboardMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines);
|
|
|
|
|
2018-02-19 21:03:17 +00:00
|
|
|
// Below is the standard KeyboardMachine::Machine interface; see there for documentation.
|
2020-01-24 03:57:51 +00:00
|
|
|
void clear_all_keys() final;
|
|
|
|
void set_key_state(uint16_t key, bool is_pressed) final;
|
|
|
|
void type_string(const std::string &) final;
|
2020-03-02 01:25:12 +00:00
|
|
|
bool can_type(char c) final;
|
2020-01-24 03:57:51 +00:00
|
|
|
Inputs::Keyboard &get_keyboard() final;
|
2018-02-09 21:31:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MultiKeyboardMachine_hpp */
|