1#ifndef UNICODEKEYMAP_HH
2#define UNICODEKEYMAP_HH
19 static constexpr unsigned INVALID = 0xFF;
45 : rowCol(
narrow<uint8_t>((row << 3) | col))
54 [[nodiscard]]
constexpr bool isValid()
const {
55 return rowCol != INVALID;
61 [[nodiscard]]
constexpr uint8_t
getRow()
const {
87 [[nodiscard]]
constexpr uint8_t
getMask()
const {
95 uint8_t rowCol = INVALID;
116 [[nodiscard]]
constexpr bool isValid()
const {
125 [[nodiscard]]
KeyInfo get(
unsigned unicode)
const;
139 if (!msxChars)
throw CommandException(
"Missing MSX-Video-characterset file");
144 static constexpr unsigned NUM_DEAD_KEYS = 3;
146 void parseUnicodeKeyMapFile(std::string_view data);
153 std::vector<Entry> mapData;
158 std::array<uint8_t, KeyMatrixPosition::NUM_ROWCOL> relevantMods;
159 std::array<KeyInfo, NUM_DEAD_KEYS> deadKeys;
161 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.
UnicodeKeymap(std::string_view keyboardType)
const MsxChar2Unicode & getMsxChars() const
This file implemented 3 utility functions:
constexpr To narrow(From from) 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