diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-30 18:22:41 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-30 18:22:41 +0100 |
commit | ba9f12810f7dc4969ac175f6e959d5fe6407747d (patch) | |
tree | f4039e46985d56bac471bd8568f96b159a92b2ae /src | |
parent | feat(src): Make usable (diff) | |
download | qmk_layout-ba9f12810f7dc4969ac175f6e959d5fe6407747d.zip |
feat(treewide): Migrate the Unicode handling to a custom c program, that works via rawhid
Diffstat (limited to 'src')
-rw-r--r-- | src/keymaps/soispha/config.h | 3 | ||||
-rw-r--r-- | src/keymaps/soispha/hid/hid.c | 47 | ||||
-rw-r--r-- | src/keymaps/soispha/hid/hid.h | 9 | ||||
-rw-r--r-- | src/keymaps/soispha/keymap.c | 9 | ||||
-rw-r--r-- | src/keymaps/soispha/layout/keymap.h | 2 | ||||
-rw-r--r-- | src/keymaps/soispha/layout/layout.h | 1 | ||||
-rw-r--r-- | src/keymaps/soispha/macros.h | 2 | ||||
-rw-r--r-- | src/keymaps/soispha/rules.mk | 8 |
8 files changed, 76 insertions, 5 deletions
diff --git a/src/keymaps/soispha/config.h b/src/keymaps/soispha/config.h index 2b1d36a..9cc7cc5 100644 --- a/src/keymaps/soispha/config.h +++ b/src/keymaps/soispha/config.h @@ -23,7 +23,8 @@ #define USB_SUSPEND_WAKEUP_DELAY 0 #define LAYER_STATE_16BIT -#define UNICODE_SELECTED_MODES UNICODE_MODE_LINUX +#define RAW_USAGE_PAGE 0xFF61 // 65377 +#define RAW_USAGE_ID 0x6A // 106 #define MOUSEKEY_DELAY 0 #define MOUSEKEY_INTERVAL 20 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 <stdint.h> +#include <string.h> + +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 <stdint.h> + +#define UK(c) (UK_UNICODE | (c)) + + + +void hid_send(uint32_t hex); diff --git a/src/keymaps/soispha/keymap.c b/src/keymaps/soispha/keymap.c index 9391212..2b6c16f 100644 --- a/src/keymaps/soispha/keymap.c +++ b/src/keymaps/soispha/keymap.c @@ -13,6 +13,9 @@ #include "layout/layout.h" #include "macros.h" #include "version.h" +#include <stdbool.h> +#include <stdint.h> +#include "hid/hid.h" bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { @@ -21,6 +24,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " (rev: " QMK_GIT_HASH ")"); } + return false; break; case ST_MACRO_0: if (record->event.pressed) { @@ -77,6 +81,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; } + + if (keycode >= UK_UNICODE && keycode <= UK_UNICODE_MAX) { + hid_send(QK_UNICODE_GET_CODE_POINT(keycode)); + } + return true; } diff --git a/src/keymaps/soispha/layout/keymap.h b/src/keymaps/soispha/layout/keymap.h index d4b183a..f61ac0f 100644 --- a/src/keymaps/soispha/layout/keymap.h +++ b/src/keymaps/soispha/layout/keymap.h @@ -83,7 +83,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [9] = LAYOUT_moonlander( // Special characters KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, - KK_TP, UC(0x201C), KK_TP, KK_TP, UC(0x201D), KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, + KK_TP, UK(0x201C), KK_TP, KK_TP, UK(0x201D), KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP, KK_TP diff --git a/src/keymaps/soispha/layout/layout.h b/src/keymaps/soispha/layout/layout.h index 4acb7f5..6b0c709 100644 --- a/src/keymaps/soispha/layout/layout.h +++ b/src/keymaps/soispha/layout/layout.h @@ -13,6 +13,7 @@ #pragma once #include QMK_KEYBOARD_H #include "../macros.h" +#include "../hid/hid.h" #define KK_TP KC_TRANSPARENT diff --git a/src/keymaps/soispha/macros.h b/src/keymaps/soispha/macros.h index e337830..ff03175 100644 --- a/src/keymaps/soispha/macros.h +++ b/src/keymaps/soispha/macros.h @@ -15,6 +15,8 @@ enum custom_keycodes { ST_MACRO_6, ST_MACRO_7, VERSION_NUMBER, + UK_UNICODE = 0x8000, + UK_UNICODE_MAX = 0xFFFF, }; enum tap_dance_codes { diff --git a/src/keymaps/soispha/rules.mk b/src/keymaps/soispha/rules.mk index c04c2d7..27610b4 100644 --- a/src/keymaps/soispha/rules.mk +++ b/src/keymaps/soispha/rules.mk @@ -24,8 +24,10 @@ SEND_STRING_ENABLE = yes SPACE_CADET_ENABLE = no SWAP_HANDS_ENABLE = yes TAP_DANCE_ENABLE = yes +UNICODE_ENABLE = no -UNICODE_COMMON = yes -UNICODE_ENABLE = yes +RAW_ENABLE = yes -SRC += rgb.c +# LTO_ENABLE = yes + +SRC += rgb.c hid/hid.c |