26class CommandController;
28class EventDistributor;
29class MSXEventDistributor;
30class StateChangeDistributor;
65 [[nodiscard]] std::span<const uint8_t, KeyMatrixPosition::NUM_ROWS>
getKeys()
const;
69 template<
typename Archive>
70 void serialize(Archive& ar,
unsigned version);
74 void signalMSXEvent(
const Event& event,
75 EmuTime::param time)
noexcept override;
77 void signalStateChange(
const StateChange& event)
override;
78 void stopReplay(EmuTime::param time)
noexcept override;
81 void executeUntil(EmuTime::param time)
override;
85 void changeKeyMatrixEvent (EmuTime::param time, uint8_t row, uint8_t newValue);
87 void processCapslockEvent(EmuTime::param time,
bool down);
88 void processCodeKanaChange(EmuTime::param time,
bool down);
89 void processGraphChange(EmuTime::param time,
bool down);
90 void processKeypadEnterKey(EmuTime::param time,
bool down);
91 void processSdlKey(EmuTime::param time,
bool down,
Keys::KeyCode key);
92 bool processQueuedEvent(
const Event& event, EmuTime::param time);
93 bool processKeyEvent(EmuTime::param time,
bool down,
const KeyEvent& keyEvent);
95 void processCmd(
Interpreter& interp, std::span<const TclObject> tokens,
bool up);
96 bool pressUnicodeByUser(
99 uint8_t pressAscii(
unsigned unicode,
bool down);
100 void pressLockKeys(uint8_t lockKeysMask,
bool down);
101 bool commonKeys(
unsigned unicode1,
unsigned unicode2);
102 void debug(
const char* format, ...);
115 std::span<const KeyMatrixPosition, MAX_KEYSYM> keyTab;
117 const std::array<KeyMatrixPosition, UnicodeKeymap::KeyInfo::NUM_MODIFIERS>& modifierPos;
123 void execute(std::span<const TclObject> tokens,
TclObject& result,
124 EmuTime::param time)
override;
125 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
128 struct KeyMatrixDownCmd final : RecordedCommand {
129 KeyMatrixDownCmd(CommandController& commandController,
130 StateChangeDistributor& stateChangeDistributor,
132 void execute(std::span<const TclObject> tokens, TclObject& result,
133 EmuTime::param time)
override;
134 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
137 class KeyInserter final :
public RecordedCommand,
public Schedulable {
139 KeyInserter(CommandController& commandController,
140 StateChangeDistributor& stateChangeDistributor,
143 template<
typename Archive>
144 void serialize(Archive& ar,
unsigned version);
147 void type(std::string_view str);
148 void reschedule(EmuTime::param time);
151 void execute(std::span<const TclObject> tokens, TclObject& result,
152 EmuTime::param time)
override;
153 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
154 void tabCompletion(std::vector<std::string>& tokens)
const override;
157 void executeUntil(EmuTime::param time)
override;
160 std::string text_utf8;
162 uint8_t lockKeysMask = 0;
163 bool releaseLast =
false;
164 uint8_t oldLocksOn = 0;
166 bool releaseBeforePress =
false;
167 int typingFrequency = 15;
170 struct Msxcode2UnicodeCmd final :
public Command {
171 Msxcode2UnicodeCmd(CommandController& commandController);
172 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
173 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
174 } msxcode2UnicodeCmd;
176 struct Unicode2MsxcodeCmd final :
public Command {
177 Unicode2MsxcodeCmd(CommandController& commandController);
178 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
179 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
180 } unicode2MsxcodeCmd;
182 class CapsLockAligner final :
private EventListener,
private Schedulable {
184 CapsLockAligner(EventDistributor& eventDistributor,
190 int signalEvent(
const Event& event)
override;
193 void executeUntil(EmuTime::param time)
override;
195 void alignCapsLock(EmuTime::param time);
198 EventDistributor& eventDistributor;
200 enum CapsLockAlignerStateType {
201 MUST_ALIGN_CAPSLOCK, MUST_DISTRIBUTE_KEY_RELEASE, IDLE
205 KeyboardSettings keyboardSettings;
207 class MsxKeyEventQueue final :
public Schedulable {
209 MsxKeyEventQueue(
Scheduler& scheduler, Interpreter& interp);
210 void process_asap(EmuTime::param time,
213 template<
typename Archive>
214 void serialize(Archive& ar,
unsigned version);
217 void executeUntil(EmuTime::param time)
override;
219 std::deque<Event> eventQueue;
223 struct KeybDebuggable final : SimpleDebuggable {
224 explicit KeybDebuggable(MSXMotherBoard& motherBoard);
225 [[nodiscard]] uint8_t
read(
unsigned address)
override;
226 void write(
unsigned address, uint8_t value)
override;
229 UnicodeKeymap unicodeKeymap;
230 std::array<unsigned, MAX_KEYSYM> dynKeymap;
233 std::array<uint8_t, KeyMatrixPosition::NUM_ROWS> cmdKeyMatrix;
235 std::array<uint8_t, KeyMatrixPosition::NUM_ROWS> typeKeyMatrix;
237 std::array<uint8_t, KeyMatrixPosition::NUM_ROWS> userKeyMatrix;
239 std::array<uint8_t, KeyMatrixPosition::NUM_ROWS> hostKeyMatrix;
241 mutable std::array<uint8_t, KeyMatrixPosition::NUM_ROWS> keyMatrix;
243 uint8_t msxModifiers = 0xff;
246 const bool hasKeypad;
250 const bool blockRow11;
252 const bool keyGhosting;
254 const bool keyGhostingSGCprotected;
258 const uint8_t modifierIsLock;
259 mutable bool keysChanged =
false;
A position (row, column) in a keyboard matrix.
static constexpr int MAX_KEYSYM
void transferHostKeyMatrix(const Keyboard &source)
void serialize(Archive &ar, unsigned version)
std::span< const uint8_t, KeyMatrixPosition::NUM_ROWS > getKeys() const
Returns a pointer to the current KeyBoard matrix.
const MsxChar2Unicode & getMsxChar2Unicode() const
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)