aboutsummaryrefslogtreecommitdiffstats
path: root/src/hid.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-12-16 20:31:06 +0100
committerLouis Burda <quent.burda@gmail.com>2022-12-16 20:31:06 +0100
commit8e8c972cbec56d8de31847981149cde4a8fc16cd (patch)
tree3f81fbb17a9e8338bf9b70f3e2059da50aebceca /src/hid.c
parentcbb0ac4dac395ea287cf5e7cc211f81aef16e78f (diff)
downloadsxkbd-8e8c972cbec56d8de31847981149cde4a8fc16cd.tar.gz
sxkbd-8e8c972cbec56d8de31847981149cde4a8fc16cd.zip
Add stdio command interface, matrix syncing and basic evaluation
Diffstat (limited to 'src/hid.c')
-rw-r--r--src/hid.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/hid.c b/src/hid.c
index ed4eedd..ea7600c 100644
--- a/src/hid.c
+++ b/src/hid.c
@@ -1,4 +1,10 @@
#include "hid.h"
+#include "split.h"
+#include "matrix.h"
+#include "keysym.h"
+#include "keymap.h"
+
+#include <pico/types.h>
void
hid_init(void)
@@ -6,6 +12,37 @@ hid_init(void)
}
+inline uint
+layer_index(uint x, uint y)
+{
+ if (y < KEY_ROWS)
+ return y * KEY_COLS + x;
+ else
+ return y * KEY_COLS + (KEY_COLS - 1 - x);
+}
+
+bool
+hid_gen_report(uint8_t *report)
+{
+ int keycnt;
+ uint x, y, p;
+
+ keycnt = 0;
+ for (y = 0; y < KEY_ROWS * 2; y++) {
+ for (x = 0; x < KEY_COLS; x++) {
+ if (!state_matrix[y * KEY_COLS + x])
+ continue;
+ if (keycnt >= 6) break;
+ DEBUG("PRESS %i %", x, y);
+ p = layer_index(x, y);
+ report[keycnt] = TO_CODE(keymap_layers_de[0][p]);
+ keycnt++;
+ }
+ }
+
+ return keycnt > 0;
+}
+
void
hid_task(void)
{