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/custom_encoder.c | |
| 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/custom_encoder.c')
| -rw-r--r-- | users/xulkal/custom_encoder.c | 67 |
1 files changed, 63 insertions, 4 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 | ||
