Compare commits
1 Commits
main
...
validate-m
Author | SHA1 | Date |
---|---|---|
lif | 40050f0314 |
|
@ -1,8 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p build
|
||||
|
||||
cc test/matrix-valid.c -o build/matrix-valid
|
||||
build/matrix-valid
|
||||
|
||||
export PICO_SDK_PATH=$(pwd)/../../pico-sdk
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -DFAMILY=rp2040 ..
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
#define KBD_COLS 12
|
||||
#define KBD_ROWS 6
|
||||
#define KBD_MATRIX_SZ KBD_COLS * KBD_ROWS + 4
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../src/matrix.h"
|
||||
|
||||
#define WHY_HYPER_RETURN \
|
||||
"Hyper+Return is required both to power on and to enter the keyboard menu.\n"
|
||||
|
||||
#define WHY_X \
|
||||
"Pressing X in the keyboard menu is required to enter bootloader mode.\n" \
|
||||
"(Bootloader mode can be exited by toggling the standby power switch.)\n"
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int hyper_loc = -1;
|
||||
int x_loc = -1;
|
||||
int enter_loc_fn = -1;
|
||||
|
||||
// irrelevant because they're both defined with [KBD_MATRIX_SZ],
|
||||
// but if they were changed not to:
|
||||
if (sizeof(matrix) != sizeof(matrix_fn)) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Layer size mismatch! %zu != %zu\n",
|
||||
sizeof(matrix),
|
||||
sizeof(matrix_fn)
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(matrix); i++) {
|
||||
if (matrix[i] == KEY_COMPOSE) {
|
||||
hyper_loc = i;
|
||||
} else if (matrix[i] == KEY_X) {
|
||||
x_loc = i;
|
||||
}
|
||||
}
|
||||
if (hyper_loc == -1) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"No hyper key (KEY_COMPOSE) found on base layer (matrix)!\n"
|
||||
WHY_HYPER_RETURN
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (x_loc == -1) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"No X key (KEY_X) found on base layer (matrix)!\n"
|
||||
WHY_X
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (matrix_fn[hyper_loc] != KEY_COMPOSE) {
|
||||
for (i = 0; i < sizeof(matrix_fn); i++) {
|
||||
if (matrix_fn[i] == KEY_COMPOSE) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Hyper key (KEY_COMPOSE) in different position on layers! %d != %d\n",
|
||||
hyper_loc,
|
||||
i
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "No hyper key (KEY_COMPOSE) found on hyper layer (matrix_fn)!\n");
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < sizeof(matrix_fn); i++) {
|
||||
if (matrix_fn[i] == KEY_ENTER) {
|
||||
enter_loc_fn = i;
|
||||
}
|
||||
}
|
||||
if (enter_loc_fn == -1) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"No return key (KEY_ENTER) found on hyper layer (matrix_fn)!\n"
|
||||
WHY_HYPER_RETURN
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue