19 #include <string_view>
26 class CommandController;
28 class EventDistributor;
29 class MSXEventDistributor;
30 class StateChangeDistributor;
63 [[nodiscard]]
const byte*
getKeys()
const;
67 template<
typename Archive>
68 void serialize(Archive& ar,
unsigned version);
72 void signalMSXEvent(
const Event& event,
73 EmuTime::param time) noexcept
override;
75 void signalStateChange(
const StateChange& event)
override;
76 void stopReplay(EmuTime::param time) noexcept
override;
79 void executeUntil(EmuTime::param time)
override;
83 void changeKeyMatrixEvent (EmuTime::param time,
byte row,
byte newValue);
85 void processCapslockEvent(EmuTime::param time,
bool down);
86 void processCodeKanaChange(EmuTime::param time,
bool down);
87 void processGraphChange(EmuTime::param time,
bool down);
88 void processKeypadEnterKey(EmuTime::param time,
bool down);
89 void processSdlKey(EmuTime::param time,
bool down,
Keys::KeyCode key);
90 bool processQueuedEvent(
const Event& event, EmuTime::param time);
91 bool processKeyEvent(EmuTime::param time,
bool down,
const KeyEvent& keyEvent);
93 void processCmd(
Interpreter& interp, std::span<const TclObject> tokens,
bool up);
94 bool pressUnicodeByUser(
97 int pressAscii(
unsigned unicode,
bool down);
98 void pressLockKeys(
byte lockKeysMask,
bool down);
99 bool commonKeys(
unsigned unicode1,
unsigned unicode2);
100 void debug(
const char* format, ...);
115 const std::array<KeyMatrixPosition, UnicodeKeymap::KeyInfo::NUM_MODIFIERS>& modifierPos;
121 void execute(std::span<const TclObject> tokens,
TclObject& result,
122 EmuTime::param time)
override;
123 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
126 struct KeyMatrixDownCmd final : RecordedCommand {
127 KeyMatrixDownCmd(CommandController& commandController,
128 StateChangeDistributor& stateChangeDistributor,
130 void execute(std::span<const TclObject> tokens, TclObject& result,
131 EmuTime::param time)
override;
132 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
135 class KeyInserter final :
public RecordedCommand,
public Schedulable {
137 KeyInserter(CommandController& commandController,
138 StateChangeDistributor& stateChangeDistributor,
141 template<
typename Archive>
142 void serialize(Archive& ar,
unsigned version);
145 void type(std::string_view str);
146 void reschedule(EmuTime::param time);
149 void execute(std::span<const TclObject> tokens, TclObject& result,
150 EmuTime::param time)
override;
151 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
152 void tabCompletion(std::vector<std::string>& tokens)
const override;
155 void executeUntil(EmuTime::param time)
override;
158 std::string text_utf8;
164 bool releaseBeforePress;
168 struct Msxcode2UnicodeCmd final :
public Command {
169 Msxcode2UnicodeCmd(CommandController& commandController);
170 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
171 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
172 } msxcode2UnicodeCmd;
174 struct Unicode2MsxcodeCmd final :
public Command {
175 Unicode2MsxcodeCmd(CommandController& commandController);
176 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
177 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
178 } unicode2MsxcodeCmd;
180 class CapsLockAligner final :
private EventListener,
private Schedulable {
182 CapsLockAligner(EventDistributor& eventDistributor,
188 int signalEvent(
const Event& event) noexcept
override;
191 void executeUntil(EmuTime::param time)
override;
193 void alignCapsLock(EmuTime::param time);
196 EventDistributor& eventDistributor;
198 enum CapsLockAlignerStateType {
199 MUST_ALIGN_CAPSLOCK, MUST_DISTRIBUTE_KEY_RELEASE,
IDLE
203 KeyboardSettings keyboardSettings;
205 class MsxKeyEventQueue final :
public Schedulable {
207 MsxKeyEventQueue(
Scheduler& scheduler, Interpreter& interp);
208 void process_asap(EmuTime::param time,
211 template<
typename Archive>
212 void serialize(Archive& ar,
unsigned version);
215 void executeUntil(EmuTime::param time)
override;
217 std::deque<Event> eventQueue;
221 struct KeybDebuggable final : SimpleDebuggable {
222 explicit KeybDebuggable(MSXMotherBoard& motherBoard);
223 [[nodiscard]]
byte read(
unsigned address)
override;
224 void write(
unsigned address,
byte value)
override;
227 UnicodeKeymap unicodeKeymap;
244 const bool hasKeypad;
248 const bool blockRow11;
250 const bool keyGhosting;
252 const bool keyGhostingSGCprotected;
256 const byte modifierIsLock;
257 mutable bool keysChanged;
A position (row, column) in a keyboard matrix.
static constexpr unsigned NUM_ROWS
Rows are in the range [0..NUM_ROWS).
static constexpr int MAX_KEYSYM
void transferHostKeyMatrix(const Keyboard &source)
void serialize(Archive &ar, unsigned version)
const byte * getKeys() const
Returns a pointer to the current KeyBoard matrix.
Keyboard(MSXMotherBoard &motherBoard, Scheduler &scheduler, CommandController &commandController, EventDistributor &eventDistributor, MSXEventDistributor &msxEventDistributor, StateChangeDistributor &stateChangeDistributor, MatrixType matrix, const DeviceConfig &config)
Constructs a new Keyboard object.
Commands that directly influence the MSX state should send and events so that they can be recorded by...
Every class that wants to get scheduled at some point must inherit from this class.
Schedulable(const Schedulable &)=delete
bool pendingSyncPoint() const
virtual byte read(unsigned address, EmuTime::param time)
virtual void write(unsigned address, byte value, EmuTime::param time)
Base class for all external MSX state changing events.
KeyCode
Constants that identify keys and key modifiers.
This file implemented 3 utility functions:
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)