Files
roro9stack/lib/input/src/key_mapper.h
T
twislaandClaude Opus 5.5 879cb0d0b6 Add widget kit, input layer with Compose Key, Launcher and demo apps
Steps 5 and 6 of M0.
- lib/ui (host-tested): ListModel, LineEditor (UTF-8, byte-limited),
  wrapText, ToastQueue, DialogModel
- lib/input (host-tested): KeyMapper turns keyboard state into logical
  keys (Fn arrows, ` Back, Fn+` Home) and composes accents with opt
- src/ui: off-screen 16-bit frame pushed in one transfer (fixes the
  flicker), Status Bar, list, text, line editor, dialog, Toast widgets,
  Notifier (Toast + beep + LED), vendored public-domain Latin-1 fonts
- Apps: minimal Launcher, Widget demo, Diagnostics (SD erase now
  behind a confirmation dialog)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-02 10:35:48 +02:00

42 lines
1.1 KiB
C++

#pragma once
#include <cstdint>
#include <vector>
#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<char> 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<KeyEvent> 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<KeyEvent>& out);
RawKeys previous_;
char compose_ = 0;
};
} // namespace roro