From ba9f12810f7dc4969ac175f6e959d5fe6407747d Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 30 Dec 2024 18:22:41 +0100 Subject: feat(treewide): Migrate the Unicode handling to a custom c program, that works via rawhid --- src/keymaps/soispha/hid/hid.c | 47 +++++++++++++++++++++++++++++++++++++++++++ src/keymaps/soispha/hid/hid.h | 9 +++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/keymaps/soispha/hid/hid.c create mode 100644 src/keymaps/soispha/hid/hid.h (limited to 'src/keymaps/soispha/hid') diff --git a/src/keymaps/soispha/hid/hid.c b/src/keymaps/soispha/hid/hid.c new file mode 100644 index 0000000..73b7370 --- /dev/null +++ b/src/keymaps/soispha/hid/hid.c @@ -0,0 +1,47 @@ +#include "hid.h" +#include "raw_hid.h" +#include +#include + +void hid_send(uint32_t hex) { + uint8_t length = 32; + + uint8_t response[length]; + memset(response, 0, length); + + uint8_t first, second, third, fourth; + + uint8_t n = 1; + if (*(char *)&n == 1) { + // Little endian + first = (uint8_t)hex; + second = (uint8_t)(hex >> 8); + third = (uint8_t)(hex >> 16); + fourth = (uint8_t)(hex >> 24); + } else { + // Big endian + fourth = (uint8_t)hex; + third = (uint8_t)(hex << 8); + second = (uint8_t)(hex << 16); + first = (uint8_t)(hex << 24); + } + + response[0] = first; + response[1] = second; + response[2] = third; + response[3] = fourth; + + raw_hid_send(response, length); +} + +// `data` is a pointer to the buffer containing the received HID report +// `length` is the length of the report - always `RAW_EPSIZE` +void raw_hid_receive(uint8_t *data, uint8_t length) { + uint8_t response[length]; + memset(response, 0, length); + response[0] = 'B'; + + if (data[0] == 'A') { + raw_hid_send(response, length); + } +} diff --git a/src/keymaps/soispha/hid/hid.h b/src/keymaps/soispha/hid/hid.h new file mode 100644 index 0000000..6ee0eda --- /dev/null +++ b/src/keymaps/soispha/hid/hid.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#define UK(c) (UK_UNICODE | (c)) + + + +void hid_send(uint32_t hex); -- cgit 1.4.1