diff options
| author | jonavin <71780717+Jonavin@users.noreply.github.com> | 2021-09-28 15:24:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-28 12:24:12 -0700 |
| commit | 705cd433c22aad00b12183eaa3bada50d90fd97b (patch) | |
| tree | d529e7d14aca455a8ed494f00ebe4707dac40af6 | |
| parent | 724ee240751fdfedf33d75fee10d2b97d9f9e3da (diff) | |
| download | qmk_firmware-705cd433c22aad00b12183eaa3bada50d90fd97b.tar.gz qmk_firmware-705cd433c22aad00b12183eaa3bada50d90fd97b.zip | |
[Keymap] fix NKRO - switch to get_mods() and refactor encoder action code (#14278)
Co-authored-by: Jonavin <=>
| -rw-r--r-- | keyboards/gmmk/pro/ansi/keymaps/jonavin/keymap.c | 37 | ||||
| -rw-r--r-- | keyboards/gmmk/pro/ansi/keymaps/jonavin/readme.md | 1 | ||||
| -rw-r--r-- | keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/keebio/quefrency/keymaps/jonavin/keymap.c | 55 | ||||
| -rwxr-xr-x | keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c | 75 | ||||
| -rw-r--r-- | keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | 89 | ||||
| -rw-r--r-- | users/jonavin/jonavin.c | 129 | ||||
| -rw-r--r-- | users/jonavin/jonavin.h | 12 | ||||
| -rw-r--r-- | users/jonavin/readme.md | 3 |
9 files changed, 213 insertions, 190 deletions
diff --git a/keyboards/gmmk/pro/ansi/keymaps/jonavin/keymap.c b/keyboards/gmmk/pro/ansi/keymaps/jonavin/keymap.c index 20a786feb..f37abfac3 100644 --- a/keyboards/gmmk/pro/ansi/keymaps/jonavin/keymap.c +++ b/keyboards/gmmk/pro/ansi/keymaps/jonavin/keymap.c | |||
| @@ -78,6 +78,43 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 78 | #endif // COLEMAK_LAYER_ENABLE | 78 | #endif // COLEMAK_LAYER_ENABLE |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | #if defined(ENCODER_ENABLE) && !defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality when not using userspace defaults | ||
| 82 | void encoder_action_rgbhue(bool clockwise) { | ||
| 83 | if (clockwise) | ||
| 84 | rgblight_increase_hue_noeeprom(); | ||
| 85 | else | ||
| 86 | rgblight_decrease_hue_noeeprom(); | ||
| 87 | } | ||
| 88 | |||
| 89 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 90 | uint8_t mods_state = get_mods(); | ||
| 91 | if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers | ||
| 92 | encoder_action_layerchange(clockwise); | ||
| 93 | } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up/dn | ||
| 94 | unregister_mods(MOD_BIT(KC_RSFT)); | ||
| 95 | encoder_action_navpage(clockwise); | ||
| 96 | register_mods(MOD_BIT(KC_RSFT)); | ||
| 97 | } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word | ||
| 98 | encoder_action_navword(clockwise); | ||
| 99 | } else if (mods_state & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, change rgb hue/colour | ||
| 100 | encoder_action_rgbhue(clockwise); | ||
| 101 | } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track | ||
| 102 | encoder_action_mediatrack(clockwise); | ||
| 103 | } else { | ||
| 104 | switch(get_highest_layer(layer_state)) { | ||
| 105 | case _FN1: | ||
| 106 | #ifdef IDLE_TIMEOUT_ENABLE | ||
| 107 | timeout_update_threshold(clockwise); | ||
| 108 | #endif | ||
| 109 | break; | ||
| 110 | default: | ||
| 111 | encoder_action_volume(clockwise); // Otherwise it just changes volume | ||
| 112 | break; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | return true; | ||
| 116 | } | ||
| 117 | #endif // ENCODER_ENABLE && !ENCODER_DEFAULTACTIONS_ENABLE | ||
| 81 | 118 | ||
| 82 | #ifdef RGB_MATRIX_ENABLE | 119 | #ifdef RGB_MATRIX_ENABLE |
| 83 | // Capslock, Scroll lock and Numlock indicator on Left side lights. | 120 | // Capslock, Scroll lock and Numlock indicator on Left side lights. |
diff --git a/keyboards/gmmk/pro/ansi/keymaps/jonavin/readme.md b/keyboards/gmmk/pro/ansi/keymaps/jonavin/readme.md index a6482baa5..2aa910e0c 100644 --- a/keyboards/gmmk/pro/ansi/keymaps/jonavin/readme.md +++ b/keyboards/gmmk/pro/ansi/keymaps/jonavin/readme.md | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | - holding Left shift, change layers | 12 | - holding Left shift, change layers |
| 13 | - holding right shift, Navigate page up/down | 13 | - holding right shift, Navigate page up/down |
| 14 | - holding Left Ctrl, navigate prev/next word | 14 | - holding Left Ctrl, navigate prev/next word |
| 15 | - holding Right Ctrl, changes RGB hue/colour | ||
| 15 | - holding Left Alt, change media prev/next track | 16 | - holding Left Alt, change media prev/next track |
| 16 | - default is change volume | 17 | - default is change volume |
| 17 | 18 | ||
diff --git a/keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk b/keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk index b06ae1b6a..81b84eea7 100644 --- a/keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk +++ b/keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk | |||
| @@ -6,6 +6,6 @@ BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite | |||
| 6 | TD_LSFT_CAPSLOCK_ENABLE = yes | 6 | TD_LSFT_CAPSLOCK_ENABLE = yes |
| 7 | IDLE_TIMEOUT_ENABLE = yes | 7 | IDLE_TIMEOUT_ENABLE = yes |
| 8 | STARTUP_NUMLOCK_ON = yes | 8 | STARTUP_NUMLOCK_ON = yes |
| 9 | ENCODER_DEFAULTACTIONS_ENABLE = yes | 9 | ENCODER_DEFAULTACTIONS_ENABLE = no |
| 10 | 10 | ||
| 11 | COLEMAK_LAYER_ENABLE = yes #Enable Colemak layer / set to no to disable | 11 | COLEMAK_LAYER_ENABLE = yes #Enable Colemak layer / set to no to disable |
diff --git a/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c b/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c index 721148f4d..415f554e2 100644 --- a/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c +++ b/keyboards/keebio/quefrency/keymaps/jonavin/keymap.c | |||
| @@ -57,46 +57,31 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | #ifdef ENCODER_ENABLE // Encoder Functionality | 59 | #ifdef ENCODER_ENABLE // Encoder Functionality |
| 60 | bool encoder_update_user(uint8_t index, bool clockwise) { | 60 | bool encoder_update_user(uint8_t index, bool clockwise) { |
| 61 | switch (index) | 61 | uint8_t mods_state = get_mods(); |
| 62 | { | 62 | switch (index) { |
| 63 | case 0: // first encoder (Left Macro set) | 63 | case 0: // first encoder (Left Macro set) |
| 64 | if (clockwise) { | 64 | encoder_action_navpage(clockwise); |
| 65 | tap_code(KC_PGDN); | 65 | break; |
| 66 | } else { | ||
| 67 | tap_code(KC_PGUP); | ||
| 68 | } | ||
| 69 | 66 | ||
| 70 | default: // other encoder (Top right) | 67 | default: // other encoder (Top right) |
| 71 | if ( clockwise ) { | 68 | if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding Left shift, change layers |
| 72 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, Page up | 69 | encoder_action_layerchange(clockwise); |
| 73 | unregister_mods(MOD_BIT(KC_LSFT)); | 70 | } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding Right shift, Page up |
| 74 | register_code(KC_PGDN); | 71 | unregister_mods(MOD_BIT(KC_RSFT)); |
| 75 | register_mods(MOD_BIT(KC_LSFT)); | 72 | encoder_action_navpage(clockwise); |
| 76 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word | 73 | register_mods(MOD_BIT(KC_RSFT)); |
| 77 | tap_code16(LCTL(KC_RGHT)); | 74 | } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word |
| 78 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track | 75 | encoder_action_navword(clockwise); |
| 79 | tap_code(KC_MEDIA_NEXT_TRACK); | 76 | } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track |
| 77 | encoder_action_mediatrack(clockwise); | ||
| 80 | } else { | 78 | } else { |
| 81 | tap_code(KC_VOLU); // Otherwise it just changes volume | 79 | encoder_action_volume(clockwise); // Otherwise it just changes volume |
| 82 | } | ||
| 83 | } else { | ||
| 84 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { | ||
| 85 | unregister_mods(MOD_BIT(KC_LSFT)); | ||
| 86 | register_code(KC_PGUP); | ||
| 87 | register_mods(MOD_BIT(KC_LSFT)); | ||
| 88 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word | ||
| 89 | tap_code16(LCTL(KC_LEFT)); | ||
| 90 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track | ||
| 91 | tap_code(KC_MEDIA_PREV_TRACK); | ||
| 92 | } else { | ||
| 93 | tap_code(KC_VOLD); | ||
| 94 | } | 80 | } |
| 81 | break; | ||
| 95 | } | 82 | } |
| 96 | break; | 83 | return true; |
| 97 | } | 84 | } |
| 98 | return true; | ||
| 99 | } | ||
| 100 | #endif | 85 | #endif |
| 101 | 86 | ||
| 102 | #ifdef RGBLIGHT_ENABLE | 87 | #ifdef RGBLIGHT_ENABLE |
diff --git a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c index 74811cbc3..22d26db3c 100755 --- a/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c +++ b/keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c | |||
| @@ -106,63 +106,48 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | #ifdef ENCODER_ENABLE // Encoder Functionality | 108 | #ifdef ENCODER_ENABLE // Encoder Functionality |
| 109 | uint8_t selected_layer = 0; | 109 | void encoder_action_selectkey(bool clockwise) { |
| 110 | if ( clockwise ) { | ||
| 111 | if ( selectedkey_idx < MAX_KEYSELECTION-1) { | ||
| 112 | selectedkey_idx ++; | ||
| 113 | } else { | ||
| 114 | // do nothing | ||
| 115 | } | ||
| 116 | } else if ( !clockwise ) { | ||
| 117 | if ( selectedkey_idx > 0){ | ||
| 118 | selectedkey_idx --; | ||
| 119 | } else { | ||
| 120 | // do nothing | ||
| 121 | } | ||
| 122 | } | ||
| 123 | set_selectedkey(selectedkey_idx); | ||
| 124 | } | ||
| 110 | 125 | ||
| 111 | bool encoder_update_user(uint8_t index, bool clockwise) { | 126 | bool encoder_update_user(uint8_t index, bool clockwise) { |
| 112 | #ifdef OLED_ENABLE | 127 | #ifdef OLED_ENABLE |
| 113 | oled_clear(); | 128 | oled_clear(); |
| 114 | oled_render(); | 129 | oled_render(); |
| 115 | #endif | 130 | #endif |
| 131 | uint8_t mods_state = get_mods(); | ||
| 116 | switch (index) { | 132 | switch (index) { |
| 117 | case 0: // This is the only encoder right now, keeping for consistency | 133 | case 0: // This is the only encoder right now, keeping for consistency |
| 118 | switch(get_highest_layer(layer_state)){ // special handling per layer | 134 | switch(get_highest_layer(layer_state)){ // special handling per layer |
| 119 | case _FN1: // on Fn layer select what the encoder does when pressed | 135 | case _FN1: // on Fn layer select what the encoder does when pressed |
| 120 | if (!keyboard_report->mods) { | 136 | if (!mods_state) { |
| 121 | if ( clockwise ) { | 137 | encoder_action_selectkey(clockwise); |
| 122 | if ( selectedkey_idx < MAX_KEYSELECTION-1) { | ||
| 123 | selectedkey_idx ++; | ||
| 124 | } else { | ||
| 125 | // do nothing | ||
| 126 | } | ||
| 127 | } else if ( !clockwise ) { | ||
| 128 | if ( selectedkey_idx > 0){ | ||
| 129 | selectedkey_idx --; | ||
| 130 | } else { | ||
| 131 | // do nothing | ||
| 132 | } | ||
| 133 | } | ||
| 134 | set_selectedkey(selectedkey_idx); | ||
| 135 | break; | 138 | break; |
| 136 | } else { | 139 | } else { |
| 137 | // continue to default | 140 | // continue to default |
| 138 | } | 141 | } |
| 139 | default: // all other layers | 142 | default: // all other layers |
| 140 | if ( clockwise ) { | 143 | if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers |
| 141 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers | 144 | encoder_action_layerchange(clockwise); |
| 142 | if(selected_layer < 3) { | 145 | } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word |
| 143 | selected_layer ++; | 146 | encoder_action_navword(clockwise); |
| 144 | layer_move(selected_layer); | 147 | } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track |
| 145 | } | 148 | encoder_action_mediatrack(clockwise); |
| 146 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word | 149 | } else { |
| 147 | tap_code16(LCTL(KC_RGHT)); | 150 | encoder_action_volume(clockwise); // Otherwise it just changes volume |
| 148 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track | ||
| 149 | tap_code(KC_MEDIA_NEXT_TRACK); | ||
| 150 | } else { | ||
| 151 | tap_code(KC_VOLU); // Otherwise it just changes volume | ||
| 152 | } | ||
| 153 | } else if ( !clockwise ) { | ||
| 154 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { | ||
| 155 | if (selected_layer > 0) { | ||
| 156 | selected_layer --; | ||
| 157 | layer_move(selected_layer); | ||
| 158 | } | ||
| 159 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word | ||
| 160 | tap_code16(LCTL(KC_LEFT)); | ||
| 161 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track | ||
| 162 | tap_code(KC_MEDIA_PREV_TRACK); | ||
| 163 | } else { | ||
| 164 | tap_code(KC_VOLD); | ||
| 165 | } | ||
| 166 | } | 151 | } |
| 167 | break; | 152 | break; |
| 168 | } | 153 | } |
| @@ -205,7 +190,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 205 | 190 | ||
| 206 | void oled_task_user(void) { | 191 | void oled_task_user(void) { |
| 207 | 192 | ||
| 208 | if ( IS_HOST_LED_OFF(USB_LED_NUM_LOCK) && IS_HOST_LED_OFF(USB_LED_CAPS_LOCK) && selected_layer == 0 && get_highest_layer(layer_state) == 0 ) { | 193 | if ( IS_HOST_LED_OFF(USB_LED_NUM_LOCK) && IS_HOST_LED_OFF(USB_LED_CAPS_LOCK) && get_selected_layer() == 0 && get_highest_layer(layer_state) == 0 ) { |
| 209 | render_name(); | 194 | render_name(); |
| 210 | clear_screen = true; | 195 | clear_screen = true; |
| 211 | } else { | 196 | } else { |
| @@ -217,7 +202,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 217 | render_logo(); | 202 | render_logo(); |
| 218 | oled_set_cursor(8,2); | 203 | oled_set_cursor(8,2); |
| 219 | char fn_str[12]; | 204 | char fn_str[12]; |
| 220 | switch(selected_layer){ | 205 | switch(get_selected_layer()){ |
| 221 | case 0: | 206 | case 0: |
| 222 | oled_write_P(PSTR("BASE"), false); | 207 | oled_write_P(PSTR("BASE"), false); |
| 223 | break; | 208 | break; |
| @@ -237,7 +222,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 237 | } | 222 | } |
| 238 | oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); | 223 | oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); |
| 239 | oled_set_cursor(8,3); | 224 | oled_set_cursor(8,3); |
| 240 | if (get_highest_layer(layer_state) == selected_layer) { | 225 | if (get_highest_layer(layer_state) == get_selected_layer()) { |
| 241 | oled_write_P(PSTR(" "), false); | 226 | oled_write_P(PSTR(" "), false); |
| 242 | } else { | 227 | } else { |
| 243 | switch (get_highest_layer(layer_state)) { | 228 | switch (get_highest_layer(layer_state)) { |
diff --git a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c index 001abc502..39e6ac87e 100644 --- a/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c +++ b/keyboards/mechwild/murphpad/keymaps/jonavin/keymap.c | |||
| @@ -144,67 +144,52 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | #ifdef ENCODER_ENABLE // Encoder Functionality | 146 | #ifdef ENCODER_ENABLE // Encoder Functionality |
| 147 | uint8_t selected_layer = 0; | 147 | void encoder_action_selectkey(bool clockwise) { |
| 148 | if ( clockwise ) { | ||
| 149 | if ( selectedkey_idx < MAX_KEYSELECTION-1) { | ||
| 150 | selectedkey_idx ++; | ||
| 151 | } else { | ||
| 152 | // do nothing | ||
| 153 | } | ||
| 154 | } else if ( !clockwise ) { | ||
| 155 | if ( selectedkey_idx > 0){ | ||
| 156 | selectedkey_idx --; | ||
| 157 | } else { | ||
| 158 | // do nothing | ||
| 159 | } | ||
| 160 | } | ||
| 161 | set_selectedkey(selectedkey_idx); | ||
| 162 | } | ||
| 148 | 163 | ||
| 149 | bool encoder_update_user(uint8_t index, bool clockwise) { | 164 | bool encoder_update_user(uint8_t index, bool clockwise) { |
| 150 | #ifdef OLED_ENABLE | 165 | #ifdef OLED_ENABLE |
| 151 | oled_clear(); | 166 | oled_clear(); |
| 152 | oled_render(); | 167 | oled_render(); |
| 153 | #endif | 168 | #endif |
| 169 | uint8_t mods_state = get_mods(); | ||
| 154 | switch (index) { | 170 | switch (index) { |
| 155 | case 0: // This is the only encoder right now, keeping for consistency | 171 | case 0: // This is the only encoder right now, keeping for consistency |
| 156 | switch(get_highest_layer(layer_state)){ // special handling per layer | 172 | switch(get_highest_layer(layer_state)){ // special handling per layer |
| 157 | case _FN1: // on Fn layer select what the encoder does when pressed | 173 | case _FN1: // on Fn layer select what the encoder does when pressed |
| 158 | if (!keyboard_report->mods) { | 174 | if (!mods_state) { |
| 159 | if ( clockwise ) { | 175 | encoder_action_selectkey(clockwise); |
| 160 | if ( selectedkey_idx < MAX_KEYSELECTION-1) { | ||
| 161 | selectedkey_idx ++; | ||
| 162 | } else { | ||
| 163 | // do nothing | ||
| 164 | } | ||
| 165 | } else if ( !clockwise ) { | ||
| 166 | if ( selectedkey_idx > 0){ | ||
| 167 | selectedkey_idx --; | ||
| 168 | } else { | ||
| 169 | // do nothing | ||
| 170 | } | ||
| 171 | } | ||
| 172 | set_selectedkey(selectedkey_idx); | ||
| 173 | break; | ||
| 174 | } else { | ||
| 175 | // continue to default | ||
| 176 | } | ||
| 177 | default: // all other layers | ||
| 178 | if ( clockwise ) { | ||
| 179 | if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding Right Shift, encoder changes layers | ||
| 180 | if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT-1)) { | ||
| 181 | selected_layer ++; | ||
| 182 | layer_move(selected_layer); | ||
| 183 | } | ||
| 184 | } else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next word | ||
| 185 | tap_code16(LCTL(KC_RGHT)); | ||
| 186 | } else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next track | ||
| 187 | tap_code(KC_MEDIA_NEXT_TRACK); | ||
| 188 | } else { | ||
| 189 | tap_code(KC_VOLU); // Otherwise it just changes volume | ||
| 190 | } | ||
| 191 | } else if ( !clockwise ) { | ||
| 192 | if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { | ||
| 193 | if (selected_layer > 0) { | ||
| 194 | selected_layer --; | ||
| 195 | layer_move(selected_layer); | ||
| 196 | } | ||
| 197 | } else if (keyboard_report->mods & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate previous word | ||
| 198 | tap_code16(LCTL(KC_LEFT)); | ||
| 199 | } else if (keyboard_report->mods & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media previous track | ||
| 200 | tap_code(KC_MEDIA_PREV_TRACK); | ||
| 201 | } else { | ||
| 202 | tap_code(KC_VOLD); | ||
| 203 | } | ||
| 204 | } | ||
| 205 | break; | 176 | break; |
| 177 | } else { | ||
| 178 | // continue to default | ||
| 179 | } | ||
| 180 | default: // all other layers | ||
| 181 | if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, encoder changes layers | ||
| 182 | encoder_action_layerchange(clockwise); | ||
| 183 | } else if (mods_state & MOD_BIT(KC_RCTL)) { // if holding Right Ctrl, navigate next/prev word | ||
| 184 | encoder_action_navword(clockwise); | ||
| 185 | } else if (mods_state & MOD_BIT(KC_RALT)) { // if holding Right Alt, change media next/prev track | ||
| 186 | encoder_action_mediatrack(clockwise); | ||
| 187 | } else { | ||
| 188 | encoder_action_volume(clockwise); // Otherwise it just changes volume | ||
| 206 | } | 189 | } |
| 207 | break; | 190 | break; |
| 191 | } | ||
| 192 | break; | ||
| 208 | } | 193 | } |
| 209 | return true; | 194 | return true; |
| 210 | } | 195 | } |
| @@ -232,7 +217,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 232 | 217 | ||
| 233 | render_logo(); | 218 | render_logo(); |
| 234 | oled_set_cursor(8,2); | 219 | oled_set_cursor(8,2); |
| 235 | switch(selected_layer){ | 220 | switch(get_selected_layer()){ |
| 236 | case _BASE: | 221 | case _BASE: |
| 237 | oled_write_P(PSTR("BASE"), false); | 222 | oled_write_P(PSTR("BASE"), false); |
| 238 | break; | 223 | break; |
| @@ -257,7 +242,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | |||
| 257 | } | 242 | } |
| 258 | oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); | 243 | oled_write_P(keymap_config.no_gui ? PSTR(" WL") : PSTR(" "), false); |
| 259 | oled_set_cursor(8,3); | 244 | oled_set_cursor(8,3); |
| 260 | if (get_highest_layer(layer_state) == selected_layer) { | 245 | if (get_highest_layer(layer_state) == get_selected_layer()) { |
| 261 | oled_write_P(PSTR(" "), false); | 246 | oled_write_P(PSTR(" "), false); |
| 262 | } else { | 247 | } else { |
| 263 | switch (get_highest_layer(layer_state)) { | 248 | switch (get_highest_layer(layer_state)) { |
diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c index bd6c55e9f..6ecadc7b4 100644 --- a/users/jonavin/jonavin.c +++ b/users/jonavin/jonavin.c | |||
| @@ -104,7 +104,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 104 | #endif // IDLE_TIMEOUT_ENABLE | 104 | #endif // IDLE_TIMEOUT_ENABLE |
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | #if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality | 107 | #ifdef ENCODER_ENABLE |
| 108 | #ifndef DYNAMIC_KEYMAP_LAYER_COUNT | 108 | #ifndef DYNAMIC_KEYMAP_LAYER_COUNT |
| 109 | #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere | 109 | #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere |
| 110 | #endif | 110 | #endif |
| @@ -112,67 +112,86 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 112 | #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders | 112 | #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders |
| 113 | #endif | 113 | #endif |
| 114 | 114 | ||
| 115 | uint8_t selected_layer = 0; | 115 | void encoder_action_volume(bool clockwise) { |
| 116 | if (clockwise) | ||
| 117 | tap_code(KC_VOLU); | ||
| 118 | else | ||
| 119 | tap_code(KC_VOLD); | ||
| 120 | } | ||
| 116 | 121 | ||
| 117 | __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; } | 122 | void encoder_action_mediatrack(bool clockwise) { |
| 123 | if (clockwise) | ||
| 124 | tap_code(KC_MEDIA_NEXT_TRACK); | ||
| 125 | else | ||
| 126 | tap_code(KC_MEDIA_PREV_TRACK); | ||
| 127 | } | ||
| 118 | 128 | ||
| 119 | bool encoder_update_user(uint8_t index, bool clockwise) { | 129 | void encoder_action_navword(bool clockwise) { |
| 120 | if (!encoder_update_keymap(index, clockwise)) { return false; } | 130 | if (clockwise) |
| 121 | if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match | 131 | tap_code16(LCTL(KC_RGHT)); |
| 122 | if ( clockwise ) { | 132 | else |
| 123 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers | 133 | tap_code16(LCTL(KC_LEFT)); |
| 124 | if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { | 134 | } |
| 125 | selected_layer ++; | 135 | |
| 126 | layer_move(selected_layer); | 136 | void encoder_action_navpage(bool clockwise) { |
| 127 | } | 137 | if (clockwise) |
| 128 | } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up | 138 | tap_code16(KC_PGUP); |
| 129 | unregister_mods(MOD_BIT(KC_RSFT)); | 139 | else |
| 130 | register_code(KC_PGDN); | 140 | tap_code16(KC_PGDN); |
| 131 | register_mods(MOD_BIT(KC_RSFT)); | 141 | } |
| 132 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word | 142 | |
| 133 | tap_code16(LCTL(KC_RGHT)); | 143 | // LAYER HANDLING |
| 134 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track | 144 | uint8_t selected_layer = 0; |
| 135 | tap_code(KC_MEDIA_NEXT_TRACK); | 145 | |
| 136 | } else { | 146 | uint8_t get_selected_layer(void) { |
| 137 | switch (selected_layer) { | 147 | return selected_layer; |
| 138 | case _FN1: | 148 | } |
| 139 | #ifdef IDLE_TIMEOUT_ENABLE | 149 | |
| 140 | timeout_update_threshold(true); | 150 | void encoder_action_layerchange(bool clockwise) { |
| 141 | #endif | 151 | if (clockwise) { |
| 142 | break; | 152 | if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { |
| 143 | default: | 153 | selected_layer ++; |
| 144 | tap_code(KC_VOLU); // Otherwise it just changes volume | 154 | layer_move(selected_layer); |
| 145 | break; | ||
| 146 | } | ||
| 147 | } | 155 | } |
| 148 | } else { | 156 | } else { |
| 149 | if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { | 157 | if (selected_layer > 0) { |
| 150 | if (selected_layer > 0) { | 158 | selected_layer --; |
| 151 | selected_layer --; | 159 | layer_move(selected_layer); |
| 152 | layer_move(selected_layer); | ||
| 153 | } | ||
| 154 | } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { | ||
| 155 | unregister_mods(MOD_BIT(KC_RSFT)); | ||
| 156 | register_code(KC_PGUP); | ||
| 157 | register_mods(MOD_BIT(KC_RSFT)); | ||
| 158 | } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word | ||
| 159 | tap_code16(LCTL(KC_LEFT)); | ||
| 160 | } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track | ||
| 161 | tap_code(KC_MEDIA_PREV_TRACK); | ||
| 162 | } else { | ||
| 163 | switch (selected_layer) { | ||
| 164 | case _FN1: | ||
| 165 | #ifdef IDLE_TIMEOUT_ENABLE | ||
| 166 | timeout_update_threshold(false); | ||
| 167 | #endif | ||
| 168 | break; | ||
| 169 | default: | ||
| 170 | tap_code(KC_VOLD); | ||
| 171 | break; | ||
| 172 | } | ||
| 173 | } | 160 | } |
| 174 | } | 161 | } |
| 162 | } | ||
| 163 | #endif // ENCODER_ENABLE | ||
| 164 | |||
| 165 | #if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality | ||
| 175 | 166 | ||
| 167 | __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; } | ||
| 168 | |||
| 169 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 170 | if (!encoder_update_keymap(index, clockwise)) { return false; } | ||
| 171 | if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match | ||
| 172 | uint8_t mods_state = get_mods(); | ||
| 173 | if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers | ||
| 174 | encoder_action_layerchange(clockwise); | ||
| 175 | } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up/dn | ||
| 176 | unregister_mods(MOD_BIT(KC_RSFT)); | ||
| 177 | encoder_action_navpage(clockwise); | ||
| 178 | register_mods(MOD_BIT(KC_RSFT)); | ||
| 179 | } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word | ||
| 180 | encoder_action_navword(clockwise); | ||
| 181 | } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track | ||
| 182 | encoder_action_mediatrack(clockwise); | ||
| 183 | } else { | ||
| 184 | switch(get_highest_layer(layer_state)) { | ||
| 185 | case _FN1: | ||
| 186 | #ifdef IDLE_TIMEOUT_ENABLE | ||
| 187 | timeout_update_threshold(clockwise); | ||
| 188 | #endif | ||
| 189 | break; | ||
| 190 | default: | ||
| 191 | encoder_action_volume(clockwise); // Otherwise it just changes volume | ||
| 192 | break; | ||
| 193 | } | ||
| 194 | } | ||
| 176 | return true; | 195 | return true; |
| 177 | } | 196 | } |
| 178 | #endif // ENCODER_ENABLE | 197 | #endif // ENCODER_ENABLE |
diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h index 5f467bc84..316483940 100644 --- a/users/jonavin/jonavin.h +++ b/users/jonavin/jonavin.h | |||
| @@ -58,6 +58,18 @@ enum custom_user_keycodes { | |||
| 58 | #endif // TD_LSFT_CAPSLOCK_ENABLE | 58 | #endif // TD_LSFT_CAPSLOCK_ENABLE |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | // ENCODER ACTIONS | ||
| 62 | #ifdef ENCODER_ENABLE | ||
| 63 | void encoder_action_volume(bool clockwise); | ||
| 64 | void encoder_action_mediatrack(bool clockwise); | ||
| 65 | void encoder_action_navword(bool clockwise); | ||
| 66 | void encoder_action_navpage(bool clockwise); | ||
| 67 | |||
| 68 | uint8_t get_selected_layer(void); | ||
| 69 | void encoder_action_layerchange(bool clockwise); | ||
| 70 | #endif // ENCODER_ENABLE | ||
| 71 | |||
| 72 | |||
| 61 | #ifdef RGB_MATRIX_ENABLE | 73 | #ifdef RGB_MATRIX_ENABLE |
| 62 | //RGB custom colours | 74 | //RGB custom colours |
| 63 | #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps | 75 | #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps |
diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md index 97fff6520..c029796b4 100644 --- a/users/jonavin/readme.md +++ b/users/jonavin/readme.md | |||
| @@ -65,11 +65,10 @@ KEYMAP LEVEL ADDITIONAL PROCESSING FUNCTIONS | |||
| 65 | void keyboard_post_init_keymap(void) | 65 | void keyboard_post_init_keymap(void) |
| 66 | 66 | ||
| 67 | LIST OF COMPATIBLE KEYMAPS | 67 | LIST OF COMPATIBLE KEYMAPS |
| 68 | - gmmk/pro | ||
| 69 | - gmmk/pro/ansi | 68 | - gmmk/pro/ansi |
| 70 | - keebio/quefrency/rev3 | 69 | - keebio/quefrency/rev3 |
| 71 | - mechwild/mercutio | 70 | - mechwild/mercutio |
| 72 | - mechwild/murphpad (*) | 71 | - mechwild/murphpad |
| 73 | - mechwild/OBE (*) | 72 | - mechwild/OBE (*) |
| 74 | - nopunin10did/kastenwagen (*) | 73 | - nopunin10did/kastenwagen (*) |
| 75 | 74 | ||
