Compile fixes

This commit is contained in:
Ken Van Hoeylandt 2026-08-22 23:23:36 +02:00
parent 5707c27882
commit 670d6ab062
2 changed files with 7 additions and 19 deletions

View File

@ -45,21 +45,21 @@ static constexpr int CARDPUTER_ADV_COLS = 14;
// emits nothing (used for the sym/shift cells themselves, and unwired cells on this board).
static const uint32_t cardputer_adv_keymap_lc[CARDPUTER_ADV_ROWS][CARDPUTER_ADV_COLS] = {
{ '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', CODEPOINT_BACKSPACE },
{ CODEPOINT_TAB, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\' },
{ '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\' },
{ 0, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', CODEPOINT_ENTER },
{ 0, 0, 0, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', ' ' },
};
static const uint32_t cardputer_adv_keymap_uc[CARDPUTER_ADV_ROWS][CARDPUTER_ADV_COLS] = {
{ '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', CODEPOINT_DELETE },
{ CODEPOINT_FOCUS_PREV, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '|' },
{ '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '|' },
{ 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', CODEPOINT_ENTER },
{ 0, 0, 0, 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', ' ' },
};
static const uint32_t cardputer_adv_keymap_sym[CARDPUTER_ADV_ROWS][CARDPUTER_ADV_COLS] = {
{ CODEPOINT_ESCAPE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ CODEPOINT_TAB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CODEPOINT_ARROW_UP, 0, CODEPOINT_ENTER },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CODEPOINT_ARROW_LEFT, CODEPOINT_ARROW_DOWN, CODEPOINT_ARROW_RIGHT, 0 },
};

View File

@ -29,15 +29,12 @@ static constexpr int CARDPUTER_PENDING_CAPACITY = 2;
enum CardputerKeyRole {
CARDPUTER_KEY_CHAR,
CARDPUTER_KEY_TAB,
CARDPUTER_KEY_FN,
CARDPUTER_KEY_SHIFT,
CARDPUTER_KEY_CTRL,
CARDPUTER_KEY_OPT,
CARDPUTER_KEY_ALT,
CARDPUTER_KEY_DEL,
CARDPUTER_KEY_ENTER,
CARDPUTER_KEY_SPACE,
};
struct CardputerKeyDef {
@ -54,12 +51,12 @@ struct CardputerKeyDef {
static const CardputerKeyDef cardputer_key_map[CARDPUTER_ROWS][CARDPUTER_COLS] = {
{ K('`', '~'), K('1', '!'), K('2', '@'), K('3', '#'), K('4', '$'), K('5', '%'), K('6', '^'),
K('7', '&'), K('8', '*'), K('9', '('), K('0', ')'), K('-', '_'), K('=', '+'), { CARDPUTER_KEY_DEL, 0, 0 } },
{ { CARDPUTER_KEY_TAB, 0, 0 }, K('q', 'Q'), K('w', 'W'), K('e', 'E'), K('r', 'R'), K('t', 'T'), K('y', 'Y'),
{ K('\t', '\t'), K('q', 'Q'), K('w', 'W'), K('e', 'E'), K('r', 'R'), K('t', 'T'), K('y', 'Y'),
K('u', 'U'), K('i', 'I'), K('o', 'O'), K('p', 'P'), K('[', '{'), K(']', '}'), K('\\', '|') },
{ { CARDPUTER_KEY_FN, 0, 0 }, { CARDPUTER_KEY_SHIFT, 0, 0 }, K('a', 'A'), K('s', 'S'), K('d', 'D'), K('f', 'F'), K('g', 'G'),
K('h', 'H'), K('j', 'J'), K('k', 'K'), K('l', 'L'), K(';', ':'), K('\'', '"'), { CARDPUTER_KEY_ENTER, 0, 0 } },
K('h', 'H'), K('j', 'J'), K('k', 'K'), K('l', 'L'), K(';', ':'), K('\'', '"'), K(0x10, 0x10) },
{ { CARDPUTER_KEY_CTRL, 0, 0 }, { CARDPUTER_KEY_OPT, 0, 0 }, { CARDPUTER_KEY_ALT, 0, 0 }, K('z', 'Z'), K('x', 'X'), K('c', 'C'), K('v', 'V'),
K('b', 'B'), K('n', 'N'), K('m', 'M'), K(',', '<'), K('.', '>'), K('/', '?'), { CARDPUTER_KEY_SPACE, 0, 0 } },
K('b', 'B'), K('n', 'N'), K('m', 'M'), K(',', '<'), K('.', '>'), K('/', '?'), K(' ', ' ') },
};
#undef K
@ -201,7 +198,7 @@ static uint8_t read_input(CardputerKeyboardInternal* internal) {
// reported themselves.
static uint32_t scan_key(CardputerKeyboardInternal* internal) {
bool fn = false, shift = false, ctrl = false;
bool del_flag = false, enter_flag = false, space_flag = false;
bool del_flag = false;
bool has_regular = false;
char regular_normal = 0, regular_shifted = 0;
@ -238,12 +235,6 @@ static uint32_t scan_key(CardputerKeyboardInternal* internal) {
case CARDPUTER_KEY_DEL:
del_flag = true;
break;
case CARDPUTER_KEY_ENTER:
enter_flag = true;
break;
case CARDPUTER_KEY_SPACE:
space_flag = true;
break;
case CARDPUTER_KEY_CHAR:
if (!has_regular) {
has_regular = true;
@ -258,8 +249,6 @@ static uint32_t scan_key(CardputerKeyboardInternal* internal) {
char resolved_char = has_regular ? ((ctrl || shift) ? regular_shifted : regular_normal) : 0;
if (!fn) {
if (enter_flag) return CODEPOINT_ENTER;
if (space_flag) return (uint32_t)' ';
if (del_flag) return CODEPOINT_BACKSPACE;
if (has_regular) return (uint32_t)resolved_char;
return 0;
@ -269,7 +258,6 @@ static uint32_t scan_key(CardputerKeyboardInternal* internal) {
// rather than arrow codepoints so widgets like lv_switch that toggle on arrow keys aren't
// affected).
if (del_flag) return CODEPOINT_DELETE;
if (enter_flag) return CODEPOINT_ENTER;
if (has_regular) {
switch (resolved_char) {
case '`': return CODEPOINT_ESCAPE;