summaryrefslogtreecommitdiff
path: root/app/src/kscan.c
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-06-20 17:54:52 -0400
committerPete Johanson <peter@peterjohanson.com>2020-06-20 17:54:52 -0400
commit7e659851c80bf2819554d93ad9971f56aa5b225b (patch)
treeb0d2ee4784741cbcd3e109b71230502d87691e1b /app/src/kscan.c
parentd65629b9a0b79b6e294419fe9a4118fb09491c91 (diff)
Refactor matrix transform, positions pervasively
* Do mapping to positions right in kscan handler, and then surface positions throughout the API.
Diffstat (limited to 'app/src/kscan.c')
-rw-r--r--app/src/kscan.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/app/src/kscan.c b/app/src/kscan.c
index 781824d..29a6019 100644
--- a/app/src/kscan.c
+++ b/app/src/kscan.c
@@ -11,8 +11,8 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
+#include <zmk/matrix_transform.h>
#include <zmk/events.h>
-#include <zmk/handlers.h>
#define ZMK_KSCAN_EVENT_STATE_PRESSED 0
#define ZMK_KSCAN_EVENT_STATE_RELEASED 1
@@ -49,19 +49,13 @@ void zmk_kscan_process_msgq(struct k_work *item)
while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0)
{
bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED);
+ u32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column);
+ LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position, (pressed ? "true" : "false"));
if (pressed) {
- LOG_DBG("PRESSING");
- zmk_events_position_pressed(ev.row, ev.column);
+ zmk_events_position_pressed(position);
} else {
- LOG_DBG("RELEASSING");
- zmk_events_position_released(ev.row, ev.column);
+ zmk_events_position_released(position);
}
- // zmk_keymap_position_state_changed(ev.row, ev.column, pressed);
- // zmk_key key = zmk_keymap_keycode_from_position(ev.row, ev.column);
- // struct zmk_key_event kev = (struct zmk_key_event){.row = ev.row, .column = ev.column, .key = key, .pressed = pressed};
-
- // LOG_DBG("Row: %d, col: %d, key: %d, pressed: %s\n", ev.row, ev.column, key, (pressed ? "true" : "false"));
- // zmk_handle_key(kev);
}
}