From b732b79b49b098dba8e14493c745075f336747d8 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Wed, 18 May 2016 23:47:16 -0400 Subject: adapts unicode to quantum.c (#333) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Unicode to have unicode input you need to: - set your OS input method to UNICODE if needed - enable unicode in your makefile - copy the action_function from keyboard/planck/keymaps/unicode/unicode.c to your keymap.c set the target OS method in your keymap.c: void matrix_init_user() { set_unicode_mode(UC_OSX); } you can then switch when you want with: set_unicode_mode(UC_OSX); set_unicode_mode(UC_LNX); set_unicode_mode(UC_WIN); put some unicode codes in your keymap like so: UC(0x0061) I did change the bit mask in quantum/keymap_common.c and .h I’m afraid we will need uint32 to get a total support for all unicode tables or relocate the handler as @mbarkhau did. * rearranges keycode values, hooks-up unicode * removes extra lalt ref * adds unicode shortcuts and example --- quantum/keymap_common.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'quantum/keymap_common.c') diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 2aae13e679..1d9ab2e05c 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -31,7 +31,6 @@ along with this program. If not, see . #include "keymap_midi.h" #endif - extern keymap_config_t keymap_config; #include @@ -154,20 +153,22 @@ static action_t keycode_to_action(uint16_t keycode) case KC_TRNS: action.code = ACTION_TRANSPARENT; break; - case 0x0100 ... 0x1FFF: ; + case LCTL(0) ... 0x1FFF: ; // Has a modifier // Split it up action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key break; - case 0x2000 ... 0x2FFF: + case FUNC(0) ... FUNC(0xFFF): ; // Is a shortcut for function layer, pull last 12bits // This means we have 4,096 FN macros at our disposal return keymap_func_to_action(keycode & 0xFFF); break; - case 0x3000 ... 0x3FFF: ; - // When the code starts with 3, it's an action macro. + case M(0) ... M(0xFF): action.code = ACTION_MACRO(keycode & 0xFF); break; + case LT(0, 0) ... LT(0xFF, 0xF): + action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); + break; #ifdef BACKLIGHT_ENABLE case BL_0 ... BL_15: action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); @@ -201,7 +202,7 @@ static action_t keycode_to_action(uint16_t keycode) print("\nDEBUG: enabled.\n"); debug_enable = true; break; - case 0x5002 ... 0x50FF: + case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); @@ -251,7 +252,7 @@ static action_t keycode_to_action(uint16_t keycode) } eeconfig_update_keymap(keymap_config.raw); break; - case 0x5100 ... 0x56FF: ; + case TO(0, 1) ... OSM(0xFF): ; // Layer movement shortcuts // See .h to see constraints/usage int type = (keycode >> 0x8) & 0xF; @@ -282,18 +283,9 @@ static action_t keycode_to_action(uint16_t keycode) action.code = ACTION_MODS_ONESHOT(mod); } break; - case 0x7000 ... 0x7FFF: + case MT(0, 0) ... MT(0xF, 0xFF): action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); break; - case 0x8000 ... 0x8FFF: - action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); - break; - #ifdef UNICODE_ENABLE - case 0x8000000 ... 0x8FFFFFF: - uint16_t unicode = keycode & ~(0x8000); - action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); - break; - #endif default: action.code = ACTION_NO; break; -- cgit v1.2.3