Skip to content
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
FontKeyboard Class Reference

The full keyboard's tile->key map: which game tile sits on which physical key. More...

#include <fontkeyboard.h>

Inheritance diagram for FontKeyboard:
Collaboration diagram for FontKeyboard:

Public Types

enum  Render { RenderEmpty = 0 , RenderTile , RenderPreview , RenderLabel }
 < Current page = its modifier mask, 0-7. More...
enum  Category {
  CatNone = 0 , CatNormal , CatSingle , CatMulti ,
  CatVariable , CatPicture , CatControl
}
 Tile category. Order matches the old filter strip = the usage order. More...

Public Member Functions

 FontKeyboard (QObject *parent=nullptr)
QVariantMap keyDataFor (const QString &key, bool shift, bool ctrl, bool alt, bool caps) const
 keyData() for the page this key actually reads. What the deck binds to.
QVariantMap keyData (int page, const QString &key) const
 Everything a keycap needs: { ind, code, title, tip, category, render, empty, natural }.
QVariantMap spaceData () const
 The same map for the spacebar (the Space tile lives there, not on a letter).
protected::void pageChanged ()

Static Public Member Functions

static int effectivePage (bool shift, bool ctrl, bool alt, bool caps)
 Assignable keys per page: 26 letters + 10 digits + the 11 punctuation keys ( - = [ ] \ ; ' , .
static QString pageBadge (int page)
 The modifier badge for a page, e.g. "" / "Shift" / "Ctrl+Alt".
static int indFor (int page, const QString &key)
 The font code on key of page, or 0 when that key is empty.
static QString naturalChar (const QString &key, bool shift)
 What a REAL keyboard (US layout) types for key with/without Shift – "a"/"A", "1"/"!", "."/">".
static QString pageDescription (int page)
 The quiet line under the deck saying what this page is.
static QString chopLastToken (const QString &str)
 Drop the last whole token off a code string – "RED<player>" -> "RED".

Static Public Attributes

static constexpr int pageTotal = 8
 Modifier combos: none/S/C/A/SC/SA/CA/SCA.

Detailed Description

The full keyboard's tile->key map: which game tile sits on which physical key.

Backs the redesigned full-screen name editor (screens/modal/FullKeyboard.qml), which draws a real ASDF/QWERTY deck whose 36 alphanumeric keys each carry one game tile. There are 255 tiles and 36 keys, so the deck has 8 pages – and Shift/Ctrl/Alt give exactly 8 modifier combinations, one per page.

The map itself (pageInd) is a hand-authored table, not a generated fill. Its doctrine, in priority order:

  1. Identity beats everything. If a tile is a key it lives on that key – page 1 is A-Z + 0-9, page 2 (Shift) is a-z, exactly like a real keyboard.
  2. Mnemonic beats ergonomics. 's on S, bold B on B (Ctrl+B!), <player> on P, <pc> on C, <dex> on X. The key legend printed on each cap makes an awkward-but-memorable key beat a comfy random one.
  3. Ergonomics breaks ties. Otherwise the more-used tile gets the better key (home row, then upper, then bottom, then the number row).

Pages follow the category order (Normal, Single-Char, Multi-Char, Variable, Picture, Control), so the four cheapest modifier combos hold everything you'd ever legitimately put in a name, and the two categories that glitch a name sit behind two- and three-key combos.

The Space tile is the one exception: it rides the deck's real spacebar (spaceInd), which is where every human already expects it. That is the only tile not on an alphanumeric key.

Every one of the 255 tiles appears exactly once across the 8 pages + the spacebar. That invariant is not a comment – it is pinned by tst_font_keyboard.

Note
A page's INDEX IS ITS MODIFIER MASK (shift = 1, ctrl = 2, alt = 4), so Alt is page 4, not "the 4th page". pageFor is therefore just the mask, and the deck can never show a page that disagrees with the keys being held. The human reading order (by category, cheapest chord first) is pageOrder – don't confuse the two, or two whole pages silently swap.

Exposed to QML as brg.keyboard.

See also
FontsDB (the tiles), notes/plans/full-keyboard-redesign.md (the full design).

Definition at line 64 of file fontkeyboard.h.

Member Enumeration Documentation

◆ Category

Tile category. Order matches the old filter strip = the usage order.

Enumerator
CatNone 
CatNormal 
CatSingle 
CatMulti 
CatVariable 
CatPicture 
CatControl 

Definition at line 84 of file fontkeyboard.h.

◆ Render

< Current page = its modifier mask, 0-7.

Display name of each page (indexed by mask). Pages in the order a human should meet them. How many pages (8). How a key draws its tile. The tile sheet can't render everything.

Enumerator
RenderEmpty 

No tile on this key.

RenderTile 

A single 8x8 tile, clipped from the shared animated sheet.

RenderPreview 

Multi-char/variable: render the expanded text (<poke> -> "Poke").

RenderLabel 

Control code: no glyph at all, so the cap shows its name.

Definition at line 75 of file fontkeyboard.h.

Constructor & Destructor Documentation

◆ FontKeyboard()

FontKeyboard::FontKeyboard ( QObject * parent = nullptr)
explicit

Definition at line 270 of file fontkeyboard.cpp.

Member Function Documentation

◆ chopLastToken()

QString FontKeyboard::chopLastToken ( const QString & str)
static

Drop the last whole token off a code string – "RED<player>" -> "RED".

A backspace must never bite one character out of the middle of a <code>.

Definition at line 492 of file fontkeyboard.cpp.

◆ effectivePage()

int FontKeyboard::effectivePage ( bool shift,
bool ctrl,
bool alt,
bool caps )
static

Assignable keys per page: 26 letters + 10 digits + the 11 punctuation keys ( - = [ ] \ ; ' , .

/). The punctuation keys were dead filler at first; they now carry the tiles that BELONG on them (. types ., Shift+/ types ?`). */ static constexpr int keyTotal = 47;

int getPage() const; ///<

See also
page property. void setPage(int val); ///<
page property. QStringList getPageNames() const; ///<
pageNames property. QVariantList getPageOrder() const; ///<
pageOrder property. int getPageCount() const; ///<
pageCount property.

/ The 36 key labels in deck order (number row, QWERTY, ASDF, ZXCV). Test/QML helper. static QStringList keyLabels();

/ Which page a modifier combination selects. The whole point of 8 pages / 8 combos. static int pageFor(bool shift, bool ctrl, bool alt);

/** The page actually on show, once Caps Lock is taken into account.

Caps LOCKS THE SHIFT PAGE (it is a page selector, not a per-key letter-case rule): Shift inverts it, Ctrl/Alt ignore it. So every state the deck can be in is exactly one of the 8 pages – which is what lets the page strip always be right.

See also
the note in the .cpp for why the real-keyboard behaviour was dropped.

Definition at line 339 of file fontkeyboard.cpp.

Referenced by keyDataFor().

◆ indFor()

int FontKeyboard::indFor ( int page,
const QString & key )
static

The font code on key of page, or 0 when that key is empty.

Definition at line 374 of file fontkeyboard.cpp.

References pageTotal.

Referenced by keyData().

◆ keyData()

QVariantMap FontKeyboard::keyData ( int page,
const QString & key ) const

Everything a keycap needs: { ind, code, title, tip, category, render, empty, natural }.

Returns an empty-flagged map for an unmapped key – never a null/undefined.

Definition at line 417 of file fontkeyboard.cpp.

References indFor().

Referenced by keyDataFor().

◆ keyDataFor()

QVariantMap FontKeyboard::keyDataFor ( const QString & key,
bool shift,
bool ctrl,
bool alt,
bool caps ) const

keyData() for the page this key actually reads. What the deck binds to.

Definition at line 368 of file fontkeyboard.cpp.

References effectivePage(), and keyData().

◆ naturalChar()

QString FontKeyboard::naturalChar ( const QString & key,
bool shift )
static

What a REAL keyboard (US layout) types for key with/without Shift – "a"/"A", "1"/"!", "."/">".

Empty for keys that produce no character.

This is what lets a cap drop its corner legend: if the deck types, on this key with these modifiers, exactly what the physical keyboard would, the legend has nothing to teach. It also states the design rule – a tile goes where a real keyboard would put it whenever it can, and must never pretend (a period on Ctrl+"/" while a real period sits on the period key is a false affordance).

Definition at line 391 of file fontkeyboard.cpp.

◆ pageBadge()

QString FontKeyboard::pageBadge ( int page)
static

The modifier badge for a page, e.g. "" / "Shift" / "Ctrl+Alt".

Definition at line 331 of file fontkeyboard.cpp.

References pageTotal.

◆ pageChanged()

protected::void FontKeyboard::pageChanged ( )

◆ pageDescription()

QString FontKeyboard::pageDescription ( int page)
static

The quiet line under the deck saying what this page is.

Definition at line 409 of file fontkeyboard.cpp.

References pageTotal.

◆ spaceData()

QVariantMap FontKeyboard::spaceData ( ) const

The same map for the spacebar (the Space tile lives there, not on a letter).

Definition at line 422 of file fontkeyboard.cpp.

Member Data Documentation

◆ pageTotal

int FontKeyboard::pageTotal = 8
staticconstexpr

Modifier combos: none/S/C/A/SC/SA/CA/SCA.

Definition at line 97 of file fontkeyboard.h.

Referenced by indFor(), pageBadge(), and pageDescription().


The documentation for this class was generated from the following files: