diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2019-07-25 13:56:29 -0500 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-07-25 11:56:29 -0700 |
| commit | 20c0533c4c66b9d222b6ced2fad3ec6be6cad76e (patch) | |
| tree | 2cceb641e573cafeb6ee68f5083fb532ab80cd93 /users/xulkal | |
| parent | a747953dfae85d3bdfdfe205fc3d4ae6f8d1fe05 (diff) | |
| download | qmk_firmware-20c0533c4c66b9d222b6ced2fad3ec6be6cad76e.tar.gz qmk_firmware-20c0533c4c66b9d222b6ced2fad3ec6be6cad76e.zip | |
[User] Xulkal Keymaps Update (#6392)
* Xulkal changes
Refactor rgb & encoder menu
Hadron Keymap
Refactor oled menu
* Fixing horizontal OLED data display
* Reverting changes to take to separate prs
Diffstat (limited to 'users/xulkal')
| -rw-r--r-- | users/xulkal/custom_encoder.c | 67 | ||||
| -rw-r--r-- | users/xulkal/custom_keycodes.h | 12 | ||||
| -rw-r--r-- | users/xulkal/custom_oled.c | 207 | ||||
| -rw-r--r-- | users/xulkal/custom_rgb.c | 64 | ||||
| -rw-r--r-- | users/xulkal/custom_rgb.h | 14 | ||||
| -rw-r--r-- | users/xulkal/custom_tap_dance.c | 16 | ||||
| -rw-r--r-- | users/xulkal/custom_tap_dance.h | 7 | ||||
| -rw-r--r-- | users/xulkal/layouts.h | 4 | ||||
| -rw-r--r-- | users/xulkal/process_records.c | 35 | ||||
| -rw-r--r-- | users/xulkal/process_records.h | 1 | ||||
| -rw-r--r-- | users/xulkal/rules.mk | 20 |
11 files changed, 310 insertions, 137 deletions
diff --git a/users/xulkal/custom_encoder.c b/users/xulkal/custom_encoder.c index 076a9891a..cd029944f 100644 --- a/users/xulkal/custom_encoder.c +++ b/users/xulkal/custom_encoder.c | |||
| @@ -1,13 +1,72 @@ | |||
| 1 | #include "custom_encoder.h" | 1 | #include "custom_encoder.h" |
| 2 | #include "custom_keycodes.h" | ||
| 3 | |||
| 4 | #ifdef RGB_OLED_MENU | ||
| 5 | #include "custom_rgb.h" | ||
| 6 | |||
| 7 | // I'm lazy and like constants over calculations, also using it as a compile time check | ||
| 8 | #if defined(RGB_MATRIX_ENABLE) | ||
| 9 | #define RGB_FUNCTION_COUNT 6 | ||
| 10 | #elif defined(RGBLIGHT_ENABLE) | ||
| 11 | #define RGB_FUNCTION_COUNT 5 | ||
| 12 | #endif | ||
| 13 | |||
| 14 | typedef void (*rgb_f)(void); | ||
| 15 | |||
| 16 | const rgb_f rgb_functions[RGB_FUNCTION_COUNT][2] = { | ||
| 17 | #if defined(RGB_MATRIX_ENABLE) | ||
| 18 | { rgb_matrix_increase_hue, rgb_matrix_decrease_hue }, | ||
| 19 | { rgb_matrix_increase_sat, rgb_matrix_decrease_sat }, | ||
| 20 | { rgb_matrix_increase_val, rgb_matrix_decrease_val }, | ||
| 21 | { rgb_matrix_increase_speed, rgb_matrix_decrease_speed }, | ||
| 22 | { rgb_matrix_step, rgb_matrix_step_reverse }, | ||
| 23 | { rgb_matrix_increase_flags, rgb_matrix_decrease_flags } | ||
| 24 | #elif defined(RGBLIGHT_ENABLE) | ||
| 25 | { rgblight_increase_hue, rgblight_decrease_hue }, | ||
| 26 | { rgblight_increase_sat, rgblight_decrease_sat }, | ||
| 27 | { rgblight_increase_val, rgblight_decrease_val }, | ||
| 28 | { rgblight_increase_speed, rgblight_decrease_speed }, | ||
| 29 | { rgblight_step, rgblight_step_reverse } | ||
| 30 | #endif | ||
| 31 | }; | ||
| 32 | |||
| 33 | // Start at the end for mode | ||
| 34 | uint8_t rgb_encoder_state = 4; | ||
| 35 | |||
| 36 | bool process_record_encoder(uint16_t keycode, keyrecord_t *record) | ||
| 37 | { | ||
| 38 | switch (keycode) | ||
| 39 | { | ||
| 40 | case RGB_ENC: | ||
| 41 | if (record->event.pressed) { | ||
| 42 | if (get_mods() & MOD_MASK_SHIFT) { | ||
| 43 | rgb_encoder_state = (rgb_encoder_state - 1); | ||
| 44 | if (rgb_encoder_state >= RGB_FUNCTION_COUNT) | ||
| 45 | rgb_encoder_state = RGB_FUNCTION_COUNT - 1; | ||
| 46 | } else { | ||
| 47 | rgb_encoder_state = (rgb_encoder_state + 1) % RGB_FUNCTION_COUNT; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | return false; | ||
| 51 | } | ||
| 52 | return true; | ||
| 53 | } | ||
| 54 | #endif // RGB_OLED_MENU | ||
| 2 | 55 | ||
| 3 | #ifdef ENCODER_ENABLE | ||
| 4 | const uint16_t PROGMEM encoders[][2] = { | 56 | const uint16_t PROGMEM encoders[][2] = { |
| 5 | { KC_PGUP, KC_PGDN }, | 57 | { KC_PGUP, KC_PGDN }, |
| 6 | { KC_DOWN, KC_UP } | 58 | { KC_VOLU, KC_VOLD } |
| 7 | }; | 59 | }; |
| 8 | 60 | ||
| 9 | void encoder_update_user(uint8_t index, bool clockwise) | 61 | void encoder_update_user(uint8_t index, bool clockwise) |
| 10 | { | 62 | { |
| 11 | tap_code16(pgm_read_word(&encoders[index][clockwise])); | 63 | if (!is_keyboard_master()) |
| 64 | return; | ||
| 65 | |||
| 66 | #ifdef RGB_OLED_MENU | ||
| 67 | if (index == RGB_OLED_MENU) | ||
| 68 | (*rgb_functions[rgb_encoder_state][clockwise])(); | ||
| 69 | else | ||
| 70 | #endif // RGB_OLED_MENU | ||
| 71 | tap_code16(pgm_read_word(&encoders[index][clockwise])); | ||
| 12 | } | 72 | } |
| 13 | #endif | ||
diff --git a/users/xulkal/custom_keycodes.h b/users/xulkal/custom_keycodes.h index d4ae0bd47..7ced92bf4 100644 --- a/users/xulkal/custom_keycodes.h +++ b/users/xulkal/custom_keycodes.h | |||
| @@ -10,6 +10,9 @@ enum custom_keycodes { | |||
| 10 | TD_DOT, | 10 | TD_DOT, |
| 11 | TD_MAX, | 11 | TD_MAX, |
| 12 | #endif | 12 | #endif |
| 13 | #ifdef ENCODER_ENABLE | ||
| 14 | RGB_ENC, | ||
| 15 | #endif | ||
| 13 | KEYMAP_SAFE_RANGE | 16 | KEYMAP_SAFE_RANGE |
| 14 | }; | 17 | }; |
| 15 | 18 | ||
| @@ -26,3 +29,12 @@ enum custom_keycodes { | |||
| 26 | 29 | ||
| 27 | #define LOWER MO(_LOWER) | 30 | #define LOWER MO(_LOWER) |
| 28 | #define RAISE MO(_RAISE) | 31 | #define RAISE MO(_RAISE) |
| 32 | |||
| 33 | |||
| 34 | #ifdef ENCODER_ENABLE | ||
| 35 | #define KC_ENC1 RGB_ENC | ||
| 36 | #define KC_ENC2 KC_MPLY | ||
| 37 | #else | ||
| 38 | #define KC_ENC1 RGB_RMOD | ||
| 39 | #define KC_ENC2 RGB_MOD | ||
| 40 | #endif | ||
diff --git a/users/xulkal/custom_oled.c b/users/xulkal/custom_oled.c index 7280ef701..448e6ca10 100644 --- a/users/xulkal/custom_oled.c +++ b/users/xulkal/custom_oled.c | |||
| @@ -3,12 +3,15 @@ | |||
| 3 | 3 | ||
| 4 | #include <stdio.h> | 4 | #include <stdio.h> |
| 5 | 5 | ||
| 6 | #ifdef OLED_DRIVER_ENABLE | ||
| 7 | |||
| 8 | #ifdef RGBLIGHT_ENABLE | 6 | #ifdef RGBLIGHT_ENABLE |
| 9 | rgblight_config_t rgblight_config; | 7 | rgblight_config_t rgblight_config; |
| 10 | #endif | 8 | #endif |
| 11 | 9 | ||
| 10 | #if KEYBOARD_helix_rev2 | ||
| 11 | extern uint8_t is_master; | ||
| 12 | bool is_keyboard_master(void) { return is_master; } | ||
| 13 | #endif | ||
| 14 | |||
| 12 | static void render_logo(void) | 15 | static void render_logo(void) |
| 13 | { | 16 | { |
| 14 | static const char PROGMEM font_logo[] = { | 17 | static const char PROGMEM font_logo[] = { |
| @@ -18,21 +21,38 @@ static void render_logo(void) | |||
| 18 | oled_write_P(font_logo, false); | 21 | oled_write_P(font_logo, false); |
| 19 | } | 22 | } |
| 20 | 23 | ||
| 21 | #if defined(OLED_90ROTATION) | 24 | static void render_icon(void) |
| 22 | |||
| 23 | // TODO: Need to define this function / extern only for helix based split common keyboards | ||
| 24 | extern uint8_t is_master; | ||
| 25 | bool is_keyboard_master(void) | ||
| 26 | { | 25 | { |
| 27 | return is_master; | 26 | #ifdef OLED_90ROTATION |
| 27 | static const char PROGMEM font_icon[] = { | ||
| 28 | 0x9b,0x9c,0x9d,0x9e,0x9f, | ||
| 29 | 0xbb,0xbc,0xbd,0xbe,0xbf, | ||
| 30 | 0xdb,0xdc,0xdd,0xde,0xdf,0 | ||
| 31 | }; | ||
| 32 | #else | ||
| 33 | static const char PROGMEM font_icon[] = { | ||
| 34 | // Use \r (0x0d) to jump to the next line without clearing the rest of the current line | ||
| 35 | 0x9b,0x9c,0x9d,0x9e,0x9f,0x0d, | ||
| 36 | 0xbb,0xbc,0xbd,0xbe,0xbf,0x0d, | ||
| 37 | 0xdb,0xdc,0xdd,0xde,0xdf,0 | ||
| 38 | }; | ||
| 39 | #endif | ||
| 40 | oled_write_P(font_icon, false); | ||
| 28 | } | 41 | } |
| 29 | 42 | ||
| 30 | static void render_layer(uint8_t layer) | 43 | static void render_layer(void) |
| 31 | { | 44 | { |
| 45 | uint8_t layer = layer_state ? biton(layer_state) : biton32(default_layer_state); | ||
| 46 | #ifdef OLED_90ROTATION | ||
| 47 | oled_write_P(PSTR("Layer"), false); | ||
| 48 | #else | ||
| 49 | oled_write_P(PSTR("Layer: "), false); | ||
| 50 | #endif | ||
| 51 | |||
| 32 | switch (layer) | 52 | switch (layer) |
| 33 | { | 53 | { |
| 34 | case _QWERTY: | 54 | case _QWERTY: |
| 35 | oled_write_P(PSTR("DFLT "), false); | 55 | oled_write_P(PSTR("BASE "), false); |
| 36 | break; | 56 | break; |
| 37 | #ifndef GAMELAYER_DISABLE | 57 | #ifndef GAMELAYER_DISABLE |
| 38 | case _GAME: | 58 | case _GAME: |
| @@ -53,125 +73,110 @@ static void render_layer(uint8_t layer) | |||
| 53 | } | 73 | } |
| 54 | } | 74 | } |
| 55 | 75 | ||
| 56 | static void render_status(void) | 76 | static void render_keyboard_leds(void) |
| 57 | { | 77 | { |
| 58 | // Render to mode icon | 78 | // Host Keyboard LED Status |
| 59 | static const char PROGMEM mode_logo[2][4] = { | 79 | uint8_t led_state = host_keyboard_leds(); |
| 60 | {0x97,0x98,0x0a,0}, | 80 | #ifdef OLED_90ROTATION |
| 61 | {0xb7,0xb8,0x0a,0} }; | 81 | oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUMLK") : PSTR(" "), false); |
| 62 | 82 | oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false); | |
| 63 | oled_write_P(mode_logo[0], false); | 83 | oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false); |
| 64 | oled_write_P(mode_logo[1], false); | 84 | #else |
| 85 | oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUM ") : PSTR(" "), false); | ||
| 86 | oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR(" "), false); | ||
| 87 | oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRL") : PSTR(" "), false); | ||
| 88 | #endif | ||
| 89 | } | ||
| 65 | 90 | ||
| 66 | oled_write_P(PSTR("Layer"), false); | 91 | #ifdef RGB_OLED_MENU |
| 67 | uint8_t layer = biton(layer_state); | 92 | extern uint8_t rgb_encoder_state; |
| 68 | if (layer != _QWERTY) | 93 | #endif |
| 69 | render_layer(layer); | ||
| 70 | else | ||
| 71 | render_layer(biton32(default_layer_state)); | ||
| 72 | 94 | ||
| 73 | // Host Keyboard LED Status | 95 | #if defined(OLED_90ROTATION) |
| 74 | uint8_t led_usb_state = host_keyboard_leds(); | ||
| 75 | oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("-----NUMLK") : PSTR("----- "), false); | ||
| 76 | oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false); | ||
| 77 | oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false); | ||
| 78 | 96 | ||
| 97 | #ifdef RGB_ENABLE | ||
| 98 | static void render_rgb_state(void) | ||
| 99 | { | ||
| 100 | // TODO: need to do a bit more handling here for horizontal rendering | ||
| 79 | #if defined(RGB_MATRIX_ENABLE) | 101 | #if defined(RGB_MATRIX_ENABLE) |
| 80 | oled_set_cursor(0, oled_max_lines() - 7); | 102 | static char buffer[31] = {0}; |
| 81 | oled_write_P(PSTR("-----"), false); | 103 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d e%3d ", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode, rgb_matrix_get_flags()); |
| 104 | #elif defined(RGBLIGHT_ENABLE) | ||
| 82 | static char buffer[26] = {0}; | 105 | static char buffer[26] = {0}; |
| 83 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d\n", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode); | 106 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d ", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode); |
| 107 | #endif | ||
| 108 | |||
| 109 | #ifdef RGB_OLED_MENU | ||
| 110 | buffer[4 + rgb_encoder_state * 5] = '<'; | ||
| 111 | #endif | ||
| 84 | oled_write(buffer, false); | 112 | oled_write(buffer, false); |
| 85 | #elif defined(RGBLIGHT_ENABLE) | 113 | } |
| 86 | oled_set_cursor(0, oled_max_lines() - 7); | 114 | #endif |
| 115 | |||
| 116 | static void render_status(void) | ||
| 117 | { | ||
| 118 | render_icon(); | ||
| 119 | render_layer(); | ||
| 120 | |||
| 121 | // Host Keyboard LED Status | ||
| 87 | oled_write_P(PSTR("-----"), false); | 122 | oled_write_P(PSTR("-----"), false); |
| 88 | static char buffer[31] = {0}; | 123 | render_keyboard_leds(); |
| 89 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode); | 124 | |
| 90 | oled_write(buffer, false); | 125 | oled_write_P(PSTR("-----"), false); |
| 126 | #ifdef RGB_ENABLE | ||
| 127 | render_rgb_state(); | ||
| 91 | #endif | 128 | #endif |
| 92 | } | 129 | } |
| 93 | 130 | ||
| 94 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | 131 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { |
| 132 | #if KEYBOARD_helix_rev2 | ||
| 95 | if (is_keyboard_master()) | 133 | if (is_keyboard_master()) |
| 96 | return OLED_ROTATION_270; | 134 | return OLED_ROTATION_270; |
| 97 | return OLED_ROTATION_180; | 135 | return rotation; |
| 136 | #else | ||
| 137 | if (is_keyboard_master()) | ||
| 138 | return OLED_ROTATION_90; | ||
| 139 | return rotation; | ||
| 140 | #endif | ||
| 98 | } | 141 | } |
| 99 | 142 | ||
| 100 | #else // OLED_90ROTATION | 143 | #else // OLED_90ROTATION |
| 101 | 144 | ||
| 102 | static void render_layer(uint8_t layer) | 145 | #ifdef RGB_ENABLE |
| 146 | static void render_rgb_state(void) | ||
| 103 | { | 147 | { |
| 104 | switch (layer) | 148 | // TODO: need to do a bit more handling here for horizontal rendering |
| 105 | { | 149 | #if defined(RGB_MATRIX_ENABLE) |
| 106 | case _QWERTY: | 150 | static char buffer[37] = {0}; |
| 107 | oled_write_P(PSTR("Default\n"), false); | 151 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d e%3d ", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode, rgb_matrix_get_flags()); |
| 108 | break; | 152 | #elif defined(RGBLIGHT_ENABLE) |
| 109 | #ifndef GAMELAYER_DISABLE | 153 | static char buffer[32] = {0}; |
| 110 | case _GAME: | 154 | snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d ", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode); |
| 111 | oled_write_P(PSTR("Game\n"), false); | ||
| 112 | break; | ||
| 113 | #endif | 155 | #endif |
| 114 | case _LOWER: | 156 | |
| 115 | oled_write_P(PSTR("Lower\n"), false); | 157 | #ifdef RGB_OLED_MENU |
| 116 | break; | 158 | buffer[4 + rgb_encoder_state * 5] = '<'; |
| 117 | case _RAISE: | ||
| 118 | oled_write_P(PSTR("Raise\n"), false); | ||
| 119 | break; | ||
| 120 | #ifdef TRILAYER_ENABLED | ||
| 121 | case _ADJUST: | ||
| 122 | oled_write_P(PSTR("Adjust\n"), false); | ||
| 123 | break; | ||
| 124 | #endif | 159 | #endif |
| 125 | } | 160 | oled_write(buffer, false); |
| 126 | } | 161 | } |
| 162 | #endif | ||
| 127 | 163 | ||
| 128 | static void render_status(void) | 164 | static void render_status(void) |
| 129 | { | 165 | { |
| 130 | // Render to mode icon | 166 | render_icon(); |
| 131 | static const char PROGMEM mode_logo[2][3] = { | ||
| 132 | {0x97,0x98,0}, | ||
| 133 | {0xb7,0xb8,0} | ||
| 134 | }; | ||
| 135 | 167 | ||
| 136 | oled_write_P(mode_logo[0], false); | 168 | // Host Layer Status |
| 169 | oled_set_cursor(6, 0); | ||
| 170 | render_layer(); | ||
| 137 | 171 | ||
| 138 | #if defined(RGB_MATRIX_ENABLE) | 172 | // Host Keyboard LED Status |
| 139 | static char buffer[20] = {0}; | 173 | oled_set_cursor(6, 1); |
| 140 | snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); | 174 | render_keyboard_leds(); |
| 141 | oled_write(buffer, false); | ||
| 142 | #elif defined(RGBLIGHT_ENABLE) | ||
| 143 | static char buffer[20] = {0}; | ||
| 144 | snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 145 | oled_write(buffer, false); | ||
| 146 | #else | ||
| 147 | oled_write_P(PSTR("\n")); | ||
| 148 | #endif | ||
| 149 | |||
| 150 | oled_write_P(mode_logo[1], false); | ||
| 151 | 175 | ||
| 152 | #if defined(RGB_MATRIX_ENABLE) | 176 | #ifdef RGB_ENABLE |
| 153 | snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode); | 177 | oled_set_cursor(6, 2); |
| 154 | oled_write(buffer, false); | 178 | render_rgb_state(); |
| 155 | #elif defined(RGBLIGHT_ENABLE) | ||
| 156 | snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgblight_config.speed, rgblight_config.mode); | ||
| 157 | oled_write(buffer, false); | ||
| 158 | #else | ||
| 159 | oled_write_P(PSTR("\n")); | ||
| 160 | #endif | 179 | #endif |
| 161 | |||
| 162 | // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below | ||
| 163 | oled_write_P(PSTR("Layer: "), false); | ||
| 164 | uint8_t layer = biton(layer_state); | ||
| 165 | if (layer != _QWERTY) | ||
| 166 | render_layer(layer); | ||
| 167 | else | ||
| 168 | render_layer(biton32(default_layer_state)); | ||
| 169 | |||
| 170 | // Host Keyboard LED Status | ||
| 171 | uint8_t led_usb_state = host_keyboard_leds(); | ||
| 172 | oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false); | ||
| 173 | oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false); | ||
| 174 | oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false); | ||
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | #endif // OLED_90ROTATION | 182 | #endif // OLED_90ROTATION |
| @@ -186,5 +191,3 @@ void oled_task_user(void) | |||
| 186 | oled_scroll_left(); | 191 | oled_scroll_left(); |
| 187 | } | 192 | } |
| 188 | } | 193 | } |
| 189 | |||
| 190 | #endif | ||
diff --git a/users/xulkal/custom_rgb.c b/users/xulkal/custom_rgb.c new file mode 100644 index 000000000..11bfad1d7 --- /dev/null +++ b/users/xulkal/custom_rgb.c | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | #include "custom_rgb.h" | ||
| 2 | |||
| 3 | #ifdef RGB_MATRIX_ENABLE | ||
| 4 | void rgb_matrix_increase_flags(void) | ||
| 5 | { | ||
| 6 | switch (rgb_matrix_get_flags()) { | ||
| 7 | case LED_FLAG_ALL: { | ||
| 8 | rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER); | ||
| 9 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 10 | } | ||
| 11 | break; | ||
| 12 | case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: { | ||
| 13 | rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); | ||
| 14 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 15 | } | ||
| 16 | break; | ||
| 17 | case LED_FLAG_UNDERGLOW: { | ||
| 18 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
| 19 | rgb_matrix_disable_noeeprom(); | ||
| 20 | } | ||
| 21 | break; | ||
| 22 | default: { | ||
| 23 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
| 24 | rgb_matrix_enable_noeeprom(); | ||
| 25 | } | ||
| 26 | break; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | void rgb_matrix_decrease_flags(void) | ||
| 31 | { | ||
| 32 | switch (rgb_matrix_get_flags()) { | ||
| 33 | case LED_FLAG_ALL: { | ||
| 34 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
| 35 | rgb_matrix_disable_noeeprom(); | ||
| 36 | } | ||
| 37 | break; | ||
| 38 | case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: { | ||
| 39 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
| 40 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 41 | } | ||
| 42 | break; | ||
| 43 | case LED_FLAG_UNDERGLOW: { | ||
| 44 | rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER); | ||
| 45 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 46 | } | ||
| 47 | break; | ||
| 48 | default: { | ||
| 49 | rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); | ||
| 50 | rgb_matrix_enable_noeeprom(); | ||
| 51 | } | ||
| 52 | break; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | #endif | ||
| 56 | |||
| 57 | void rgb_reset(void) { | ||
| 58 | #if defined(RGB_MATRIX_ENABLE) | ||
| 59 | eeconfig_update_rgb_matrix_default(); | ||
| 60 | #elif defined(RGBLIGHT_ENABLE) | ||
| 61 | eeconfig_update_rgblight_default(); | ||
| 62 | rgblight_enable(); | ||
| 63 | #endif | ||
| 64 | } | ||
diff --git a/users/xulkal/custom_rgb.h b/users/xulkal/custom_rgb.h new file mode 100644 index 000000000..f19dd223c --- /dev/null +++ b/users/xulkal/custom_rgb.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #if defined(RGB_MATRIX_ENABLE) | ||
| 4 | #include "rgb_matrix.h" | ||
| 5 | #elif defined(RGBLIGHT_ENABLE) | ||
| 6 | #include "rgblight.h" | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #ifdef RGB_MATRIX_ENABLE | ||
| 10 | void rgb_matrix_increase_flags(void); | ||
| 11 | void rgb_matrix_decrease_flags(void); | ||
| 12 | #endif | ||
| 13 | |||
| 14 | void rgb_reset(void); | ||
diff --git a/users/xulkal/custom_tap_dance.c b/users/xulkal/custom_tap_dance.c index 7123f1be6..e0f90ea11 100644 --- a/users/xulkal/custom_tap_dance.c +++ b/users/xulkal/custom_tap_dance.c | |||
| @@ -8,8 +8,7 @@ | |||
| 8 | qk_tap_dance_action_t tap_dance_actions[] = { | 8 | qk_tap_dance_action_t tap_dance_actions[] = { |
| 9 | [COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT), | 9 | [COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT), |
| 10 | [BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)), | 10 | [BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)), |
| 11 | [DELETE] = ACTION_TAP_DANCE_DOUBLE (KC_DELETE, LCTL(KC_DELETE)), | 11 | [DELETE] = ACTION_TAP_DANCE_DOUBLE (KC_DELETE, LCTL(KC_DELETE)) |
| 12 | [DOT] = ACTION_TAP_DANCE_DOUBLE (KC_DOT, KC_GRAVE) | ||
| 13 | }; | 12 | }; |
| 14 | 13 | ||
| 15 | #else | 14 | #else |
| @@ -20,18 +19,17 @@ static uint16_t td_timer; | |||
| 20 | const uint16_t PROGMEM td_keymaps[TD_MAX - TD_MIN][2] = { | 19 | const uint16_t PROGMEM td_keymaps[TD_MAX - TD_MIN][2] = { |
| 21 | [TD_COMM - TD_MIN] = { KC_COMM, KC_QUOT }, | 20 | [TD_COMM - TD_MIN] = { KC_COMM, KC_QUOT }, |
| 22 | [TD_BSPC - TD_MIN] = { KC_BSPACE, LCTL(KC_BSPACE) }, | 21 | [TD_BSPC - TD_MIN] = { KC_BSPACE, LCTL(KC_BSPACE) }, |
| 23 | [TD_DEL - TD_MIN] = { KC_DELETE, LCTL(KC_DELETE) }, | 22 | [TD_DEL - TD_MIN] = { KC_DELETE, LCTL(KC_DELETE) } |
| 24 | [TD_DOT - TD_MIN] = { KC_DOT, KC_GRAVE } | ||
| 25 | }; | 23 | }; |
| 26 | 24 | ||
| 27 | void run_tap_dance_double(uint8_t i) | 25 | static void run_custom_tap_dance(uint8_t i) |
| 28 | { | 26 | { |
| 29 | tap_code16(pgm_read_word(&td_keymaps[td_keycode - TD_MIN][i])); | 27 | tap_code16(pgm_read_word(&td_keymaps[td_keycode - TD_MIN][i])); |
| 30 | td_keycode = KC_TRANSPARENT; | 28 | td_keycode = KC_TRANSPARENT; |
| 31 | td_timer = timer_read() + TAPPING_TERM; | 29 | td_timer = timer_read() + TAPPING_TERM; |
| 32 | } | 30 | } |
| 33 | 31 | ||
| 34 | bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record) | 32 | bool process_custom_tap_dance(uint16_t keycode, keyrecord_t *record) |
| 35 | { | 33 | { |
| 36 | if (TD_MIN <= keycode && keycode < TD_MAX) | 34 | if (TD_MIN <= keycode && keycode < TD_MAX) |
| 37 | { | 35 | { |
| @@ -43,20 +41,20 @@ bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record) | |||
| 43 | td_timer = timer_read() + TAPPING_TERM; | 41 | td_timer = timer_read() + TAPPING_TERM; |
| 44 | } | 42 | } |
| 45 | else | 43 | else |
| 46 | run_tap_dance_double(1); | 44 | run_custom_tap_dance(1); |
| 47 | } | 45 | } |
| 48 | return false; | 46 | return false; |
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | if (td_keycode != KC_TRANSPARENT) | 49 | if (td_keycode != KC_TRANSPARENT) |
| 52 | run_tap_dance_double(0); | 50 | run_custom_tap_dance(0); |
| 53 | return true; | 51 | return true; |
| 54 | } | 52 | } |
| 55 | 53 | ||
| 56 | void matrix_scan_user(void) | 54 | void matrix_scan_user(void) |
| 57 | { | 55 | { |
| 58 | if (td_keycode != KC_TRANSPARENT && timer_expired(td_timer)) | 56 | if (td_keycode != KC_TRANSPARENT && timer_expired(td_timer)) |
| 59 | run_tap_dance_double(0); | 57 | run_custom_tap_dance(0); |
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | #endif | 60 | #endif |
diff --git a/users/xulkal/custom_tap_dance.h b/users/xulkal/custom_tap_dance.h index 33398808d..c4da9318c 100644 --- a/users/xulkal/custom_tap_dance.h +++ b/users/xulkal/custom_tap_dance.h | |||
| @@ -9,18 +9,15 @@ | |||
| 9 | enum { | 9 | enum { |
| 10 | COMM_QUOT = 0, | 10 | COMM_QUOT = 0, |
| 11 | BACKSPACE, | 11 | BACKSPACE, |
| 12 | DELETE, | 12 | DELETE |
| 13 | DOT | ||
| 14 | }; | 13 | }; |
| 15 | 14 | ||
| 16 | #define TD_COMM TD(COMM_QUOT) | 15 | #define TD_COMM TD(COMM_QUOT) |
| 17 | #define TD_BSPC TD(BACKSPACE) | 16 | #define TD_BSPC TD(BACKSPACE) |
| 18 | #define TD_DEL TD(DELETE) | 17 | #define TD_DEL TD(DELETE) |
| 19 | #define TD_DOT TD(DOT) | ||
| 20 | 18 | ||
| 21 | #else | 19 | #else |
| 22 | 20 | ||
| 23 | void run_tap_dance_double(uint8_t i); | 21 | bool process_custom_tap_dance(uint16_t keycode, keyrecord_t *record); |
| 24 | bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record); | ||
| 25 | 22 | ||
| 26 | #endif | 23 | #endif |
diff --git a/users/xulkal/layouts.h b/users/xulkal/layouts.h index 65dad8c63..89bdfb60d 100644 --- a/users/xulkal/layouts.h +++ b/users/xulkal/layouts.h | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | #define _________________QWERTY_R1_________________ KC_6, KC_7, KC_8, KC_9, KC_0, TD_BSPC | 23 | #define _________________QWERTY_R1_________________ KC_6, KC_7, KC_8, KC_9, KC_0, TD_BSPC |
| 24 | #define _________________QWERTY_R2_________________ KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS | 24 | #define _________________QWERTY_R2_________________ KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS |
| 25 | #define _________________QWERTY_R3_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT | 25 | #define _________________QWERTY_R3_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT |
| 26 | #define _________________QWERTY_R4_________________ KC_N, KC_M, TD_COMM, TD_DOT, KC_SLASH, KC_RSPC | 26 | #define _________________QWERTY_R4_________________ KC_N, KC_M, TD_COMM, KC_DOT, KC_SLASH, KC_RSPC |
| 27 | #define _________________QWERTY_R5_________________ KC_SPC, KC_LEFT, KC_UP, KC_DOWN, KC_RIGHT, KC_RCPC | 27 | #define _________________QWERTY_R5_________________ KC_SPC, KC_LEFT, KC_UP, KC_DOWN, KC_RIGHT, KC_RCPC |
| 28 | 28 | ||
| 29 | 29 | ||
| @@ -86,7 +86,7 @@ | |||
| 86 | #define __________________LOWER_L4_________________ _______, _______, _______, _______, _______, _______ | 86 | #define __________________LOWER_L4_________________ _______, _______, _______, _______, _______, _______ |
| 87 | #define __________________LOWER_L5_________________ _______, _______, _______, _______, _______, _______ | 87 | #define __________________LOWER_L5_________________ _______, _______, _______, _______, _______, _______ |
| 88 | 88 | ||
| 89 | #define __________________LOWER_R1_________________ _______, _______, _______, _______, _______, KC_DEL | 89 | #define __________________LOWER_R1_________________ _______, _______, _______, KC_SLCK, KC_NLCK, KC_DEL |
| 90 | #define __________________LOWER_R2_________________ _______, _______, KC_KP_7, KC_KP_8, KC_KP_9, _______ | 90 | #define __________________LOWER_R2_________________ _______, _______, KC_KP_7, KC_KP_8, KC_KP_9, _______ |
| 91 | #define __________________LOWER_R3_________________ _______, _______, KC_KP_4, KC_KP_5, KC_KP_6, _______ | 91 | #define __________________LOWER_R3_________________ _______, _______, KC_KP_4, KC_KP_5, KC_KP_6, _______ |
| 92 | #define __________________LOWER_R4_________________ _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, _______ | 92 | #define __________________LOWER_R4_________________ _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, _______ |
diff --git a/users/xulkal/process_records.c b/users/xulkal/process_records.c index 2c5d2a4e7..245d4955f 100644 --- a/users/xulkal/process_records.c +++ b/users/xulkal/process_records.c | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | #include "custom_keycodes.h" | 2 | #include "custom_keycodes.h" |
| 3 | #include "timer_utils.h" | 3 | #include "timer_utils.h" |
| 4 | 4 | ||
| 5 | #ifdef RGB_ENABLE | ||
| 6 | #include "custom_rgb.h" | ||
| 7 | #endif | ||
| 8 | |||
| 5 | #ifdef TRILAYER_ENABLED | 9 | #ifdef TRILAYER_ENABLED |
| 6 | uint32_t layer_state_set_user(uint32_t state) | 10 | uint32_t layer_state_set_user(uint32_t state) |
| 7 | { | 11 | { |
| @@ -14,25 +18,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) | |||
| 14 | static uint16_t reset_timer; | 18 | static uint16_t reset_timer; |
| 15 | 19 | ||
| 16 | #ifndef TAP_DANCE_ENABLE | 20 | #ifndef TAP_DANCE_ENABLE |
| 17 | if (!process_tap_dance_double(keycode, record)) | 21 | if (!process_custom_tap_dance(keycode, record)) |
| 18 | return false; | 22 | return false; |
| 19 | #endif | 23 | #endif |
| 20 | 24 | ||
| 21 | switch (keycode) | 25 | switch (keycode) |
| 22 | { | 26 | { |
| 23 | case RGBRST: | 27 | case RGBRST: |
| 24 | { | 28 | #ifdef RGB_ENABLE |
| 25 | #if defined(RGBLIGHT_ENABLE) | 29 | if (record->event.pressed) |
| 26 | if (record->event.pressed) | 30 | rgb_reset(); |
| 27 | { | ||
| 28 | eeconfig_update_rgblight_default(); | ||
| 29 | rgblight_enable(); | ||
| 30 | } | ||
| 31 | #elif defined(RGB_MATRIX_ENABLE) | ||
| 32 | if (record->event.pressed) | ||
| 33 | eeconfig_update_rgb_matrix_default(); | ||
| 34 | #endif | 31 | #endif |
| 35 | } | ||
| 36 | return false; | 32 | return false; |
| 37 | case RESET: | 33 | case RESET: |
| 38 | { | 34 | { |
| @@ -42,9 +38,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) | |||
| 42 | reset_keyboard(); | 38 | reset_keyboard(); |
| 43 | } | 39 | } |
| 44 | return false; | 40 | return false; |
| 41 | #ifdef RGB_MATRIX_TOG_LAYERS | ||
| 42 | case RGB_TOG: | ||
| 43 | if (record->event.pressed) { | ||
| 44 | rgb_matrix_decrease_flags(); | ||
| 45 | } | ||
| 46 | return false; | ||
| 47 | #endif | ||
| 45 | } | 48 | } |
| 46 | 49 | ||
| 47 | return process_record_keymap(keycode, record); | 50 | return process_record_encoder(keycode, record) && process_record_keymap(keycode, record); |
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | __attribute__ ((weak)) | 53 | __attribute__ ((weak)) |
| @@ -52,3 +55,9 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) | |||
| 52 | { | 55 | { |
| 53 | return true; | 56 | return true; |
| 54 | } | 57 | } |
| 58 | |||
| 59 | __attribute__ ((weak)) | ||
| 60 | bool process_record_encoder(uint16_t keycode, keyrecord_t *record) | ||
| 61 | { | ||
| 62 | return true; | ||
| 63 | } | ||
diff --git a/users/xulkal/process_records.h b/users/xulkal/process_records.h index 701ef7e74..c219394f8 100644 --- a/users/xulkal/process_records.h +++ b/users/xulkal/process_records.h | |||
| @@ -15,3 +15,4 @@ enum layer_number { | |||
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); | 17 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); |
| 18 | bool process_record_encoder(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/users/xulkal/rules.mk b/users/xulkal/rules.mk index ab0231d7d..c3834ff5f 100644 --- a/users/xulkal/rules.mk +++ b/users/xulkal/rules.mk | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | SRC += xulkal.c \ | 1 | SRC += xulkal.c \ |
| 2 | process_records.c \ | 2 | process_records.c \ |
| 3 | custom_tap_dance.c \ | 3 | custom_tap_dance.c \ |
| 4 | custom_encoder.c \ | ||
| 5 | custom_oled.c \ | ||
| 6 | timer_utils.c | 4 | timer_utils.c |
| 7 | 5 | ||
| 8 | # Some usual defaults | 6 | # Some usual defaults |
| @@ -15,3 +13,21 @@ ifneq ($(strip $(DISABLE_LTO)), yes) | |||
| 15 | OPT_DEFS += -DNO_ACTION_MACRO | 13 | OPT_DEFS += -DNO_ACTION_MACRO |
| 16 | OPT_DEFS += -DNO_ACTION_FUNCTION | 14 | OPT_DEFS += -DNO_ACTION_FUNCTION |
| 17 | endif | 15 | endif |
| 16 | |||
| 17 | ifeq ($(strip $(ENCODER_ENABLE)), yes) | ||
| 18 | SRC += custom_encoder.c | ||
| 19 | endif | ||
| 20 | |||
| 21 | ifneq ($(strip $(RGB_MATRIX_ENABLE)), no) | ||
| 22 | OPT_DEFS += -DRGB_ENABLE | ||
| 23 | SRC += custom_rgb.c | ||
| 24 | endif | ||
| 25 | |||
| 26 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | ||
| 27 | OPT_DEFS += -DRGB_ENABLE | ||
| 28 | SRC += custom_rgb.c | ||
| 29 | endif | ||
| 30 | |||
| 31 | ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes) | ||
| 32 | SRC += custom_oled.c | ||
| 33 | endif | ||
