diff options
author | Chewxy <chewxy@gmail.com> | 2022-08-15 05:24:52 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-14 20:24:52 +0100 |
commit | 6fc7c03e9581ddde68b32f2f76f8053628da6465 (patch) | |
tree | 8eafd127806a85afd2f70d5cbf4eb484f33011cc /quantum/process_keycode | |
parent | 4da34828720d6daa9fd45d811129370cf11ba874 (diff) | |
download | qmk_firmware-6fc7c03e9581ddde68b32f2f76f8053628da6465.tar.gz qmk_firmware-6fc7c03e9581ddde68b32f2f76f8053628da6465.zip |
Added emacs as an "operating system" for input mode. (#16949)
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 40 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 1 |
2 files changed, 35 insertions, 6 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 6cb2ba8dbb..8de31c055c 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -117,6 +117,12 @@ __attribute__((weak)) void unicode_input_start(void) { tap_code(UNICODE_KEY_WINC); tap_code(KC_U); break; + case UC_EMACS: + // The usual way to type unicode in emacs is C-x-8 <RET> then the unicode number in hex + tap_code16(LCTL(KC_X)); + tap_code16(KC_8); + tap_code16(KC_ENTER); + break; } wait_ms(UNICODE_TYPE_DELAY); @@ -142,6 +148,9 @@ __attribute__((weak)) void unicode_input_finish(void) { case UC_WINC: tap_code(KC_ENTER); break; + case UC_EMACS: + tap_code16(KC_ENTER); + break; } set_mods(unicode_saved_mods); // Reregister previously set mods @@ -167,6 +176,9 @@ __attribute__((weak)) void unicode_input_cancel(void) { tap_code(KC_NUM_LOCK); } break; + case UC_EMACS: + tap_code16(LCTL(KC_G)); // C-g cancels + break; } set_mods(unicode_saved_mods); // Reregister previously set mods @@ -299,14 +311,30 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { cycle_unicode_input_mode(shifted ? +1 : -1); audio_helper(); break; - - case UNICODE_MODE_MAC ... UNICODE_MODE_WINC: { - // Keycodes and input modes follow the same ordering - uint8_t delta = keycode - UNICODE_MODE_MAC; - set_unicode_input_mode(UC_MAC + delta); + case UNICODE_MODE_MAC: + set_unicode_input_mode(UC_MAC); + audio_helper(); + break; + case UNICODE_MODE_LNX: + set_unicode_input_mode(UC_LNX); + audio_helper(); + break; + case UNICODE_MODE_WIN: + set_unicode_input_mode(UC_WIN); + audio_helper(); + break; + case UNICODE_MODE_BSD: + set_unicode_input_mode(UC_BSD); + audio_helper(); + break; + case UNICODE_MODE_WINC: + set_unicode_input_mode(UC_WINC); + audio_helper(); + break; + case UNICODE_MODE_EMACS: + set_unicode_input_mode(UC_EMACS); audio_helper(); break; - } } } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 8a4494c939..15e798dbb3 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -64,6 +64,7 @@ enum unicode_input_modes { UC_WIN, // Windows using EnableHexNumpad UC_BSD, // BSD (not implemented) UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UC_EMACS, // Emacs is an operating system in search of a good text editor UC__COUNT // Number of available input modes (always leave at the end) }; |