From 1512a6bfd48fb75619a1f77394d41bdca7ea28b1 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 1 Oct 2018 18:00:14 -0700 Subject: Keymap: Update to drashna keymaps and userspace (#3992) * Enabled unicode support and send_unicode function * Unicode cleanup * More unicode tweaking * Update EEPROM stuff * Account for keyboard macros * Switch Equal to Plus on Ergodox * more tweaks * Minor Unicode tweaks * Correct matrix printing for keylogger * Fix unicode functions * Fix unicode mode set since it actually uses EEPROM * Re-add DISABLE_LEADER * Ergodox is easier to hit the tapping term, fix that * Fix stupid type on unicode mode check * Preliminary CRKBD/HeliDox support * Fixes to Helidox * Cleanup userspace from old merge stuff * Remove CCCV sounds * Make Mode NOEEPROM Again --- users/drashna/config.h | 10 +++++- users/drashna/drashna.c | 75 ++++++++++++++++++++--------------------- users/drashna/drashna.h | 28 +++++++++++---- users/drashna/drashna_unicode.h | 71 -------------------------------------- users/drashna/rgb_stuff.c | 5 +-- users/drashna/rules.mk | 7 ++-- users/drashna/send_unicode.c | 58 +++++++++++++++++++++++++++++++ users/drashna/send_unicode.h | 71 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 204 insertions(+), 121 deletions(-) delete mode 100644 users/drashna/drashna_unicode.h create mode 100644 users/drashna/send_unicode.c create mode 100644 users/drashna/send_unicode.h (limited to 'users') diff --git a/users/drashna/config.h b/users/drashna/config.h index 92efcc5c7..3ddec93b1 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -55,7 +55,11 @@ #ifdef TAPPING_TERM #undef TAPPING_TERM #endif // TAPPING_TERM -#define TAPPING_TERM 175 +#ifdef KEYBOARD_ergodox_ez + #define TAPPING_TERM 185 +#else + #define TAPPING_TERM 175 +#endif // Disable action_get_macro and fn_actions, since we don't use these @@ -63,4 +67,8 @@ #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION +#define DISABLE_LEADER + #define MACRO_TIMER 5 + + diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 9489fb456..aad9fab61 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -21,6 +21,7 @@ along with this program. If not, see . userspace_config_t userspace_config; +uint16_t copy_paste_timer; // Helper Functions @@ -131,7 +132,7 @@ void led_set_keymap(uint8_t usb_led) {} // Call user matrix init, set default RGB colors and then // call the keymap's init function void matrix_init_user(void) { - userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); + userspace_config.raw = eeprom_read_dword(EECONFIG_USERSPACE); #ifdef BOOTLOADER_CATERINA @@ -143,7 +144,9 @@ void matrix_init_user(void) { #endif #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) - set_unicode_input_mode(UC_WINC); + if (eeprom_read_byte(EECONFIG_UNICODEMODE) != UC_WIN) { + set_unicode_input_mode(UC_WIN); + } #endif //UNICODE_ENABLE matrix_init_keymap(); } @@ -173,17 +176,12 @@ void shutdown_user (void) { shutdown_keymap(); } -void suspend_power_down_user(void) -{ +void suspend_power_down_user(void) { suspend_power_down_keymap(); } -void suspend_wakeup_init_user(void) -{ +void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); - #ifdef KEYBOARD_ergodox_ez - wait_ms(10); - #endif } @@ -216,7 +214,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // If console is enabled, it will print the matrix position and status of each key pressed #ifdef KEYLOGGER_ENABLE - xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); + #if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2) + xprintf("KL: col: %u, row: %u, pressed: %u\n", record->event.key.row, record->event.key.col, record->event.pressed); + #else + xprintf("KL: col: %u, row: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); + #endif #endif //KEYLOGGER_ENABLE switch (keycode) { @@ -249,7 +251,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader if (!record->event.pressed) { send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP -#if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU)) +#if defined(__ARM__) + ":dfu-util" +#elif defined(BOOTLOADER_DFU) ":dfu" #elif defined(BOOTLOADER_HALFKAY) ":teensy" @@ -291,7 +295,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // to save on firmware space, since it's limited. #ifdef MACROS_ENABLED case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros - if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } + if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeprom_update_dword(EECONFIG_USERSPACE, userspace_config.raw); } #ifdef RGBLIGHT_ENABLE userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); #endif //RGBLIGHT_ENABLE @@ -342,45 +346,40 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { register_code(KC_LCTL); tap(KC_C); unregister_code(KC_LCTL); -#ifdef AUDIO_ENABLE - PLAY_SONG(tone_copy); -#endif } else { // Tap, paste register_code(KC_LCTL); tap(KC_V); unregister_code(KC_LCTL); -#ifdef AUDIO_ENABLE - PLAY_SONG(tone_paste); -#endif } } return false; break; #ifdef UNICODE_ENABLE - case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻ + case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ if (record->event.pressed) { - register_code(KC_RSFT); - tap(KC_9); - unregister_code(KC_RSFT); - process_unicode((0x256F | QK_UNICODE), record); // Arm - process_unicode((0x00B0 | QK_UNICODE), record); // Eye - process_unicode((0x25A1 | QK_UNICODE), record); // Mouth - process_unicode((0x00B0 | QK_UNICODE), record); // Eye - register_code(KC_RSFT); - tap(KC_0); - unregister_code(KC_RSFT); - process_unicode((0x256F | QK_UNICODE), record); // Arm - tap(KC_SPC); - process_unicode((0x0361 | QK_UNICODE), record); // Flippy - tap(KC_SPC); - process_unicode((0x253B | QK_UNICODE), record); // Table - process_unicode((0x2501 | QK_UNICODE), record); // Table - process_unicode((0x253B | QK_UNICODE), record); // Table + send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); } return false; break; -#endif // UNICODE_ENABLE - + case UC_TABL: // ┬─┬ノ( º _ ºノ) + if (record->event.pressed) { + send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029"); + } + return false; + break; + case UC_SHRG: // ¯\_(ツ)_/¯ + if (record->event.pressed) { + send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); + } + return false; + break; + case UC_DISA: // ಠ_ಠ + if (record->event.pressed) { + send_unicode_hex_string("0CA0 005F 0CA0"); + } + return false; + break; +#endif } return process_record_keymap(keycode, record) && #ifdef RGBLIGHT_ENABLE diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index de8c3ba94..49e3fc870 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h @@ -19,9 +19,13 @@ along with this program. If not, see . #include "quantum.h" #include "version.h" #include "eeprom.h" +#include "send_unicode.h" + #ifdef RGB_MATRIX_ENABLE #include "rgb_matrix.h" #endif + + // Define layer names enum userspace_layers { _QWERTY = 0, @@ -59,19 +63,26 @@ inline void tap(uint16_t keycode){ register_code(keycode); unregister_code(keyco bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed); bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer); -#define EECONFIG_USERSPACE (uint8_t *)19 +#define EECONFIG_USERSPACE (uint32_t *)19 typedef union { - uint8_t raw; + uint32_t raw; struct { bool rgb_layer_change :1; bool is_overwatch :1; bool nuke_switch :1; + uint8_t unicode_mod :4; }; } userspace_config_t; +#if defined(KEYMAP_SAFE_RANGE) + #define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE +#else + #define PLACEHOLDER_SAFE_RANGE SAFE_RANGE +#endif + enum userspace_custom_keycodes { - EPRM = SAFE_RANGE, // Resets EEPROM do defaults (as in eeconfig_init) + EPRM = PLACEHOLDER_SAFE_RANGE, // Resets EEPROM do defaults (as in eeconfig_init) VRSN, // Prints QMK Firmware and board info KC_QWERTY, // Sets default layer to QWERTY KC_COLEMAK, // Sets default layer to COLEMAK @@ -99,13 +110,14 @@ enum userspace_custom_keycodes { KC_SECRET_5, // test5 KC_CCCV, // Hold to copy, tap to paste KC_NUKE, // NUCLEAR LAUNCH DETECTED!!! - -#ifdef UNICODE_ENABLE - UC_FLIP, // Table flip (not working?) -#endif //UNICODE_ENABLE + UC_FLIP, // (ಠ痊ಠ)┻━┻ + UC_TABL, // ┬─┬ノ( º _ ºノ) + UC_SHRG, // ¯\_(ツ)_/¯ + UC_DISA, // ಠ_ಠ NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes }; + #define LOWER MO(_LOWER) #define RAISE MO(_RAISE) #define ADJUST MO(_ADJUST) @@ -153,6 +165,8 @@ enum userspace_custom_keycodes { #define MG_NKRO MAGIC_TOGGLE_NKRO +#define UC_IRNY UC(0x2E2E) +#define UC_CLUE UC(0x203D) #ifdef TAP_DANCE_ENABLE enum { diff --git a/users/drashna/drashna_unicode.h b/users/drashna/drashna_unicode.h deleted file mode 100644 index 3d1bc03f9..000000000 --- a/users/drashna/drashna_unicode.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef UNICODE_USERSPACE_H -#define UNICODE_USERSPACE_H - - - -/* use X(n) to call the */ - -enum unicode_name { - THINK, // thinking face 🤔 - GRIN, // grinning face 😊 - SMRK, // smirk 😏 - WEARY, // good shit 😩 - UNAMU, // unamused 😒 - - SNEK, // snke 🐍 - PENGUIN, // 🐧 - DRAGON, // 🐉 - MONKEY, // 🐒 - CHICK, // 🐥 - BOAR, // 🐗 - - OKOK, // 👌 - EFFU, // 🖕 - INUP, // 👆 - THUP, // 👍 - THDN, // 👎 - - BBB, // dat B 🅱 - POO, // poop 💩 - HUNDR, // 100 💯 - EGGPL, // EGGPLANT 🍆 - WATER, // wet 💦 - TUMBLER, // 🥃 - - LIT, // fire 🔥 - BANG, // ‽ - IRONY, // ⸮ - DEGREE // ° -}; - - -const uint32_t PROGMEM unicode_map[] = { - [THINK] = 0x1F914, - [GRIN] = 0x1F600, - [BBB] = 0x1F171, - [POO] = 0x1F4A9, - [HUNDR] = 0x1F4AF, - [SMRK] = 0x1F60F, - [WEARY] = 0x1F629, - [EGGPL] = 0x1F346, - [WATER] = 0x1F4A6, - [LIT] = 0x1F525, - [UNAMU] = 0x1F612, - [SNEK] = 0x1F40D, - [PENGUIN] = 0x1F427, - [BOAR] = 0x1F417, - [MONKEY] = 0x1F412, - [CHICK] = 0x1F425, - [DRAGON] = 0x1F409, - [OKOK] = 0x1F44C, - [EFFU] = 0x1F595, - [INUP] = 0x1F446, - [THDN] = 0x1F44E, - [THUP] = 0x1F44D, - [TUMBLER] = 0x1F943, - [BANG] = 0x0203D, - [IRONY] = 0x02E2E, - [DEGREE] = 0x000B0 - }; - - #endif diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index 03c55b132..4a1a8de69 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -230,7 +230,7 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { userspace_config.rgb_layer_change ^= 1; xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); - eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); + eeprom_update_dword(EECONFIG_USERSPACE, userspace_config.raw); if (userspace_config.rgb_layer_change) { layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better) } @@ -243,7 +243,7 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { if (userspace_config.rgb_layer_change) { userspace_config.rgb_layer_change = false; xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); - eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); + eeprom_update_dword(EECONFIG_USERSPACE, userspace_config.raw); } } return true; break; @@ -273,6 +273,7 @@ void matrix_init_rgb(void) { default: rgblight_sethsv_noeeprom_cyan(); break; } + rgblight_mode_noeeprom(1); } } diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index e299f24a1..3d6213eff 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk @@ -1,4 +1,3 @@ - SRC += drashna.c ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") @@ -9,7 +8,7 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) SRC += tap_dances.c endif -EXTRAFLAGS += -flto +EXTRAFLAGS += -flto ifeq ($(strip $(NO_SECRETS)), yes) OPT_DEFS += -DNO_SECRETS @@ -37,3 +36,7 @@ ifdef CONSOLE_ENABLE OPT_DEFS += -DKEYLOGGER_ENABLE endif endif + +ifeq ($(strip $(UNICODE_ENABLE)), yes) + SRC += send_unicode.c +endif diff --git a/users/drashna/send_unicode.c b/users/drashna/send_unicode.c new file mode 100644 index 000000000..cacfe1dc8 --- /dev/null +++ b/users/drashna/send_unicode.c @@ -0,0 +1,58 @@ +// Written by konstantin: vomindoraan +#include "send_unicode.h" +#include +#include + +__attribute__((weak)) +void send_unicode_hex_string(const char* str) { + if (!str) { return; } // Safety net + + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower((unsigned char)*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + + str += n; // Move to the first ' ' (or '\0') after the current token + } +} + +// (ノಠ痊ಠ)ノ彡┻━┻ +// send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); + +//Old code +// (╯°□°)╯ ︵ ┻━┻ + #if 0 + register_code(KC_RSFT); + tap(KC_9); + unregister_code(KC_RSFT); + process_unicode((0x256F | QK_UNICODE), record); // Arm + process_unicode((0x00B0 | QK_UNICODE), record); // Eye + process_unicode((0x25A1 | QK_UNICODE), record); // Mouth + process_unicode((0x00B0 | QK_UNICODE), record); // Eye + register_code(KC_RSFT); + tap(KC_0); + unregister_code(KC_RSFT); + process_unicode((0x256F | QK_UNICODE), record); // Arm + tap(KC_SPC); + process_unicode((0x0361 | QK_UNICODE), record); // Flippy + tap(KC_SPC); + process_unicode((0x253B | QK_UNICODE), record); // Table + process_unicode((0x2501 | QK_UNICODE), record); // Table + process_unicode((0x253B | QK_UNICODE), record); // Table + #endif + + +// If you need a good converter: https://r12a.github.io/app-conversion/ diff --git a/users/drashna/send_unicode.h b/users/drashna/send_unicode.h new file mode 100644 index 000000000..818b6e571 --- /dev/null +++ b/users/drashna/send_unicode.h @@ -0,0 +1,71 @@ +#pragma once + +#include "quantum.h" + +void send_unicode_hex_string(const char* str); + +/* use X(n) to call the */ +#ifdef UNICODEMAP_ENABLE +enum unicode_name { + THINK, // thinking face 🤔 + GRIN, // grinning face 😊 + SMRK, // smirk 😏 + WEARY, // good shit 😩 + UNAMU, // unamused 😒 + + SNEK, // snke 🐍 + PENGUIN, // 🐧 + DRAGON, // 🐉 + MONKEY, // 🐒 + CHICK, // 🐥 + BOAR, // 🐗 + + OKOK, // 👌 + EFFU, // 🖕 + INUP, // 👆 + THUP, // 👍 + THDN, // 👎 + + BBB, // dat B 🅱 + POO, // poop 💩 + HUNDR, // 100 💯 + EGGPL, // EGGPLANT 🍆 + WATER, // wet 💦 + TUMBLER, // 🥃 + + LIT, // fire 🔥 + BANG, // ‽ + IRONY, // ⸮ + DEGREE // ° +}; + + +const uint32_t PROGMEM unicode_map[] = { + [THINK] = 0x1F914, + [GRIN] = 0x1F600, + [BBB] = 0x1F171, + [POO] = 0x1F4A9, + [HUNDR] = 0x1F4AF, + [SMRK] = 0x1F60F, + [WEARY] = 0x1F629, + [EGGPL] = 0x1F346, + [WATER] = 0x1F4A6, + [LIT] = 0x1F525, + [UNAMU] = 0x1F612, + [SNEK] = 0x1F40D, + [PENGUIN] = 0x1F427, + [BOAR] = 0x1F417, + [MONKEY] = 0x1F412, + [CHICK] = 0x1F425, + [DRAGON] = 0x1F409, + [OKOK] = 0x1F44C, + [EFFU] = 0x1F595, + [INUP] = 0x1F446, + [THDN] = 0x1F44E, + [THUP] = 0x1F44D, + [TUMBLER] = 0x1F943, + [BANG] = 0x0203D, + [IRONY] = 0x02E2E, + [DEGREE] = 0x000B0 + }; +#endif // UNICODEMAP_ENABLE -- cgit v1.2.3-24-g4f1b