From 73bea6218e6681c62a4cbe32f6dd1394f242fa66 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 15 May 2020 09:41:06 -0400 Subject: Some initial BEL HoG support. --- src/hid.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/hid.c (limited to 'src/hid.c') diff --git a/src/hid.c b/src/hid.c new file mode 100644 index 0000000..8c42df5 --- /dev/null +++ b/src/hid.c @@ -0,0 +1,56 @@ +#include "hid.h" + +static struct zmk_hid_report report = { + .modifiers = 0, + .keys = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + +#define KEY_OFFSET 0x02 +#define MAX_KEYS 6 + +/* +#define TOGGLE_BOOT_KEY(match, val) \ + for (int idx = 0; idx < MAX_KEYS; idx++) \ + { \ + if (report.boot.keys[idx + KEY_OFFSET] != match) \ + { \ + continue; \ + } \ + report.boot.keys[idx + KEY_OFFSET] = val; \ + break; \ + } +*/ + +#define TOGGLE_KEY(code, val) WRITE_BIT(report.keys[code / 8], code % 8, val) + +int zmk_hid_press_key(zmk_key code) +{ + if (code > ZMK_HID_MAX_KEYCODE) + { + return -EINVAL; + } + + // TOGGLE_BOOT_KEY(0U, code); + + TOGGLE_KEY(code, true); + + return 0; +}; + +int zmk_hid_release_key(zmk_key code) +{ + if (code > ZMK_HID_MAX_KEYCODE) + { + return -EINVAL; + } + + // TOGGLE_BOOT_KEY(code, 0U); + + TOGGLE_KEY(code, false); + + return 0; +}; + +struct zmk_hid_report *zmk_hid_get_report() +{ + return &report; +} \ No newline at end of file -- cgit v1.2.3