Created
March 25, 2020 01:50
-
-
Save asmand/2da52dc089a006f7e32c4607c163d067 to your computer and use it in GitHub Desktop.
QMK keyboard - Swedish characters on US layout on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum custom_keycodes { | |
| . | |
| . | |
| . | |
| SE_AA, | |
| SE_AE, | |
| SE_OE | |
| }; | |
| char *swedish_codes[][2] = { | |
| { | |
| SS_RALT("a"), // Option+a → å | |
| SS_RALT("A"), // Option+A → Å | |
| }, | |
| { | |
| SS_RALT("u")"a", // Option+u, a → ä | |
| SS_RALT("u")"A", // Option+u, A → Ä | |
| }, | |
| { | |
| SS_RALT("u")"o", // Option+u, o → ö | |
| SS_RALT("u")"O", // Option+u, O → Ö | |
| }, | |
| }; | |
| bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |
| . | |
| . | |
| . | |
| if (!record->event.pressed) return true; | |
| switch (keycode) { | |
| case SE_AA: case SE_AE: case SE_OE: { | |
| uint8_t mods = get_mods(); | |
| clear_mods(); | |
| // Send code based on which key was pressed and whether Shift was held. | |
| uint16_t index = keycode - SE_AA; | |
| uint8_t shift = mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)); | |
| send_string(swedish_codes[index][(bool)shift]); | |
| set_mods(mods); | |
| return false; | |
| } | |
| default: | |
| return true; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment