From 1048a588c750e27ff0f900cd6aaf670e034086d0 Mon Sep 17 00:00:00 2001 From: npoirey Date: Fri, 7 Oct 2016 17:15:11 +0200 Subject: Add Altgr combination for non US layouts --- quantum/keymap.h | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum/keymap.h') diff --git a/quantum/keymap.h b/quantum/keymap.h index 98ddfd0c53..4b2192cb2e 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -191,6 +191,7 @@ enum quantum_keycodes { #define HYPR(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI) #define MEH(kc) (kc | QK_LCTL | QK_LSFT | QK_LALT) #define LCAG(kc) (kc | QK_LCTL | QK_LALT | QK_LGUI) +#define ALTG(kc) (kc | QK_RCTL | QK_RALT) #define MOD_HYPR 0xf #define MOD_MEH 0x7 -- cgit v1.2.3 From 5b2e455d3b71bfb90754930d1f22d3e8ce98b927 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 10 Oct 2016 00:46:20 +0700 Subject: Unicode map framework. Allow unicode up to 0xFFFFF using separate mapping table --- build_keyboard.mk | 5 +++++ quantum/keymap.h | 7 +++++++ quantum/process_keycode/process_unicode.c | 26 ++++++++++++++++++++++++++ quantum/process_keycode/process_unicode.h | 4 ++++ quantum/quantum.c | 3 +++ readme.md | 6 ++++++ 6 files changed, 51 insertions(+) (limited to 'quantum/keymap.h') diff --git a/build_keyboard.mk b/build_keyboard.mk index 03a69b1464..282adcb118 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -153,6 +153,11 @@ ifeq ($(strip $(UCIS_ENABLE)), yes) UNICODE_ENABLE = yes endif +ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) + OPT_DEFS += -DUNICODEMAP_ENABLE + UNICODE_ENABLE = yes +endif + ifeq ($(strip $(UNICODE_ENABLE)), yes) OPT_DEFS += -DUNICODE_ENABLE SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c diff --git a/quantum/keymap.h b/quantum/keymap.h index 98ddfd0c53..0daa001204 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -84,6 +84,10 @@ enum quantum_keycodes { QK_MOD_TAP_MAX = 0x6FFF, QK_TAP_DANCE = 0x7100, QK_TAP_DANCE_MAX = 0x71FF, +#ifdef UNICODEMAP_ENABLE + QK_UNICODE_MAP = 0x7800, + QK_UNICODE_MAP_MAX = 0x7FFF, +#endif #ifdef UNICODE_ENABLE QK_UNICODE = 0x8000, QK_UNICODE_MAX = 0xFFFF, @@ -335,5 +339,8 @@ enum quantum_keycodes { #define UC(n) UNICODE(n) #endif +#ifdef UNICODEMAP_ENABLE + #define X(n) (n | QK_UNICODE_MAP) +#endif #endif diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 6a30afe293..37dd471ffd 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -78,6 +78,32 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { return true; } +#ifdef UNICODEMAP_ENABLE +__attribute__((weak)) +const uint32_t PROGMEM unicode_map[] = { +}; + +// 5 digit max because of linux limitation +void register_hex32(uint32_t hex) { + for(int i = 4; i >= 0; i--) { + uint8_t digit = ((hex >> (i*4)) & 0xF); + register_code(hex_to_keycode(digit)); + unregister_code(hex_to_keycode(digit)); + } +} + +bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { + if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { + const uint32_t* map = unicode_map; + uint16_t index = keycode & 0x7FF; + unicode_input_start(); + register_hex32(pgm_read_dword_far(&map[index])); + unicode_input_finish(); + } + return true; +} +#endif + #ifdef UCIS_ENABLE qk_ucis_state_t qk_ucis_state; diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index 27f8072ee6..a6c7e45845 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h @@ -20,6 +20,10 @@ void register_hex(uint16_t hex); bool process_unicode(uint16_t keycode, keyrecord_t *record); +#ifdef UNICODEMAP_ENABLE +bool process_unicode_map(uint16_t keycode, keyrecord_t *record); +#endif + #ifdef UCIS_ENABLE #ifndef UCIS_MAX_SYMBOL_LENGTH #define UCIS_MAX_SYMBOL_LENGTH 32 diff --git a/quantum/quantum.c b/quantum/quantum.c index a16bd5443c..098312e6ef 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -128,6 +128,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef UCIS_ENABLE process_ucis(keycode, record) && + #endif + #ifdef UNICODEMAP_ENABLE + process_unicode_map(keycode, record) && #endif true)) { return false; diff --git a/readme.md b/readme.md index a7320202b2..2653ab2ea7 100644 --- a/readme.md +++ b/readme.md @@ -320,6 +320,12 @@ This enables MIDI sending and receiving with your keyboard. To enter MIDI send m This allows you to send unicode symbols via `UC()` in your keymap. Only codes up to 0x7FFF are currently supported. +`UNICODEMAP_ENABLE` + +This allows sending unicode symbols using `X()` in your keymap. Codes +up to 0xFFFFF are supported, including emojis. But you need to maintain a +separate mapping table in your keymap file. + `BLUETOOTH_ENABLE` This allows you to interface with a Bluefruit EZ-key to send keycodes wirelessly. It uses the D2 and D3 pins. -- cgit v1.2.3 From e27a754b70434de88a37c4a572e4ca5f7730ff58 Mon Sep 17 00:00:00 2001 From: Jack & Erez Date: Wed, 12 Oct 2016 22:18:27 -0400 Subject: [Jack & Erez] Simplifies and documents TO --- keyboards/ergodox/keymaps/dave/keymap.c | 12 ++++++------ quantum/keymap.h | 5 ++++- readme.md | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'quantum/keymap.h') diff --git a/keyboards/ergodox/keymaps/dave/keymap.c b/keyboards/ergodox/keymaps/dave/keymap.c index 32c70097b0..23c4e04906 100644 --- a/keyboards/ergodox/keymaps/dave/keymap.c +++ b/keyboards/ergodox/keymaps/dave/keymap.c @@ -38,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_H, CTL_T(KC_GRV),KC_NUBS,KC_NO, KC_NO, KC_LALT, KC_PSCREEN, KC_PSCREEN, - TO(PROG, ON_PRESS), + TO(PROG), KC_SPC, MO(NAVI), KC_LGUI, // right hand KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_BSPC, @@ -47,7 +47,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_RALT,KC_LBRC,KC_RBRC,KC_NO, CTL_T(KC_QUOT), MT(0x5, KC_NO), MT(0x5, KC_NO), - TO(PROG, ON_PRESS), + TO(PROG), KC_RGUI, MO(PROG), KC_SPC ), @@ -81,7 +81,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - TO(NAVI, ON_PRESS), + TO(NAVI), KC_TRNS, KC_TRNS, KC_TRNS, // right hand KC_TRNS, KC_TRNS, KC_NO, KC_PSLS, KC_PAST, KC_PMNS, KC_EQUAL, @@ -90,7 +90,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_P1, KC_P2, KC_P3, KC_PENT, KC_TRNS, KC_P0, KC_P0, KC_PDOT, KC_PENT, KC_TRNS, KC_TRNS, KC_TRNS, - TO(NAVI, ON_PRESS), + TO(NAVI), KC_TRNS, KC_TRNS, KC_TRNS ), @@ -123,7 +123,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_BTN1, KC_MS_U, KC_BTN2, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, - TO(BASE, ON_PRESS), + TO(BASE), KC_TRNS, KC_TRNS, KC_TRNS, // right hand KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, @@ -132,7 +132,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS, KC_TRNS, KC_VOLD, KC_MUTE, KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - TO(BASE, ON_PRESS), + TO(BASE), KC_TRNS, KC_TRNS, KC_TRNS ), }; diff --git a/quantum/keymap.h b/quantum/keymap.h index 4b2192cb2e..85c090972d 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h @@ -296,7 +296,10 @@ enum quantum_keycodes { // ON_PRESS = 1 // ON_RELEASE = 2 // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default. -#define TO(layer, when) (layer | QK_TO | (when << 0x4)) +// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own +// keycode modeled after the old version, kept below for this. +/* #define TO(layer, when) (layer | QK_TO | (when << 0x4)) */ +#define TO(layer) (layer | QK_TO | (ON_PRESS << 0x4)) // Momentary switch layer - 256 layer max #define MO(layer) (layer | QK_MOMENTARY) diff --git a/readme.md b/readme.md index f20ab41b16..80f0a3ab27 100644 --- a/readme.md +++ b/readme.md @@ -379,6 +379,8 @@ Instead of using `FNx` when defining `ACTION_*` functions, you can use `F(x)` - `TG(layer)` - toggles a layer on or off. As with `MO()`, you should set this key as `KC_TRNS` in the destination layer so that tapping it again actually toggles back to the original layer. Only works upwards in the layer stack. +`TO(layer)` - Goes to a layer. This code is special, because it lets you go either up or down the stack -- just goes directly to the layer you want. So while other codes only let you go _up_ the stack (from layer 0 to layer 3, for example), `TO(2)` is going to get you to layer 2, no matter where you activate it from -- even if you're currently on layer 5. This gets activated on keydown (as soon as the key is pressed). + ### Fun with modifier keys -- cgit v1.2.3