1#ifndef UNICODEKEYMAP_HH
2#define UNICODEKEYMAP_HH
22 static constexpr unsigned INVALID = 0xFF;
48 : rowCol(
narrow<uint8_t>((row << 3) | col))
57 [[nodiscard]]
constexpr bool isValid()
const {
58 return rowCol != INVALID;
64 [[nodiscard]]
constexpr uint8_t
getRow()
const {
90 [[nodiscard]]
constexpr uint8_t
getMask()
const {
98 uint8_t rowCol = INVALID;
119 [[nodiscard]]
constexpr bool isValid()
const {
128 [[nodiscard]]
KeyInfo get(
unsigned unicode)
const;
142 if (!msxChars)
throw CommandException(
"Missing MSX-Video-characterset file");
147 static constexpr unsigned NUM_DEAD_KEYS = 3;
149 void parseUnicodeKeyMapFile(std::string_view data);
156 std::vector<Entry> mapData;
161 std::array<uint8_t, KeyMatrixPosition::NUM_ROWCOL> relevantMods;
162 std::array<KeyInfo, NUM_DEAD_KEYS> deadKeys;
164 std::optional<MsxChar2Unicode> msxChars;
A position (row, column) in a keyboard matrix.
constexpr uint8_t getColumn() const
Returns the matrix column.
constexpr KeyMatrixPosition(uint8_t rowCol_)
Creates a key matrix position from a uint8_t: the row is stored in the high nibble,...
constexpr bool isValid() const
Returns true iff this position is valid.
static constexpr unsigned NUM_ROWCOL
Combined row and column values are in the range [0..NUM_ROWCOL).
constexpr KeyMatrixPosition(unsigned row, unsigned col)
Creates a key matrix position with a given row and column.
constexpr uint8_t getRowCol() const
Returns the matrix row and column combined in a single uint8_t: the column is stored in the lower 3 b...
constexpr bool operator==(const KeyMatrixPosition &) const =default
constexpr KeyMatrixPosition()=default
Creates an invalid key matrix position, which can be used when a key does not exist on a particular k...
static constexpr unsigned NUM_COLS
Columns are in the range [0..NUM_COLS).
constexpr uint8_t getMask() const
Returns a mask with the bit corresponding to this position's column set, all other bits clear.
static constexpr unsigned NUM_ROWS
Rows are in the range [0..NUM_ROWS).
constexpr uint8_t getRow() const
Returns the matrix row.
KeyInfo getDeadKey(unsigned n) const
KeyInfo get(unsigned unicode) const
uint8_t getRelevantMods(const KeyInfo &keyInfo) const
Returns a mask in which a bit is set iff the corresponding modifier is relevant for the given key.
const MsxChar2Unicode & getMsxChars() const
This file implemented 3 utility functions:
constexpr To narrow(From from) noexcept
constexpr auto to_underlying(E e) noexcept
constexpr KeyInfo(KeyMatrixPosition pos_, uint8_t modMask_)
static constexpr uint8_t CAPS_MASK
constexpr KeyInfo()=default
constexpr bool isValid() const
static constexpr uint8_t SHIFT_MASK
static constexpr uint8_t GRAPH_MASK
static constexpr uint8_t CODE_MASK
static constexpr uint8_t CTRL_MASK