forked from mfulz_github/qmk_firmware
		
	Added emacs as an "operating system" for input mode. (#16949)
This commit is contained in:
		
							parent
							
								
									4da3482872
								
							
						
					
					
						commit
						6fc7c03e95
					
				@ -172,6 +172,7 @@ You can switch the input mode at any time by using the following keycodes. Addin
 | 
				
			|||||||
|`UNICODE_MODE_WIN`    |`UC_M_WI`|`UC_WIN`    |Switch to Windows input                                                      |
 | 
					|`UNICODE_MODE_WIN`    |`UC_M_WI`|`UC_WIN`    |Switch to Windows input                                                      |
 | 
				
			||||||
|`UNICODE_MODE_BSD`    |`UC_M_BS`|`UC_BSD`    |Switch to BSD input _(not implemented)_                                      |
 | 
					|`UNICODE_MODE_BSD`    |`UC_M_BS`|`UC_BSD`    |Switch to BSD input _(not implemented)_                                      |
 | 
				
			||||||
|`UNICODE_MODE_WINC`   |`UC_M_WC`|`UC_WINC`   |Switch to Windows input using WinCompose                                     |
 | 
					|`UNICODE_MODE_WINC`   |`UC_M_WC`|`UC_WINC`   |Switch to Windows input using WinCompose                                     |
 | 
				
			||||||
 | 
					|`UNICODE_MODE_EMACS`  |`UC_M_EM`|`UC_EMACS`  |Switch to emacs (`C-x-8 RET`)                                               |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, where _x_ is one of the above input mode constants (e.g. `UC_LNX`).
 | 
					You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, where _x_ is one of the above input mode constants (e.g. `UC_LNX`).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -117,6 +117,12 @@ __attribute__((weak)) void unicode_input_start(void) {
 | 
				
			|||||||
            tap_code(UNICODE_KEY_WINC);
 | 
					            tap_code(UNICODE_KEY_WINC);
 | 
				
			||||||
            tap_code(KC_U);
 | 
					            tap_code(KC_U);
 | 
				
			||||||
            break;
 | 
					            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);
 | 
					    wait_ms(UNICODE_TYPE_DELAY);
 | 
				
			||||||
@ -142,6 +148,9 @@ __attribute__((weak)) void unicode_input_finish(void) {
 | 
				
			|||||||
        case UC_WINC:
 | 
					        case UC_WINC:
 | 
				
			||||||
            tap_code(KC_ENTER);
 | 
					            tap_code(KC_ENTER);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case UC_EMACS:
 | 
				
			||||||
 | 
					            tap_code16(KC_ENTER);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    set_mods(unicode_saved_mods); // Reregister previously set mods
 | 
					    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);
 | 
					                tap_code(KC_NUM_LOCK);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case UC_EMACS:
 | 
				
			||||||
 | 
					            tap_code16(LCTL(KC_G)); // C-g cancels
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    set_mods(unicode_saved_mods); // Reregister previously set mods
 | 
					    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);
 | 
					                cycle_unicode_input_mode(shifted ? +1 : -1);
 | 
				
			||||||
                audio_helper();
 | 
					                audio_helper();
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					            case UNICODE_MODE_MAC:
 | 
				
			||||||
            case UNICODE_MODE_MAC ... UNICODE_MODE_WINC: {
 | 
					                set_unicode_input_mode(UC_MAC);
 | 
				
			||||||
                // Keycodes and input modes follow the same ordering
 | 
					                audio_helper();
 | 
				
			||||||
                uint8_t delta = keycode - UNICODE_MODE_MAC;
 | 
					                break;
 | 
				
			||||||
                set_unicode_input_mode(UC_MAC + delta);
 | 
					            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();
 | 
					                audio_helper();
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -64,6 +64,7 @@ enum unicode_input_modes {
 | 
				
			|||||||
    UC_WIN,   // Windows using EnableHexNumpad
 | 
					    UC_WIN,   // Windows using EnableHexNumpad
 | 
				
			||||||
    UC_BSD,   // BSD (not implemented)
 | 
					    UC_BSD,   // BSD (not implemented)
 | 
				
			||||||
    UC_WINC,  // Windows using WinCompose (https://github.com/samhocevar/wincompose)
 | 
					    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)
 | 
					    UC__COUNT // Number of available input modes (always leave at the end)
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -609,6 +609,8 @@ enum quantum_keycodes {
 | 
				
			|||||||
    MAGIC_UNSWAP_ESCAPE_CAPSLOCK,
 | 
					    MAGIC_UNSWAP_ESCAPE_CAPSLOCK,
 | 
				
			||||||
    MAGIC_TOGGLE_ESCAPE_CAPSLOCK,
 | 
					    MAGIC_TOGGLE_ESCAPE_CAPSLOCK,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UNICODE_MODE_EMACS,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Start of custom keycode range for keyboards and keymaps - always leave at the end
 | 
					    // Start of custom keycode range for keyboards and keymaps - always leave at the end
 | 
				
			||||||
    SAFE_RANGE
 | 
					    SAFE_RANGE
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -894,6 +896,7 @@ enum quantum_keycodes {
 | 
				
			|||||||
#define UC_M_WI UNICODE_MODE_WIN
 | 
					#define UC_M_WI UNICODE_MODE_WIN
 | 
				
			||||||
#define UC_M_BS UNICODE_MODE_BSD
 | 
					#define UC_M_BS UNICODE_MODE_BSD
 | 
				
			||||||
#define UC_M_WC UNICODE_MODE_WINC
 | 
					#define UC_M_WC UNICODE_MODE_WINC
 | 
				
			||||||
 | 
					#define UC_M_EM UNICODE_MODE_EMACS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Swap Hands
 | 
					// Swap Hands
 | 
				
			||||||
#define SH_T(kc) (QK_SWAP_HANDS | (kc))
 | 
					#define SH_T(kc) (QK_SWAP_HANDS | (kc))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user