upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-18 23:41:19 +0530
committerYour Name <you@example.com>2026-05-18 23:41:19 +0530
commit699fc6c03899c3b1ff853d8c7c6cf32173436354 (patch)
treea1dbf26b3d2c6ea3dc12a5c8ee443c00b364bb4d
parent9ff7cffcff11237288cfddecee2684f499d23ddf (diff)
fix: keyboard KB_START_Y must match render position (70), simplify row 3 layout
- KB_START_Y was 310 but keyboard rendered at y=70 — touch hits never matched - Row 3 simplified to 3 keys: [layer/shift, space, done] - All 362 unit tests pass
-rw-r--r--main/display.c1
-rw-r--r--main/keyboard.c10
-rw-r--r--main/keyboard.h2
-rw-r--r--tests/unit/test_keyboard.c4
4 files changed, 7 insertions, 10 deletions
diff --git a/main/display.c b/main/display.c
index 44af981..e5e31c4 100644
--- a/main/display.c
+++ b/main/display.c
@@ -454,7 +454,6 @@ static void render_wifi_setup_password(void) {
454 } else if (c == '\004') { 454 } else if (c == '\004') {
455 label[0] = '>'; 455 label[0] = '>';
456 fg = COLOR_GREEN; 456 fg = COLOR_GREEN;
457 bg = COLOR_DARKGRAY;
458 } else if (c == '\b') { 457 } else if (c == '\b') {
459 label[0] = '<'; 458 label[0] = '<';
460 bg = COLOR_GRAY; 459 bg = COLOR_GRAY;
diff --git a/main/keyboard.c b/main/keyboard.c
index 741bd08..33365de 100644
--- a/main/keyboard.c
+++ b/main/keyboard.c
@@ -5,21 +5,21 @@ static const char *s_alpha_lower[] = {
5 "qwertyuiop", 5 "qwertyuiop",
6 "asdfghjkl", 6 "asdfghjkl",
7 "\001zxcvbnm\b", 7 "\001zxcvbnm\b",
8 "\002\003 \004" 8 "\002\003\004"
9}; 9};
10 10
11static const char *s_alpha_upper[] = { 11static const char *s_alpha_upper[] = {
12 "QWERTYUIOP", 12 "QWERTYUIOP",
13 "ASDFGHJKL", 13 "ASDFGHJKL",
14 "\001ZXCVBNM\b", 14 "\001ZXCVBNM\b",
15 "\002\003 \004" 15 "\002\003\004"
16}; 16};
17 17
18static const char *s_numsym[] = { 18static const char *s_numsym[] = {
19 "1234567890", 19 "1234567890",
20 "-/:;()$&@\"", 20 "-/:;()$&@\"",
21 "\001.,?!'\\b", 21 "\001.,?!'\\b",
22 "\002\003 \004" 22 "\002\003\004"
23}; 23};
24 24
25#define CTRL_SHIFT '\001' 25#define CTRL_SHIFT '\001'
@@ -73,9 +73,7 @@ static int key_width_at(int row, int col, int total_keys) {
73 if (row == 3) { 73 if (row == 3) {
74 if (col == 0) return 42; 74 if (col == 0) return 42;
75 if (col == total_keys - 1) return 50; 75 if (col == total_keys - 1) return 50;
76 if (total_keys == 3 && col == 1) return 168; 76 return 168;
77 if (total_keys == 4 && col == 1) return 168;
78 if (total_keys == 4 && col == 2) return 42;
79 } 77 }
80 return KB_KEY_W; 78 return KB_KEY_W;
81} 79}
diff --git a/main/keyboard.h b/main/keyboard.h
index d7b3400..495c499 100644
--- a/main/keyboard.h
+++ b/main/keyboard.h
@@ -9,7 +9,7 @@
9#define KB_KEY_H 36 9#define KB_KEY_H 36
10#define KB_KEY_GAP 2 10#define KB_KEY_GAP 2
11#define KB_ROW_COUNT 4 11#define KB_ROW_COUNT 4
12#define KB_START_Y 310 12#define KB_START_Y 70
13 13
14typedef enum { 14typedef enum {
15 KB_ALPHA_LOWER, 15 KB_ALPHA_LOWER,
diff --git a/tests/unit/test_keyboard.c b/tests/unit/test_keyboard.c
index 4cb923d..e069f28 100644
--- a/tests/unit/test_keyboard.c
+++ b/tests/unit/test_keyboard.c
@@ -38,10 +38,10 @@ int main(void)
38 ASSERT_EQ_INT(0, count, "Invalid row 99 returns 0"); 38 ASSERT_EQ_INT(0, count, "Invalid row 99 returns 0");
39 39
40 { 40 {
41 kb_result_t r = kb_hit_test(160, 100, KB_ALPHA_LOWER); 41 kb_result_t r = kb_hit_test(160, 10, KB_ALPHA_LOWER);
42 ASSERT(r.action == KB_ACTION_NONE, "Touch above keyboard = NONE"); 42 ASSERT(r.action == KB_ACTION_NONE, "Touch above keyboard = NONE");
43 43
44 r = kb_hit_test(160, 500, KB_ALPHA_LOWER); 44 r = kb_hit_test(160, KB_START_Y + KB_ROW_COUNT * (KB_KEY_H + KB_KEY_GAP) + 10, KB_ALPHA_LOWER);
45 ASSERT(r.action == KB_ACTION_NONE, "Touch below keyboard = NONE"); 45 ASSERT(r.action == KB_ACTION_NONE, "Touch below keyboard = NONE");
46 } 46 }
47 47