fix compose bug

This commit is contained in:
Charlotte 🦝 Delenk 2023-02-22 15:49:36 +01:00
parent c22f25a597
commit d7aeb6cc5d
11 changed files with 36291 additions and 36244 deletions

View file

@ -11,7 +11,7 @@
#define MATRIX_COLS 6
#define DEBUG_MATRIX_SCAN_RATE
#define UNICODE_SELECTED_MODES UC_LNX, UC_MAC, UC_WINC
#define UNICODE_SELECTED_MODES UNICODE_MODE_LINUX, UNICODE_MODE_MACOS, UNICODE_MODE_WINCOMPOSE, UNICODE_MODE_EMACS
#define OLED_DISPLAY_128X64

View file

@ -55,7 +55,7 @@ static const compose_edge_t *findEdge(uint16_t keycode) {
if (keycode < 256) {
match2 = 0xD800 + keycode;
print("(low keycode)\n");
} else if(keycode == KC_LEAD) {
} else if (keycode == QK_LEAD) {
match2 = 0xD800;
print("(leader key)\n");
}
@ -74,8 +74,7 @@ static const compose_edge_t *findEdge(uint16_t keycode) {
static size_t charcount_utf8(const char *s) {
size_t n = 0;
while (*s)
if((*(s++) & 0xC0) != 0x80)
n++; // only count non-continuation characters
if ((*(s++) & 0xC0) != 0x80) n++; // only count non-continuation characters
return n;
}
@ -93,19 +92,17 @@ static void transEdge(const compose_edge_t *edge) {
static bool isCombining(uint32_t uc) {
// yes it is not all of them, but all of them that matter for us
if(uc >= 0x300 && uc < 0x370)
return true;
if(uc == 0x20d7)
return true;
if (uc >= 0x300 && uc < 0x370) return true;
if (uc == 0x20d7) return true;
return false;
}
void process_compose(uint16_t keycode, keyrecord_t *record) {
if(!record->event.pressed)
return;
if (!record->event.pressed) return;
uint32_t uc = keystroke_to_unicode(keycode);
const compose_edge_t *edge = findEdge(keycode);
if (edge == NULL && uc != 0) { // no matching edge found, reset and try again
uprintf("uc: %ld", uc);
print("No matching edge found, reset.\n");
resetState();
edge = findEdge(keycode);
@ -118,7 +115,7 @@ void process_compose(uint16_t keycode, keyrecord_t *record) {
if (isCombining(uc)) {
print("keycode refers to deadkey, writing space\n");
tap_code(KC_SPACE);
} else if(keycode == KC_LEAD) {
} else if (keycode == QK_LEAD) {
print("keycode refers to leader key, writing compose symbol\n");
send_unicode_string("");
}

View file

@ -1,5 +1,6 @@
const uint16_t keycode_to_char[][6] = {
[KC_SPACE] = {
[KC_SPACE] =
{
0x20,
0x0,
0x0,
@ -7,7 +8,8 @@ const uint16_t keycode_to_char[][6] = {
0xa0,
0x202f,
},
[KC_Y] = {
[KC_Y] =
{
0x6b,
0x4b,
0x21,
@ -15,7 +17,8 @@ const uint16_t keycode_to_char[][6] = {
0x3ba,
0xd7,
},
[KC_COMM] = {
[KC_COMM] =
{
0x0,
0x2013,
0x22,
@ -23,7 +26,8 @@ const uint16_t keycode_to_char[][6] = {
0x3f1,
0x21d2,
},
[KC_Z] = {
[KC_Z] =
{
0xfc,
0xdc,
0x23,
@ -31,7 +35,8 @@ const uint16_t keycode_to_char[][6] = {
0x0,
0x222a,
},
[KC_6] = {
[KC_6] =
{
0x36,
0x24,
0xa2,
@ -39,7 +44,8 @@ const uint16_t keycode_to_char[][6] = {
0x26a5,
0x2225,
},
[KC_X] = {
[KC_X] =
{
0xf6,
0xd6,
0x24,
@ -47,7 +53,8 @@ const uint16_t keycode_to_char[][6] = {
0x3f5,
0x2229,
},
[KC_M] = {
[KC_M] =
{
0x6d,
0x4d,
0x25,
@ -55,7 +62,8 @@ const uint16_t keycode_to_char[][6] = {
0x3bc,
0x21d4,
},
[KC_P0] = {
[KC_P0] =
{
0x30,
0x2423,
0x25,
@ -63,7 +71,8 @@ const uint16_t keycode_to_char[][6] = {
0x2030,
0x25a1,
},
[KC_P] = {
[KC_P] =
{
0x71,
0x51,
0x26,
@ -71,7 +80,8 @@ const uint16_t keycode_to_char[][6] = {
0x3d5,
0x211a,
},
[KC_DOT] = {
[KC_DOT] =
{
0x2e,
0x2022,
0x27,
@ -79,7 +89,8 @@ const uint16_t keycode_to_char[][6] = {
0x3d1,
0x21a6,
},
[KC_J] = {
[KC_J] =
{
0x6e,
0x4e,
0x28,
@ -87,7 +98,8 @@ const uint16_t keycode_to_char[][6] = {
0x3bd,
0x2115,
},
[KC_K] = {
[KC_K] =
{
0x72,
0x52,
0x29,
@ -95,7 +107,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c1,
0x211d,
},
[KC_KP_ASTERISK] = {
[KC_KP_ASTERISK] =
{
0x2a,
0x2a,
0x22c5,
@ -103,7 +116,8 @@ const uint16_t keycode_to_char[][6] = {
0x2299,
0x2297,
},
[KC_G] = {
[KC_G] =
{
0x6f,
0x4f,
0x2a,
@ -111,7 +125,8 @@ const uint16_t keycode_to_char[][6] = {
0x3bf,
0x2208,
},
[KC_0] = {
[KC_0] =
{
0x30,
0x201d,
0x2019,
@ -119,7 +134,8 @@ const uint16_t keycode_to_char[][6] = {
0x2080,
0x2205,
},
[KC_KP_PLUS] = {
[KC_KP_PLUS] =
{
0x2b,
0x2b,
0xb1,
@ -127,7 +143,8 @@ const uint16_t keycode_to_char[][6] = {
0x2295,
0x2214,
},
[KC_N] = {
[KC_N] =
{
0x62,
0x42,
0x2b,
@ -135,7 +152,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b2,
0x21d0,
},
[KC_KP_DOT] = {
[KC_KP_DOT] =
{
0x2c,
0x2e,
0x2c,
@ -143,7 +161,8 @@ const uint16_t keycode_to_char[][6] = {
0x2032,
0x2033,
},
[KC_SCLN] = {
[KC_SCLN] =
{
0x64,
0x44,
0x3a,
@ -151,7 +170,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b4,
0x394,
},
[KC_MINS] = {
[KC_MINS] =
{
0x2d,
0x2014,
0x0,
@ -159,7 +179,8 @@ const uint16_t keycode_to_char[][6] = {
0x2011,
0xad,
},
[KC_KP_MINUS] = {
[KC_KP_MINUS] =
{
0x2d,
0x2d,
0x2212,
@ -167,7 +188,8 @@ const uint16_t keycode_to_char[][6] = {
0x2296,
0x2238,
},
[KC_L] = {
[KC_L] =
{
0x74,
0x54,
0x2d,
@ -175,7 +197,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c4,
0x2202,
},
[KC_QUOT] = {
[KC_QUOT] =
{
0x79,
0x59,
0x40,
@ -183,7 +206,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c5,
0x2207,
},
[KC_KP_SLASH] = {
[KC_KP_SLASH] =
{
0x2f,
0x2f,
0xf7,
@ -191,7 +215,8 @@ const uint16_t keycode_to_char[][6] = {
0x2300,
0x2223,
},
[KC_S] = {
[KC_S] =
{
0x69,
0x49,
0x2f,
@ -199,7 +224,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b9,
0x222b,
},
[KC_9] = {
[KC_9] =
{
0x39,
0x201c,
0x2018,
@ -207,7 +233,8 @@ const uint16_t keycode_to_char[][6] = {
0x27e9,
0x221d,
},
[KC_1] = {
[KC_1] =
{
0x31,
0xb0,
0xb9,
@ -215,7 +242,8 @@ const uint16_t keycode_to_char[][6] = {
0x2081,
0xac,
},
[KC_P1] = {
[KC_P1] =
{
0x31,
0x2666,
0x2194,
@ -223,7 +251,8 @@ const uint16_t keycode_to_char[][6] = {
0x2264,
0x230a,
},
[KC_2] = {
[KC_2] =
{
0x32,
0xa7,
0xb2,
@ -231,7 +260,8 @@ const uint16_t keycode_to_char[][6] = {
0x2082,
0x2228,
},
[KC_P2] = {
[KC_P2] =
{
0x32,
0x2665,
0x2193,
@ -239,7 +269,8 @@ const uint16_t keycode_to_char[][6] = {
0x222a,
0x22c3,
},
[KC_3] = {
[KC_3] =
{
0x33,
0x2113,
0xb3,
@ -247,7 +278,8 @@ const uint16_t keycode_to_char[][6] = {
0x2083,
0x2227,
},
[KC_P3] = {
[KC_P3] =
{
0x33,
0x2660,
0x21cc,
@ -255,7 +287,8 @@ const uint16_t keycode_to_char[][6] = {
0x2265,
0x230b,
},
[KC_4] = {
[KC_4] =
{
0x34,
0xbb,
0x203a,
@ -263,7 +296,8 @@ const uint16_t keycode_to_char[][6] = {
0x2640,
0x22a5,
},
[KC_P4] = {
[KC_P4] =
{
0x34,
0x2663,
0x2190,
@ -271,7 +305,8 @@ const uint16_t keycode_to_char[][6] = {
0x2282,
0x2286,
},
[KC_5] = {
[KC_5] =
{
0x35,
0xab,
0x2039,
@ -279,7 +314,8 @@ const uint16_t keycode_to_char[][6] = {
0x2642,
0x2221,
},
[KC_P5] = {
[KC_P5] =
{
0x35,
0x20ac,
0x3a,
@ -287,7 +323,8 @@ const uint16_t keycode_to_char[][6] = {
0x22b6,
0x22b7,
},
[KC_P6] = {
[KC_P6] =
{
0x36,
0x2023,
0x2192,
@ -295,7 +332,8 @@ const uint16_t keycode_to_char[][6] = {
0x2283,
0x2287,
},
[KC_7] = {
[KC_7] =
{
0x37,
0x20ac,
0xa5,
@ -303,7 +341,8 @@ const uint16_t keycode_to_char[][6] = {
0x3f0,
0x2192,
},
[KC_P7] = {
[KC_P7] =
{
0x37,
0x2714,
0x2195,
@ -311,7 +350,8 @@ const uint16_t keycode_to_char[][6] = {
0x226a,
0x2308,
},
[KC_U] = {
[KC_U] =
{
0x68,
0x48,
0x3c,
@ -319,7 +359,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c8,
0x3a8,
},
[KC_8] = {
[KC_8] =
{
0x38,
0x201e,
0x201a,
@ -327,7 +368,8 @@ const uint16_t keycode_to_char[][6] = {
0x27e8,
0x221e,
},
[KC_P8] = {
[KC_P8] =
{
0x38,
0x2718,
0x2191,
@ -335,7 +377,8 @@ const uint16_t keycode_to_char[][6] = {
0x2229,
0x22c2,
},
[KC_I] = {
[KC_I] =
{
0x67,
0x47,
0x3e,
@ -343,7 +386,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b3,
0x393,
},
[KC_P9] = {
[KC_P9] =
{
0x39,
0x2020,
0x0,
@ -351,7 +395,8 @@ const uint16_t keycode_to_char[][6] = {
0x226b,
0x2309,
},
[KC_O] = {
[KC_O] =
{
0x66,
0x46,
0x3d,
@ -359,7 +404,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c6,
0x3a6,
},
[KC_SLSH] = {
[KC_SLSH] =
{
0x6a,
0x4a,
0x3b,
@ -367,7 +413,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b8,
0x398,
},
[KC_NUM_LOCK] = {
[KC_NUM_LOCK] =
{
0x0,
0x0,
0x3d,
@ -375,7 +422,8 @@ const uint16_t keycode_to_char[][6] = {
0x2248,
0x2261,
},
[KC_H] = {
[KC_H] =
{
0x73,
0x53,
0x3f,
@ -383,7 +431,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c3,
0x3a3,
},
[KC_E] = {
[KC_E] =
{
0x6c,
0x4c,
0x5b,
@ -391,7 +440,8 @@ const uint16_t keycode_to_char[][6] = {
0x3bb,
0x39b,
},
[KC_A] = {
[KC_A] =
{
0x75,
0x55,
0x5c,
@ -399,7 +449,8 @@ const uint16_t keycode_to_char[][6] = {
0x0,
0x2282,
},
[KC_R] = {
[KC_R] =
{
0x63,
0x43,
0x5d,
@ -407,7 +458,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c7,
0x2102,
},
[KC_T] = {
[KC_T] =
{
0x77,
0x57,
0x5e,
@ -415,7 +467,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c9,
0x3a9,
},
[KC_W] = {
[KC_W] =
{
0x76,
0x56,
0x5f,
@ -423,7 +476,8 @@ const uint16_t keycode_to_char[][6] = {
0x0,
0x221a,
},
[KC_B] = {
[KC_B] =
{
0x7a,
0x5a,
0x60,
@ -431,7 +485,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b6,
0x2124,
},
[KC_D] = {
[KC_D] =
{
0x61,
0x41,
0x7b,
@ -439,7 +494,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b1,
0x2200,
},
[KC_C] = {
[KC_C] =
{
0xe4,
0xc4,
0x7c,
@ -447,7 +503,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b7,
0x2135,
},
[KC_F] = {
[KC_F] =
{
0x65,
0x45,
0x7d,
@ -455,7 +512,8 @@ const uint16_t keycode_to_char[][6] = {
0x3b5,
0x2203,
},
[KC_V] = {
[KC_V] =
{
0x70,
0x50,
0x7e,
@ -463,7 +521,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c0,
0x3a0,
},
[KC_LBRC] = {
[KC_LBRC] =
{
0xdf,
0x1e9e,
0x17f,
@ -471,7 +530,8 @@ const uint16_t keycode_to_char[][6] = {
0x3c2,
0x2218,
},
[KC_Q] = {
[KC_Q] =
{
0x78,
0x58,
0x2026,

View file

@ -5,17 +5,7 @@
#include "raw_hid.h"
#include "neo2.h"
#include "compose.h"
enum {
_MAIN,
_NUMPAD,
_PLOVER,
_MOUSE,
_GAMING,
_SYS,
_NAV,
_FN,
_EMPTY
};
enum { _MAIN, _NUMPAD, _PLOVER, _MOUSE, _GAMING, _SYS, _NAV, _FN, _EMPTY };
#define LAYOUT(k0A, k0B, k0C, k0D, k0E, k0F, k5A, k5B, k5C, k5D, k5E, k5F, k1A, k1B, k1C, k1D, k1E, k1F, k6A, k6B, k6C, k6D, k6E, k6F, k2A, k2B, k2C, k2D, k2E, k2F, k7A, k7B, k7C, k7D, k7E, k7F, k3A, k3B, k3C, k3D, k3E, k3F, k8A, k8B, k8C, k8D, k8E, k8F, k4C, k4D, k4E, k4F, k9C, k9D, k9E, k9F) LAYOUT_ortho_4x6_2x2uc(k0A, k0B, k0C, k0D, k0E, k0F, k1A, k1B, k1C, k1D, k1E, k1F, k2A, k2B, k2C, k2D, k2E, k2F, k3A, k3B, k3C, k3D, k3E, k3F, k4C, k4D, k4E, k4F, k5A, k5B, k5C, k5D, k5E, k5F, k6A, k6B, k6C, k6D, k6E, k6F, k7A, k7B, k7C, k7D, k7E, k7F, k8A, k8B, k8C, k8D, k8E, k8F, k9C, k9D, k9E, k9F)
#define STN_PLS STN_NB
@ -27,8 +17,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_MAIN] = LAYOUT(
KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_LBRC,
KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT,
KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , KC_LEAD,
KC_LCTL, KC_LGUI, KC_LALT, KC_NUBS , TT(_FN), _______, KC_LOCK, TG(_PLOVER), KC_RALT , KC_RGUI, KC_APP , KC_RCTL,
KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , QK_LEAD,
KC_LCTL, KC_LGUI, KC_LALT, KC_NUBS , TT(_FN), _______, QK_LOCK, TG(_PLOVER), KC_RALT , KC_RGUI, KC_APP , KC_RCTL,
KC_CAPS, TT(_GAMING), KC_SPC , KC_LSFT, TT(_MOUSE), TT(_NUMPAD), TT(_NAV), TT(_SYS)
),
[_NUMPAD] = LAYOUT(