24static const char*
s_tag =
"KBD";
30typedef enum : int32_t {
57static const char s_n_r0[] =
"1234567890";
58static const char s_n_r1[] =
"-/:;()$&@\"";
62static const char s_s_r0[] =
"[]{}#%^*+=";
63static const char s_s_r1[] =
"<>\\_`|~";
198 for (int32_t i = 0; i < n; i++) {
207 (
char)((hi !=
nullptr) ? hi[i] : lo[i]),
399 const int32_t fy = f->
y;
409 const int32_t y2 = fy + ((int32_t)
k_kbd_row2 * rh);
461 const int32_t fy = f->
y;
500 const int32_t fy = f->
y;
561 if ((frame->
w <= 0) || (frame->
h <= 0)) {
576 for (uint8_t i = 0U; i < kb->
count; i++) {
586 if ((kb ==
nullptr) || (key_idx >= kb->
count)) {
645 if (key_idx >= kb->
count) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
uint8_t ra8_kbd_hit(const ra8_kbd_layout_t *kb, int32_t px, int32_t py)
Map a tap to a key index.
static void internal_add(ra8_kbd_layout_t *kb, int32_t x, int32_t w, int32_t y, int32_t h, char lo, char hi, ra8_kbd_key_kind_t kind, uint8_t aux)
Append one key descriptor to the layout, bounded by k_ra8_kbd_max_keys.
ra8_err_t ra8_kbd_text_init(ra8_kbd_text_t *t)
Reset a text buffer to empty / uncommitted.
static void internal_build_numbers(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *f, int32_t rh)
Build the numbers layer (digits, common symbols; #+= toggles to symbols).
static const char s_n_r0[]
static void internal_build_symbols(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *f, int32_t rh)
Build the symbols layer (brackets, math operators; 123 toggles to numbers).
ra8_err_t ra8_kbd_apply(ra8_kbd_text_t *t, ra8_kbd_layout_t *kb, uint8_t key_idx)
Apply key key_idx to the text buffer, SHIFT, and active layer.
static const char s_l_r2_lo[]
static const char s_l_r2_hi[]
static void internal_build_letters(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *f, int32_t rh)
Build the letters layer (QWERTY / SHIFT / 123 bottom-row toggle).
static void internal_place(ra8_kbd_layout_t *kb, const char *lo, const char *hi, int32_t n, int32_t hu0, const ra8_ui_rect_t *f, int32_t y, int32_t rh)
Place n character keys, each k_kbd_key_hu (2) half-units wide, starting from half-unit offset hu0.
static const char s_s_r0[]
static void internal_row_bottom(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *f, int32_t y, int32_t rh, uint8_t left_aux)
Build the bottom row: a layer-toggle key, SPACE, and RETURN.
static const char s_l_r0_hi[]
static const char s_l_r1_lo[]
kbd_geom_t
Row geometry in 20ths of the width ("half-units"), iOS proportions.
@ k_kbd_top_keys
Keys in rows 0 and 1.
@ k_kbd_wide_hu
SHIFT / BACKSPACE width.
@ k_kbd_hu_div
Half-units per row (a normal key = 2 hu).
@ k_kbd_inset_hu
Home-row inset each side.
@ k_kbd_sym1_n
Symbols row 1 keys (_ \ | ~ < > `).
@ k_kbd_punct_hu0
Centred start for the 5 punctuation keys.
@ k_kbd_space_hu
SPACE width.
@ k_kbd_punct_n
Punctuation keys (.
@ k_kbd_act_hu
123 / ABC / RETURN width.
@ k_kbd_key_hu
Normal key width (half-units).
@ k_kbd_mid_keys
Keys in the inset home row.
@ k_kbd_sym1_hu0
Centred start for symbols row 1.
@ k_kbd_r2_lett
Letters in letters row 2.
static void internal_row_punct(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *f, int32_t y, int32_t rh, uint8_t tog_aux)
Build row 2 for the numbers or symbols layer: layer-toggle, punctuation, backspace.
static void internal_append(ra8_kbd_text_t *t, char ch)
Append character ch to the text buffer if capacity allows.
ra8_err_t ra8_kbd_layout_init(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *frame)
Lay the letters layer into frame; clear SHIFT.
static void internal_build_layer(ra8_kbd_layout_t *kb)
Rebuild the key grid for the active layer stored in kb->layer.
static int32_t internal_hx(const ra8_ui_rect_t *f, int32_t hu)
Compute the pixel X coordinate for a given half-unit offset within a frame.
static const char s_punct[]
char ra8_kbd_key_glyph(const ra8_kbd_layout_t *kb, uint8_t key_idx)
Effective character a char key emits given the live SHIFT state.
static const char s_l_r1_hi[]
static const char s_l_r0_lo[]
static const char s_s_r1[]
static const char s_n_r1[]
static void internal_span(ra8_kbd_layout_t *kb, int32_t a, int32_t b, const ra8_ui_rect_t *f, int32_t y, int32_t rh, ra8_kbd_key_kind_t kind, uint8_t aux)
Append one special key that spans half-units [a, b).
On-screen keyboard widget – iOS-style layers, shift, hit-test.
ra8_kbd_key_kind_t
What a key does when tapped.
@ k_ra8_kbd_key_space
Append a space.
@ k_ra8_kbd_key_layer
Switch to the layer in aux.
@ k_ra8_kbd_key_enter
Commit the query (RETURN).
@ k_ra8_kbd_key_char
Append the shift-correct char.
@ k_ra8_kbd_key_shift
Toggle the one-shot SHIFT.
@ k_ra8_kbd_key_backspace
Delete the last char.
@ k_ra8_kbd_layer_symbols
Brackets / math symbols (#+=).
@ k_ra8_kbd_layer_letters
QWERTY letters (with one-shot SHIFT).
@ k_ra8_kbd_layer_numbers
Digits + common symbols (123).
@ k_ra8_kbd_rows
Key rows per layer.
@ k_ra8_kbd_max_keys
Key-rect slots (<= 31 used per layer).
@ k_ra8_kbd_no_hit
ra8_kbd_hit "no key" sentinel.
@ k_ra8_kbd_text_max
Text buffer capacity incl.
Bounded UI interaction core: hit-testing, screen stack, paging.
bool ra8_ui_rect_contains(const ra8_ui_rect_t *r, int32_t px, int32_t py)
Test whether a point lies inside a rectangle.
One key: a hit rectangle, its unshifted + shifted chars, a kind, and (for layer keys) the target laye...
uint8_t aux
Target ra8_kbd_layer_t for a layer key.
char ch_lower
Unshifted char (char keys); 0 else.
ra8_kbd_key_kind_t kind
Key behaviour.
ra8_ui_rect_t rect
Hit / draw rectangle.
char ch_upper
Shifted char (char keys); 0 else.
The key grid for the active layer, plus SHIFT / layer / frame state.
ra8_kbd_key_t keys[k_ra8_kbd_max_keys]
Keys for the active layer.
uint8_t count
Keys in use.
uint8_t layer
Active ra8_kbd_layer_t.
bool shift
One-shot SHIFT armed.
ra8_ui_rect_t frame
Saved frame (re-lay on swap).
The typed query buffer + commit state.
char buf[k_ra8_kbd_text_max]
NUL-terminated query.
uint8_t len
Chars before the NUL.
bool committed
RETURN was applied.
Axis-aligned rectangle in framebuffer pixel coordinates.
int32_t w
Width (pixels, >= 0).
int32_t h
Height (pixels, >= 0).
int32_t x
Left edge (pixels).
int32_t y
Top edge (pixels).