#pragma once #include #include #include "key_event.h" namespace roro { // The physical keyboard state as reported by the keyboard driver: every character key currently // held (already shifted) plus the modifier and special keys. struct RawKeys { std::vector chars; bool fn = false; bool opt = false; bool ctrl = false; bool alt = false; bool shift = false; bool enter = false; bool del = false; bool tab = false; }; // Turns keyboard state changes into logical KeyEvents: only newly pressed keys produce events; // Fn + ; . , / are arrows; ` is Back and Fn + ` is Home; the Compose Key (opt) followed by an // accent and a letter types the accented letter (opt ' e -> é). class KeyMapper { public: std::vector update(const RawKeys& keys); // 0 when idle, '*' when opt was pressed, or the accent character waiting for its letter. char pendingCompose() const { return compose_; } private: void onChar(char c, const RawKeys& keys, std::vector& out); RawKeys previous_; char compose_ = 0; }; } // namespace roro