diff options
author | QMK Bot <hello@qmk.fm> | 2021-05-13 16:29:39 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-05-13 16:29:39 +0000 |
commit | f8f0ca458d246d5db70cad3b504ab435ed5977b9 (patch) | |
tree | c3d069fe02d5e7cd4a112e28030a887899416372 /keyboards/redox/keymaps/jeherve/keymap.c | |
parent | 40907fa98a11d8a6416f0001da71f973e888d0d7 (diff) | |
parent | 6e5e34662bb83964d3d580a22cd16828fd37cfd5 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/redox/keymaps/jeherve/keymap.c')
-rw-r--r-- | keyboards/redox/keymaps/jeherve/keymap.c | 295 |
1 files changed, 152 insertions, 143 deletions
diff --git a/keyboards/redox/keymaps/jeherve/keymap.c b/keyboards/redox/keymaps/jeherve/keymap.c index f39b5a438a..226d14aae1 100644 --- a/keyboards/redox/keymaps/jeherve/keymap.c +++ b/keyboards/redox/keymaps/jeherve/keymap.c @@ -1,6 +1,21 @@ -#include QMK_KEYBOARD_H +/* +Copyright 2021 Jeremy Herve <jeremy@jeremy.hu> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ -extern keymap_config_t keymap_config; +#include QMK_KEYBOARD_H // Each layer gets a name for readability, which is then used in the keymap matrix below. // The underscores don't mean anything - you can have a layer called STUFF or any other name. @@ -12,126 +27,127 @@ extern keymap_config_t keymap_config; #define _INTER 3 #define _ADJUST 4 +// Define song. +#ifdef AUDIO_ENABLE +float tone_zelda[][2] = SONG(ZELDA_TREASURE); +#endif + enum custom_keycodes { - COLEMAK = SAFE_RANGE, - SYMB, - NAV, - INTER, - ADJUST, - // These use process_record_user() - M_BRACKET_LEFT, - M_BRACKET_RIGHT, - SHRUG, - WAVE, - YOSHI, - THUMB_UP, - NBSP, - INV_1P, - ALFRED + COLEMAK = SAFE_RANGE, + SYMB, + NAV, + INTER, + ADJUST, + // These use process_record_user() + M_BRACKET_LEFT, + M_BRACKET_RIGHT, + SHRUG, + WAVE, + YOSHI, + THUMB_UP, + INV_1P, + ALFRED }; // Is shift being held? Let's store this in a bool. static bool shift_held = false; bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch(keycode) { - case SHRUG: - if (record->event.pressed) { - send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); - } - return false; - break; - case INV_1P: - if (record->event.pressed) { - SEND_STRING(SS_DOWN(X_LGUI)SS_DOWN(X_LALT)SS_TAP(X_BSLASH)SS_UP(X_LGUI)SS_UP(X_LALT)); - } - return false; - break; - case ALFRED: - if (record->event.pressed) { - SEND_STRING(SS_DOWN(X_LALT)SS_TAP(X_SPACE)SS_UP(X_LALT)); - } - return false; - break; - case YOSHI: - if (record->event.pressed) { - SEND_STRING(":yellow_yoshi:"); - } - return false; - break; - case THUMB_UP: - if (record->event.pressed) { - SEND_STRING(SS_LALT("D83D+DC4D")); - } - return false; - break; - case WAVE: - if (record->event.pressed) { - SEND_STRING(SS_LALT("D83D+DC4B")); - } - return false; - break; - case NBSP: - if (record->event.pressed) { - SEND_STRING(" "); - } - return false; - break; - case KC_LSFT: - shift_held = record->event.pressed; - return true; - break; - case KC_RSFT: - shift_held = record->event.pressed; - return true; - break; - case M_BRACKET_LEFT: { - if (record->event.pressed) { - if (shift_held) { - unregister_code(KC_LSFT); - unregister_code(KC_RSFT); - register_code(KC_LBRC); - } else { - register_code(KC_LSFT); - register_code(KC_9); - } - } else { // Release the key - unregister_code(KC_LBRC); - unregister_code(KC_LSFT); - unregister_code(KC_RSFT); - unregister_code(KC_9); - } - return false; - break; - } - case M_BRACKET_RIGHT: { - if (record->event.pressed) { - if (shift_held) { - unregister_code(KC_LSFT); - unregister_code(KC_RSFT); - register_code(KC_RBRC); - } else { - register_code(KC_LSFT); - register_code(KC_0); - } - } else { // Release the key - unregister_code(KC_RBRC); - unregister_code(KC_LSFT); - unregister_code(KC_RSFT); - unregister_code(KC_0); - } - return false; - break; - } - } - return true; + switch (keycode) { + case SHRUG: + if (record->event.pressed) { + send_unicode_string("¯\\_(ツ)_/¯"); + } + return false; + break; + case INV_1P: + if (record->event.pressed) { + SEND_STRING(SS_DOWN(X_LGUI) SS_DOWN(X_LALT) SS_TAP(X_BSLASH) SS_UP(X_LGUI) SS_UP(X_LALT)); + } + return false; + break; + case ALFRED: + if (record->event.pressed) { + SEND_STRING(SS_DOWN(X_LALT) SS_TAP(X_SPACE) SS_UP(X_LALT)); + } + return false; + break; + case YOSHI: + if (record->event.pressed) { +#ifdef AUDIO_ENABLE + PLAY_SONG(tone_zelda); +#endif + SEND_STRING(":yellow_yoshi:"); + } + return false; + break; + case THUMB_UP: + if (record->event.pressed) { + register_unicode(0x1F44D); + } + return false; + break; + case WAVE: + if (record->event.pressed) { + register_unicode(0x1F44B); + } + return false; + break; + case KC_LSFT: + shift_held = record->event.pressed; + return true; + break; + case KC_RSFT: + shift_held = record->event.pressed; + return true; + break; + case M_BRACKET_LEFT: { + if (record->event.pressed) { + if (shift_held) { + unregister_code(KC_LSFT); + unregister_code(KC_RSFT); + register_code(KC_LBRC); + } else { + register_code(KC_LSFT); + register_code(KC_9); + } + } else { // Release the key + unregister_code(KC_LBRC); + unregister_code(KC_LSFT); + unregister_code(KC_RSFT); + unregister_code(KC_9); + } + return false; + break; + } + case M_BRACKET_RIGHT: { + if (record->event.pressed) { + if (shift_held) { + unregister_code(KC_LSFT); + unregister_code(KC_RSFT); + register_code(KC_RBRC); + } else { + register_code(KC_LSFT); + register_code(KC_0); + } + } else { // Release the key + unregister_code(KC_RBRC); + unregister_code(KC_LSFT); + unregister_code(KC_RSFT); + unregister_code(KC_0); + } + return false; + break; + } + } + return true; }; // Shortcut to make keymap more readable -#define KC_SYQT LT(_SYMB,KC_QUOT) -#define SYM_L MO(_SYMB) -#define MO_INTR MO(_INTER) -#define TT_ADJ TT(_ADJUST) +#define KC_SYQT LT(_SYMB, KC_QUOT) +#define SYM_L MO(_SYMB) +#define MO_INTR MO(_INTER) +#define TT_ADJ TT(_ADJUST) #define UC_00E0 UC(0x00E0) #define UC_00FC UC(0x00FC) @@ -147,6 +163,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { #define UC_0171 UC(0x0171) #define UC_00EA UC(0x00EA) #define UC_0151 UC(0x0151) +// Non-breaking space. +#define UC_00A0 UC(0x00a0) const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -202,7 +220,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ XXXXXXX ,UC_00E2 ,XXXXXXX ,UC_00E7 ,XXXXXXX ,XXXXXXX ,XXXXXXX ,_______ , _______ ,XXXXXXX ,XXXXXXX ,UC_0171 ,UC_00EA ,XXXXXXX ,UC_0151 ,XXXXXXX , //├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤ - _______ ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,_______ , _______ ,NBSP , XXXXXXX , _______ ,XXXXXXX ,XXXXXXX ,_______ + _______ ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,_______ , _______ ,UC_00A0 , XXXXXXX , _______ ,XXXXXXX ,XXXXXXX ,_______ //└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘ ), @@ -222,38 +240,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; -#ifdef AUDIO_ENABLE -float tone_colemak[][2] = SONG(ZELDA_TREASURE); -#endif - void persistent_default_layer_set(uint16_t default_layer) { - eeconfig_update_default_layer(default_layer); - default_layer_set(default_layer); + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); } -// Set unicode in Mac OS. -void eeconfig_init_user(void) { - set_unicode_input_mode(UC_OSX); -}; - // Change LED colors depending on the layer. -uint32_t layer_state_set_user(uint32_t state) { - switch (biton32(state)) { - case _SYMB: - rgblight_setrgb_orange(); - break; - case _NAV: - rgblight_setrgb_springgreen(); - break; - case _INTER: - rgblight_setrgb_teal(); - break; - case _ADJUST: - rgblight_setrgb_red(); - break; - default: // for any other layers, or the default layer - rgblight_setrgb_yellow(); - break; - } - return state; +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case _SYMB: + rgblight_setrgb_orange(); + break; + case _NAV: + rgblight_setrgb_springgreen(); + break; + case _INTER: + rgblight_setrgb_teal(); + break; + case _ADJUST: + rgblight_setrgb_red(); + break; + default: // for any other layers, or the default layer + rgblight_setrgb_yellow(); + break; + } + return state; }; |