mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-18 18:04:57 +00:00
Merge remote-tracking branch 'drashna/make_unicode_init' into cycle_unicode_input_mode_new
This commit is contained in:
commit
bd68cfe688
11 changed files with 226 additions and 153 deletions
|
@ -1,28 +1,28 @@
|
|||
# Unicode Support
|
||||
|
||||
There are three Unicode keymap definition method available in QMK:
|
||||
There are three Unicode keymap definition methods available in QMK:
|
||||
|
||||
## UNICODE_ENABLE
|
||||
|
||||
Supports Unicode input up to 0xFFFF. The keycode function is `UC(n)` in keymap file, where *n* is a 4 digit hexadecimal.
|
||||
Supports Unicode up to `0xFFFF`. The keycode function is `UC(n)` in the keymap file, where _n_ is a 4 digit hexadecimal number.
|
||||
|
||||
## UNICODEMAP_ENABLE
|
||||
|
||||
Supports Unicode up to 0xFFFFFFFF. You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(n)` where *n* is the array index of the mapping table.
|
||||
Supports Unicode up to `0x10FFFF` (all possible code points). You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(n)`, where _n_ is an array index into the mapping table.
|
||||
|
||||
And you may want to have an enum to make reference easier. So you'd want to add something like this to your keymap:
|
||||
|
||||
```c
|
||||
enum unicode_name {
|
||||
BANG, // ‽
|
||||
IRONY, // ⸮
|
||||
SNEK // snke 🐍
|
||||
enum unicode_names {
|
||||
BANG,
|
||||
IRONY,
|
||||
SNEK,
|
||||
};
|
||||
|
||||
const uint32_t PROGMEM unicode_map[] = {
|
||||
[BANG] = 0x0203D, // ‽
|
||||
[IRONY] = 0x02E2E, // ⸮
|
||||
[SNEK] = 0x1F40D // snke 🐍
|
||||
[BANG] = 0x203D, // ‽
|
||||
[IRONY] = 0x2E2E, // ⸮
|
||||
[SNEK] = 0x1F40D, // 🐍
|
||||
}:
|
||||
```
|
||||
|
||||
|
@ -30,7 +30,7 @@ Make sure that the order for both matches.
|
|||
|
||||
## UCIS_ENABLE
|
||||
|
||||
Supports Unicode up to 0xFFFFFFFF. As with `UNICODE_MAP`, you may want to main a mapping table in your keymap file. However, there is no keycodes for this feature, you will have to add a keycode or function to call `qk_ucis_start()`. Once you've run that, you can just type the text for your unicode, and then hit space or enter to complete it, or ESC to cancel it. And if it matches an entry in your table, it will automatically "backspace" the trigger word (from your table) and then will input the unicode sequence.
|
||||
Supports Unicode up to `0x10FFFF` (all possible code points). As with `UNICODEMAP`, you may want to maintain a mapping table in your keymap file. However, there are no built-in keycodes for this feature — you will have to add a keycode or function that calls `qk_ucis_start()`. Once it's been called, you can type the mnemonic for your character, then hit Space or Enter to complete it or Esc to cancel. If the mnemonic matches an entry in your table, the typed text will automatically be erased and the corresponding Unicode sequence inserted.
|
||||
|
||||
For instance, you would need to have a table like this in your keymap:
|
||||
|
||||
|
@ -53,42 +53,82 @@ There are several functions that you can add to your keymap to customize the fun
|
|||
* `void qk_ucis_success(uint8_t symbol_index)` - This runs when the unicode input has matched something, and has completed. Default doesn't do anything.
|
||||
* `void qk_ucis_symbol_fallback (void)` - This runs if the input text doesn't match anything. The default function falls back to trying that input as a unicode code.
|
||||
|
||||
The default code for these are:
|
||||
You can find the default implementations of these functions in [`process_ucis.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_ucis.c).
|
||||
|
||||
## Input Modes
|
||||
|
||||
Unicode input in QMK works by inputting a sequence of characters to the OS, sort of like a macro. Unfortunately, the way this is done differs for each platform. Specifically, each platform requires a different combination of keys to trigger Unicode input. Therefore, a corresponding input mode has to be set in QMK.
|
||||
|
||||
The following input modes are available:
|
||||
|
||||
* **`UC_OSX`**: Mac OS X built-in Unicode hex input. Supports code points up to `0xFFFF` (`0x10FFFF` with `UNICODEMAP`).
|
||||
|
||||
To enable, go to _System Preferences > Keyboard > Input Sources_, add _Unicode Hex Input_ to the list (it's under _Other_), then activate it from the input dropdown in the Menu Bar.
|
||||
|
||||
* **`UC_OSX_RALT`**: Same as `UC_OSX`, but sends the Right Alt/Option key for Unicode input.
|
||||
|
||||
* **`UC_LNX`**: Linux built-in IBus Unicode input. Supports all possible code points (`0x10FFFF`).
|
||||
|
||||
Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else.
|
||||
|
||||
* **`UC_WIN`**: _(not recommended)_ Windows built-in hex numpad Unicode input. Supports code points up to `0xFFFF`.
|
||||
|
||||
To enable, create a registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad` and set its value to `1`. This can be done from the Command Prompt by running `reg add "HKCU\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d 1` with administrator privileges. Afterwards, reboot.
|
||||
This mode is not recommended because of reliability and compatibility issues; use the `UC_WINC` mode instead.
|
||||
|
||||
* **`UC_BSD`**: _(non implemented)_ Unicode input under BSD. Not implemented at this time. If you're a BSD user and want to help add support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues).
|
||||
|
||||
* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). As of v0.8.2, supports code points up to `0xFFFFF`.
|
||||
|
||||
To enable, install the [latest release](https://github.com/samhocevar/wincompose/releases/latest). Once installed, WinCompose will automatically run on startup. Works reliably under all version of Windows supported by the app.
|
||||
This mode relies on the Compose key being set to Right Alt (`KC_RALT`). If you change it to something else in the WinCompose settings, this mode will not work.
|
||||
|
||||
### Switching Input Modes
|
||||
|
||||
There are two ways to set the input mode for Unicode: by keycode or by function. Keep in mind that both methods write to persistent storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it the first time, you don't need to set it again unless you want to change it, or you've reset the EEPROM settings.
|
||||
|
||||
You can switch the input mode at any time by using one of the following keycodes. The easiest way is to add the ones you use to your keymap.
|
||||
|
||||
|Keycode |Alias |Input mode |Description |
|
||||
|-----------------------|---------|-------------|-----------------------------------------|
|
||||
|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Switch to Mac OS X input. |
|
||||
|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Switch to Linux 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_WINC` |`UC_M_WC`|`UC_WINC` |Switch to Windows input using WinCompose.|
|
||||
|`UNICODE_MODE_OSX_RALT`|`UC_M_OR`|`UC_OSX_RALT`|Switch to Mac OS X input using Right Alt.|
|
||||
|
||||
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`). Since the function only needs to be called once, it's recommended that you do it in `eeconfig_init_user` (or a similar function). For example:
|
||||
|
||||
```c
|
||||
void qk_ucis_start_user(void) { // outputs keyboard emoji
|
||||
unicode_input_start();
|
||||
register_hex(0x2328);
|
||||
unicode_input_finish();
|
||||
}
|
||||
|
||||
void qk_ucis_success(uint8_t symbol_index) {
|
||||
}
|
||||
|
||||
void qk_ucis_symbol_fallback (void) { // falls back to manual unicode entry
|
||||
for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
|
||||
uint8_t code = qk_ucis_state.codes[i];
|
||||
register_code(code);
|
||||
unregister_code(code);
|
||||
wait_ms(UNICODE_TYPE_DELAY);
|
||||
}
|
||||
void eeconfig_init_user(void) {
|
||||
set_unicode_input_mode(UC_LNX);
|
||||
}
|
||||
```
|
||||
|
||||
## Unicode Input methods
|
||||
### Audio Feedback
|
||||
|
||||
Unicode input in QMK works by inputting a sequence of characters to the OS,
|
||||
sort of like macro. Unfortunately, each OS has different ideas on how Unicode is input.
|
||||
If you have the [Audio feature](feature_audio.md) enabled on the board, you can set melodies to be played when you press the above keys. That way you can have some audio feedback when switching input modes.
|
||||
|
||||
This is the current list of Unicode input method in QMK:
|
||||
For instance, you can add these definitions to your `config.h` file:
|
||||
|
||||
* __UC_OSX__: MacOS Unicode Hex Input support. Works only up to 0xFFFF. Disabled by default. To enable: go to System Preferences -> Keyboard -> Input Sources, and enable Unicode Hex.
|
||||
* __UC_OSX_RALT__: Same as UC_OSX, but sends the Right Alt key for unicode input
|
||||
* __UC_LNX__: Unicode input method under Linux. Works up to 0xFFFFF. Should work almost anywhere on ibus enabled distros. Without ibus, this works under GTK apps, but rarely anywhere else.
|
||||
* __UC_WIN__: (not recommended) Windows built-in Unicode input. To enable: create registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad`, set its value to 1, and reboot. This method is not recommended because of reliability and compatibility issue, use WinCompose method below instead.
|
||||
* __UC_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows.
|
||||
```c
|
||||
#define UNICODE_SONG_OSX COIN_SOUND
|
||||
#define UNICODE_SONG_LNX UNICODE_LINUX
|
||||
#define UNICODE_SONG_BSD MARIO_GAMEOVER
|
||||
#define UNICODE_SONG_WIN UNICODE_WINDOWS
|
||||
#define UNICODE_SONG_WINC UNICODE_WINDOWS
|
||||
#define UNICODE_SONG_OSX_RALT COIN_SOUND
|
||||
```
|
||||
|
||||
At some point, you need to call `set_unicode_input_mode(x)` to set the correct unicode method. This sets the method that is used to send the unicode, and stores it in EEPROM, so you only need to call this once.
|
||||
### Additional Customization
|
||||
|
||||
The functions for starting and finishing Unicode input on your platform can be overridden locally. Possible uses include customizing input mode behavior if you don't use the default keys, or adding extra visual/audio feedback to Unicode input.
|
||||
|
||||
* `void unicode_input_start(void)` – This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on Mac.
|
||||
* `void unicode_input_finish(void)` – This is called to exit Unicode input mode, for example by pressing Space or releasing the Option key.
|
||||
|
||||
You can find the default implementations of these functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c).
|
||||
|
||||
## `send_unicode_hex_string`
|
||||
|
||||
|
|
|
@ -93,8 +93,6 @@ void register_ucis(const char *hex) {
|
|||
}
|
||||
|
||||
bool process_ucis (uint16_t keycode, keyrecord_t *record) {
|
||||
unicode_input_mode_init();
|
||||
|
||||
if (!qk_ucis_state.in_progress)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PROCESS_UCIS_H
|
||||
#define PROCESS_UCIS_H
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "process_unicode_common.h"
|
||||
|
@ -48,5 +47,3 @@ void qk_ucis_symbol_fallback (void);
|
|||
void qk_ucis_success(uint8_t symbol_index);
|
||||
void register_ucis(const char *hex);
|
||||
bool process_ucis (uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
|
||||
if (keycode > QK_UNICODE && record->event.pressed) {
|
||||
uint16_t unicode = keycode & 0x7FFF;
|
||||
unicode_input_mode_init();
|
||||
unicode_input_start();
|
||||
register_hex(unicode);
|
||||
unicode_input_finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef PROCESS_UNICODE_H
|
||||
#define PROCESS_UNICODE_H
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "process_unicode_common.h"
|
||||
|
||||
bool process_unicode(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,81 +19,64 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static uint8_t input_mode;
|
||||
unicode_config_t unicode_config;
|
||||
#if UNICODE_SELECTED_MODES != -1
|
||||
static uint8_t selected[] = { UNICODE_SELECTED_MODES };
|
||||
static uint8_t selected_count = sizeof selected / sizeof *selected;
|
||||
static uint8_t selected_index;
|
||||
#endif
|
||||
uint8_t mods;
|
||||
static uint8_t saved_mods;
|
||||
|
||||
void set_unicode_input_mode(uint8_t os_target) {
|
||||
input_mode = os_target;
|
||||
unicode_config.input_mode = os_target;
|
||||
persist_unicode_input_mode();
|
||||
dprintf("input_mode set to: %u\n", input_mode);
|
||||
dprintf("input_mode set to: %u\n", unicode_config.input_mode);
|
||||
}
|
||||
|
||||
uint8_t get_unicode_input_mode(void) {
|
||||
return input_mode;
|
||||
return unicode_config.input_mode;
|
||||
}
|
||||
|
||||
void unicode_input_mode_init(void) {
|
||||
static bool first_flag = false;
|
||||
if (!first_flag) {
|
||||
input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE);
|
||||
|
||||
unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE);
|
||||
#if UNICODE_SELECTED_MODES != -1
|
||||
// Find input_mode in selected modes
|
||||
uint8_t i;
|
||||
for (i = 0; i < selected_count; i++) {
|
||||
if (selected[i] == input_mode) {
|
||||
selected_index = i;
|
||||
break;
|
||||
}
|
||||
// Find input_mode in selected modes
|
||||
uint8_t i;
|
||||
for (i = 0; i < selected_count; i++) {
|
||||
if (selected[i] == unicode_config.input_mode) {
|
||||
selected_index = i;
|
||||
break;
|
||||
}
|
||||
if (i == selected_count) {
|
||||
// input_mode isn't selected, change to one that is
|
||||
input_mode = selected[selected_index = 0];
|
||||
}
|
||||
#endif
|
||||
|
||||
dprintf("input_mode init to: %u\n", input_mode);
|
||||
first_flag = true;
|
||||
}
|
||||
if (i == selected_count) {
|
||||
// input_mode isn't selected, change to one that is
|
||||
unicode_config.input_mode = selected[selected_index = 0];
|
||||
}
|
||||
#endif
|
||||
dprintf("input_mode init to: %u\n", unicode_config.input_mode);
|
||||
}
|
||||
|
||||
void cycle_unicode_input_mode(void) {
|
||||
#if UNICODE_SELECTED_MODES != -1
|
||||
unicode_input_mode_init(); // Init selected_index
|
||||
selected_index = (selected_index + 1) % selected_count;
|
||||
input_mode = selected[selected_index];
|
||||
# if UNICODE_CYCLE_PERSIST
|
||||
unicode_config.input_mode = selected[selected_index];
|
||||
#if UNICODE_CYCLE_PERSIST
|
||||
persist_unicode_input_mode();
|
||||
# endif
|
||||
dprintf("input_mode cycle to: %u\n", input_mode);
|
||||
#endif
|
||||
dprintf("input_mode cycle to: %u\n", unicode_config.input_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void persist_unicode_input_mode(void) {
|
||||
eeprom_update_byte(EECONFIG_UNICODEMODE, input_mode);
|
||||
eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode);
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void unicode_input_start (void) {
|
||||
// save current mods
|
||||
mods = keyboard_report->mods;
|
||||
void unicode_input_start(void) {
|
||||
saved_mods = get_mods(); // Save current mods
|
||||
clear_mods(); // Unregister mods to start from a clean state
|
||||
|
||||
// unregister all mods to start from clean state
|
||||
if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT);
|
||||
if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT);
|
||||
if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL);
|
||||
if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL);
|
||||
if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT);
|
||||
if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT);
|
||||
if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI);
|
||||
if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI);
|
||||
|
||||
switch(input_mode) {
|
||||
switch (unicode_config.input_mode) {
|
||||
case UC_OSX:
|
||||
register_code(KC_LALT);
|
||||
break;
|
||||
|
@ -103,50 +86,40 @@ void unicode_input_start (void) {
|
|||
case UC_LNX:
|
||||
register_code(KC_LCTL);
|
||||
register_code(KC_LSFT);
|
||||
register_code(KC_U);
|
||||
unregister_code(KC_U);
|
||||
tap_code(KC_U);
|
||||
unregister_code(KC_LSFT);
|
||||
unregister_code(KC_LCTL);
|
||||
break;
|
||||
case UC_BSD:
|
||||
break;
|
||||
case UC_WIN:
|
||||
register_code(KC_LALT);
|
||||
register_code(KC_PPLS);
|
||||
unregister_code(KC_PPLS);
|
||||
tap_code(KC_PPLS);
|
||||
break;
|
||||
case UC_WINC:
|
||||
register_code(KC_RALT);
|
||||
unregister_code(KC_RALT);
|
||||
register_code(KC_U);
|
||||
unregister_code(KC_U);
|
||||
tap_code(KC_RALT);
|
||||
tap_code(KC_U);
|
||||
break;
|
||||
}
|
||||
wait_ms(UNICODE_TYPE_DELAY);
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void unicode_input_finish (void) {
|
||||
switch(input_mode) {
|
||||
case UC_OSX:
|
||||
case UC_WIN:
|
||||
unregister_code(KC_LALT);
|
||||
break;
|
||||
case UC_OSX_RALT:
|
||||
unregister_code(KC_RALT);
|
||||
break;
|
||||
case UC_LNX:
|
||||
register_code(KC_SPC);
|
||||
unregister_code(KC_SPC);
|
||||
break;
|
||||
void unicode_input_finish(void) {
|
||||
switch (unicode_config.input_mode) {
|
||||
case UC_OSX:
|
||||
case UC_WIN:
|
||||
unregister_code(KC_LALT);
|
||||
break;
|
||||
case UC_OSX_RALT:
|
||||
unregister_code(KC_RALT);
|
||||
break;
|
||||
case UC_LNX:
|
||||
tap_code(KC_SPC);
|
||||
break;
|
||||
}
|
||||
|
||||
// reregister previously set mods
|
||||
if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT);
|
||||
if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT);
|
||||
if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL);
|
||||
if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL);
|
||||
if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT);
|
||||
if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT);
|
||||
if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI);
|
||||
if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI);
|
||||
set_mods(saved_mods); // Reregister previously set mods
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
|
@ -163,8 +136,7 @@ uint16_t hex_to_keycode(uint8_t hex) {
|
|||
void register_hex(uint16_t hex) {
|
||||
for(int i = 3; i >= 0; i--) {
|
||||
uint8_t digit = ((hex >> (i*4)) & 0xF);
|
||||
register_code(hex_to_keycode(digit));
|
||||
unregister_code(hex_to_keycode(digit));
|
||||
tap_code(hex_to_keycode(digit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,3 +164,61 @@ void send_unicode_hex_string(const char *str) {
|
|||
str += n; // Move to the first ' ' (or '\0') after the current token
|
||||
}
|
||||
}
|
||||
|
||||
bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch (keycode) {
|
||||
case UNICODE_MODE_OSX:
|
||||
set_unicode_input_mode(UC_OSX);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX)
|
||||
static float song_osx[][2] = UNICODE_SONG_OSX;
|
||||
PLAY_SONG(song_osx);
|
||||
#endif
|
||||
break;
|
||||
case UNICODE_MODE_LNX:
|
||||
set_unicode_input_mode(UC_LNX);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX)
|
||||
static float song_lnx[][2] = UNICODE_SONG_LNX;
|
||||
PLAY_SONG(song_lnx);
|
||||
#endif
|
||||
break;
|
||||
case UNICODE_MODE_WIN:
|
||||
set_unicode_input_mode(UC_WIN);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN)
|
||||
static float song_win[][2] = UNICODE_SONG_WIN;
|
||||
PLAY_SONG(song_win);
|
||||
#endif
|
||||
break;
|
||||
case UNICODE_MODE_BSD:
|
||||
set_unicode_input_mode(UC_BSD);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD)
|
||||
static float song_bsd[][2] = UNICODE_SONG_BSD;
|
||||
PLAY_SONG(song_bsd);
|
||||
#endif
|
||||
break;
|
||||
case UNICODE_MODE_WINC:
|
||||
set_unicode_input_mode(UC_WINC);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC)
|
||||
static float song_winc[][2] = UNICODE_SONG_WINC;
|
||||
PLAY_SONG(song_winc);
|
||||
#endif
|
||||
break;
|
||||
case UNICODE_MODE_OSX_RALT:
|
||||
set_unicode_input_mode(UC_OSX_RALT);
|
||||
#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT)
|
||||
static float song_osx_ralt[][2] = UNICODE_SONG_OSX_RALT;
|
||||
PLAY_SONG(song_osx_ralt);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if defined(UNICODE_ENABLE)
|
||||
return process_unicode(keycode, record);
|
||||
#elif defined(UNICODEMAP_ENABLE)
|
||||
return process_unicode_map(keycode, record);
|
||||
#elif defined(UCIS_ENABLE)
|
||||
return process_ucis(keycode, record);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,28 +14,37 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PROCESS_UNICODE_COMMON_H
|
||||
#define PROCESS_UNICODE_COMMON_H
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1
|
||||
#error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time"
|
||||
#endif
|
||||
|
||||
// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle)
|
||||
// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX
|
||||
#ifndef UNICODE_SELECTED_MODES
|
||||
#define UNICODE_SELECTED_MODES -1
|
||||
#define UNICODE_SELECTED_MODES -1
|
||||
#endif
|
||||
|
||||
// Whether input mode changes in cycle should be written to EEPROM
|
||||
#ifndef UNICODE_CYCLE_PERSIST
|
||||
#define UNICODE_CYCLE_PERSIST true
|
||||
#define UNICODE_CYCLE_PERSIST true
|
||||
#endif
|
||||
|
||||
#ifndef UNICODE_TYPE_DELAY
|
||||
#define UNICODE_TYPE_DELAY 10
|
||||
#define UNICODE_TYPE_DELAY 10
|
||||
#endif
|
||||
|
||||
__attribute__ ((unused))
|
||||
static uint8_t input_mode;
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct {
|
||||
uint8_t input_mode :8;
|
||||
};
|
||||
} unicode_config_t;
|
||||
|
||||
extern unicode_config_t unicode_config;
|
||||
|
||||
void set_unicode_input_mode(uint8_t os_target);
|
||||
uint8_t get_unicode_input_mode(void);
|
||||
|
@ -47,6 +56,7 @@ void unicode_input_start(void);
|
|||
void unicode_input_finish(void);
|
||||
void register_hex(uint16_t hex);
|
||||
void send_unicode_hex_string(const char *str);
|
||||
bool process_unicode_common(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
#define UC_OSX 0 // Mac OS X
|
||||
#define UC_LNX 1 // Linux
|
||||
|
@ -161,5 +171,3 @@ void send_unicode_hex_string(const char *str);
|
|||
#define UC_RCBR UC(0x007D)
|
||||
#define UC_TILD UC(0x007E)
|
||||
#define UC_DEL UC(0x007F)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,6 @@ __attribute__((weak))
|
|||
void unicode_map_input_error() {}
|
||||
|
||||
bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
|
||||
unicode_input_mode_init();
|
||||
uint8_t input_mode = get_unicode_input_mode();
|
||||
if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
|
||||
const uint32_t* map = unicode_map;
|
||||
|
|
|
@ -14,12 +14,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PROCESS_UNICODEMAP_H
|
||||
#define PROCESS_UNICODEMAP_H
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "process_unicode_common.h"
|
||||
|
||||
void unicode_map_input_error(void);
|
||||
bool process_unicode_map(uint16_t keycode, keyrecord_t *record);
|
||||
#endif
|
||||
|
|
|
@ -235,7 +235,7 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||
process_key_lock(&keycode, record) &&
|
||||
#endif
|
||||
#if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
|
||||
process_clicky(keycode, record) &&
|
||||
process_clicky(keycode, record) &&
|
||||
#endif //AUDIO_CLICKY
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES)
|
||||
|
@ -250,33 +250,27 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||
#ifdef STENO_ENABLE
|
||||
process_steno(keycode, record) &&
|
||||
#endif
|
||||
#if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
|
||||
#if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
|
||||
process_music(keycode, record) &&
|
||||
#endif
|
||||
#ifdef TAP_DANCE_ENABLE
|
||||
process_tap_dance(keycode, record) &&
|
||||
#endif
|
||||
#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
|
||||
process_unicode_common(keycode, record) &&
|
||||
#endif
|
||||
#ifdef LEADER_ENABLE
|
||||
process_leader(keycode, record) &&
|
||||
#endif
|
||||
#ifdef COMBO_ENABLE
|
||||
process_combo(keycode, record) &&
|
||||
#endif
|
||||
#ifdef UNICODE_ENABLE
|
||||
process_unicode(keycode, record) &&
|
||||
#endif
|
||||
#ifdef UCIS_ENABLE
|
||||
process_ucis(keycode, record) &&
|
||||
#endif
|
||||
#ifdef PRINTING_ENABLE
|
||||
process_printer(keycode, record) &&
|
||||
#endif
|
||||
#ifdef AUTO_SHIFT_ENABLE
|
||||
process_auto_shift(keycode, record) &&
|
||||
#endif
|
||||
#ifdef UNICODEMAP_ENABLE
|
||||
process_unicode_map(keycode, record) &&
|
||||
#endif
|
||||
#ifdef TERMINAL_ENABLE
|
||||
process_terminal(keycode, record) &&
|
||||
#endif
|
||||
|
@ -997,6 +991,9 @@ void matrix_init_quantum() {
|
|||
#ifdef ENCODER_ENABLE
|
||||
encoder_init();
|
||||
#endif
|
||||
#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
|
||||
unicode_input_mode_init();
|
||||
#endif
|
||||
matrix_init_kb();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,9 +81,6 @@ enum quantum_keycodes {
|
|||
#endif
|
||||
QK_MOD_TAP = 0x6000,
|
||||
QK_MOD_TAP_MAX = 0x7FFF,
|
||||
#if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE)
|
||||
#error "Cannot enable both UNICODEMAP && UNICODE"
|
||||
#endif
|
||||
#ifdef UNICODE_ENABLE
|
||||
QK_UNICODE = 0x8000,
|
||||
QK_UNICODE_MAX = 0xFFFF,
|
||||
|
@ -454,6 +451,13 @@ enum quantum_keycodes {
|
|||
TERM_OFF,
|
||||
#endif
|
||||
|
||||
UNICODE_MODE_OSX,
|
||||
UNICODE_MODE_LNX,
|
||||
UNICODE_MODE_WIN,
|
||||
UNICODE_MODE_BSD,
|
||||
UNICODE_MODE_WINC,
|
||||
UNICODE_MODE_OSX_RALT,
|
||||
|
||||
// always leave at the end
|
||||
SAFE_RANGE
|
||||
};
|
||||
|
@ -681,6 +685,13 @@ enum quantum_keycodes {
|
|||
#define X(n) (QK_UNICODE_MAP | (n))
|
||||
#endif
|
||||
|
||||
#define UC_M_OS UNICODE_MODE_OSX
|
||||
#define UC_M_LN UNICODE_MODE_LNX
|
||||
#define UC_M_WI UNICODE_MODE_WIN
|
||||
#define UC_M_BS UNICODE_MODE_BSD
|
||||
#define UC_M_WC UNICODE_MODE_WINC
|
||||
#define UC_M_OR UNICODE_MODE_OSX_RALT
|
||||
|
||||
#ifdef SWAP_HANDS_ENABLE
|
||||
#define SH_T(kc) (QK_SWAP_HANDS | (kc))
|
||||
#define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
|
||||
|
|
Loading…
Reference in a new issue