From 20c0533c4c66b9d222b6ced2fad3ec6be6cad76e Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Thu, 25 Jul 2019 13:56:29 -0500 Subject: [PATCH] [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 --- keyboards/hadron/ver3/keymaps/xulkal/config.h | 1 + keyboards/hadron/ver3/keymaps/xulkal/keymap.c | 73 ++++++ keyboards/hadron/ver3/keymaps/xulkal/rules.mk | 4 + .../massdrop/ctrl/keymaps/default/keymap.c | 4 +- .../massdrop/ctrl/keymaps/xulkal/config.h | 23 ++ .../massdrop/ctrl/keymaps/xulkal/keymap.c | 13 +- keyboards/rgbkb/sol/keymaps/xulkal/config.h | 31 +++ keyboards/rgbkb/sol/keymaps/xulkal/keymap.c | 6 +- keyboards/rgbkb/sol/keymaps/xulkal/rules.mk | 10 +- users/xulkal/custom_encoder.c | 67 +++++- users/xulkal/custom_keycodes.h | 12 + users/xulkal/custom_oled.c | 213 +++++++++--------- users/xulkal/custom_rgb.c | 64 ++++++ users/xulkal/custom_rgb.h | 14 ++ users/xulkal/custom_tap_dance.c | 16 +- users/xulkal/custom_tap_dance.h | 7 +- users/xulkal/layouts.h | 4 +- users/xulkal/process_records.c | 35 +-- users/xulkal/process_records.h | 1 + users/xulkal/rules.mk | 20 +- 20 files changed, 460 insertions(+), 158 deletions(-) create mode 100644 keyboards/hadron/ver3/keymaps/xulkal/config.h create mode 100644 keyboards/hadron/ver3/keymaps/xulkal/keymap.c create mode 100644 keyboards/hadron/ver3/keymaps/xulkal/rules.mk create mode 100644 keyboards/massdrop/ctrl/keymaps/xulkal/config.h create mode 100644 keyboards/rgbkb/sol/keymaps/xulkal/config.h create mode 100644 users/xulkal/custom_rgb.c create mode 100644 users/xulkal/custom_rgb.h diff --git a/keyboards/hadron/ver3/keymaps/xulkal/config.h b/keyboards/hadron/ver3/keymaps/xulkal/config.h new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/keyboards/hadron/ver3/keymaps/xulkal/config.h @@ -0,0 +1 @@ +#pragma once diff --git a/keyboards/hadron/ver3/keymaps/xulkal/keymap.c b/keyboards/hadron/ver3/keymaps/xulkal/keymap.c new file mode 100644 index 000000000..0b7fd6f5e --- /dev/null +++ b/keyboards/hadron/ver3/keymaps/xulkal/keymap.c @@ -0,0 +1,73 @@ +#include QMK_KEYBOARD_H +#include "xulkal.h" + +#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Qwerty Layout + * ,-----------------------------------------------------------------------------------. + * | GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | BkSp | + * |------+------+------+------+------+------|------+------+------+------+------+------+--------------------. + * | Tab | Q | W | E | R | T | Y | U | I | O | P | \ | 7 | 8 | 9 | + * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------| + * |FN(CAPS)| A | S | D | F | G | H | J | K | L | ; | Enter| 4 | 5 | 6 | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | Sft[ | Z | X | C | V | B | N | M | , | . | / | Sft] | 1 | 2 | 3 | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| + * | Ctl- | Win | LOWER| RAISE| Alt | Space| Space| Left | Up | Down | Right| Ctl= | 0 | . | = | + * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------' + */ + [_QWERTY] = EXPAND_LAYOUT( \ + _________________QWERTY_L1_________________, _________________QWERTY_R1_________________,\ + _________________QWERTY_L2_________________, _________________QWERTY_R2_________________, KC_P7, KC_P8, KC_P9, \ + _________________QWERTY_L3_________________, _________________QWERTY_R3_________________, KC_P4, KC_P5, KC_P6, \ + _________________QWERTY_L4_________________, _________________QWERTY_R4_________________, KC_P1, KC_P2, KC_P3, \ + _________________QWERTY_L5_________________, _________________QWERTY_R5_________________, KC_P0, KC_DOT, KC_EQL \ + ), + +#ifndef GAMELAYER_DISABLE + [_GAME] = EXPAND_LAYOUT( \ + ___________________GAME_L1_________________, ___________________GAME_R1_________________, \ + ___________________GAME_L2_________________, ___________________GAME_R2_________________, _______, _______, _______, \ + ___________________GAME_L3_________________, ___________________GAME_R3_________________, _______, _______, _______, \ + ___________________GAME_L4_________________, ___________________GAME_R4_________________, _______, _______, _______, \ + ___________________GAME_L5_________________, ___________________GAME_R5_________________, _______, _______, _______ \ + ), +#endif + + [_LOWER] = EXPAND_LAYOUT( \ + __________________LOWER_L1_________________, __________________LOWER_R1_________________, \ + __________________LOWER_L2_________________, __________________LOWER_R2_________________, _______, _______, _______, \ + __________________LOWER_L3_________________, __________________LOWER_R3_________________, _______, _______, _______, \ + __________________LOWER_L4_________________, __________________LOWER_R4_________________, _______, _______, _______, \ + __________________LOWER_L5_________________, __________________LOWER_R5_________________, _______, _______, _______ \ + ), + + [_RAISE] = EXPAND_LAYOUT( \ + __________________RAISE_L1_________________, __________________RAISE_R1_________________, \ + __________________RAISE_L2_________________, __________________RAISE_R2_________________, _______, _______, _______, \ + __________________RAISE_L3_________________, __________________RAISE_R3_________________, _______, _______, _______, \ + __________________RAISE_L4_________________, __________________RAISE_R4_________________, _______, _______, _______, \ + __________________RAISE_L5_________________, __________________RAISE_R5_________________, _______, _______, _______ \ + ), + +#ifdef TRILAYER_ENABLED + [_ADJUST] = EXPAND_LAYOUT( \ + _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, \ + _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, _______, _______, _______, \ + _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, _______, _______, _______, \ + _________________ADJUST_L4_________________, _________________ADJUST_R4_________________, _______, _______, _______, \ + _________________ADJUST_L5_________________, _________________ADJUST_R5_________________, _______, _______, _______ \ + ), +#endif +}; + +bool music_mask_user(uint16_t keycode) { + switch (keycode) { + case RAISE: + case LOWER: + return false; + default: + return true; + } +} diff --git a/keyboards/hadron/ver3/keymaps/xulkal/rules.mk b/keyboards/hadron/ver3/keymaps/xulkal/rules.mk new file mode 100644 index 000000000..0305226b3 --- /dev/null +++ b/keyboards/hadron/ver3/keymaps/xulkal/rules.mk @@ -0,0 +1,4 @@ +# Overridden build options + +COMMAND_ENABLE = no +ENCODER_ENABLER = no diff --git a/keyboards/massdrop/ctrl/keymaps/default/keymap.c b/keyboards/massdrop/ctrl/keymaps/default/keymap.c index 53c96d95d..39122ee49 100644 --- a/keyboards/massdrop/ctrl/keymaps/default/keymap.c +++ b/keyboards/massdrop/ctrl/keymaps/default/keymap.c @@ -102,11 +102,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (rgb_matrix_get_flags()) { case LED_FLAG_ALL: { - rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER); rgb_matrix_set_color_all(0, 0, 0); } break; - case LED_FLAG_KEYLIGHT: { + case LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER: { rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); rgb_matrix_set_color_all(0, 0, 0); } diff --git a/keyboards/massdrop/ctrl/keymaps/xulkal/config.h b/keyboards/massdrop/ctrl/keymaps/xulkal/config.h new file mode 100644 index 000000000..a078fece0 --- /dev/null +++ b/keyboards/massdrop/ctrl/keymaps/xulkal/config.h @@ -0,0 +1,23 @@ +/* +This is the c configuration file for the keymap + +Copyright 2012 Jun Wako +Copyright 2015 Jack Humbert + +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 . +*/ + +#pragma once + +#define RGB_MATRIX_TOG_LAYERS diff --git a/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c b/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c index 8b45b53ec..debfa3b47 100644 --- a/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c +++ b/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c @@ -8,7 +8,6 @@ enum ctrl_keycodes { DBG_MTRX, //DEBUG Toggle Matrix Prints DBG_KBD, //DEBUG Toggle Keyboard Prints DBG_MOU, //DEBUG Toggle Mouse Prints - MD_BOOT, //Restart into bootloader after hold timeout }; #define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode @@ -21,7 +20,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, TD_BSPC, KC_INS, KC_HOME, KC_PGUP, \ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, TD_DEL, KC_END, KC_PGDN, \ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \ - KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, TD_COMM, TD_DOT, KC_SLSH, KC_RSPC, KC_UP, \ + KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, TD_COMM, KC_DOT, KC_SLSH, KC_RSPC, KC_UP, \ KC_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LOWER, KC_APP, KC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT \ ), @@ -39,7 +38,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_LOWER] = LAYOUT( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \ _______, RGB_RMOD,RGB_MOD, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \ - RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, MD_BOOT, QWERTY, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \ + RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, RESET, QWERTY, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \ RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, RGBRST, GAME, _______, _______, _______, _______, _______, _______, _______, \ _______, _______, _______, _______, _______, _______, TG_NKRO, _______, _______, _______, _______, _______, _______, \ _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ @@ -62,8 +61,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - static uint16_t reset_timer; - switch (keycode) { case U_T_AUTO: if (record->event.pressed && MODS_SHIFT && MODS_CTRL) @@ -89,12 +86,6 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) if (record->event.pressed) TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse"); return false; - case MD_BOOT: - if (record->event.pressed) - reset_timer = timer_read() + 500; - else if (timer_expired(reset_timer)) - reset_keyboard(); - return false; } return true; diff --git a/keyboards/rgbkb/sol/keymaps/xulkal/config.h b/keyboards/rgbkb/sol/keymaps/xulkal/config.h new file mode 100644 index 000000000..a5c35cfae --- /dev/null +++ b/keyboards/rgbkb/sol/keymaps/xulkal/config.h @@ -0,0 +1,31 @@ +/* +This is the c configuration file for the keymap + +Copyright 2012 Jun Wako +Copyright 2015 Jack Humbert + +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 . +*/ + +#pragma once + +// Xulkal custom stuff +#if KEYBOARD_rgbkb_sol_rev2 + #define OLED_90ROTATION + #define RGB_MATRIX_TOG_LAYERS + #define RGB_MATRIX_HUE_STEP 8 + #define RGB_MATRIX_SAT_STEP 8 + #define RGB_MATRIX_VAL_STEP 8 + #define RGB_MATRIX_SPD_STEP 8 +#endif diff --git a/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c b/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c index e51edd907..c508b0ca8 100644 --- a/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c +++ b/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c @@ -21,7 +21,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| * | Sft[ | Z | X | C | V | B | RGB | |RGBRST| N | M | , | . | / | Sft] | * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| - * | Ctl- | Win | LOWER| RAISE| Alt | Space|RGBRMOD| |RGBMOD| Space| Left | Up | Down | Right| Ctl= | + * | Ctl- | Win | LOWER| RAISE| Alt | Space| ENC1 | | ENC2 | Space| Left | Up | Down | Right| Ctl= | * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------' * | Space| DEL | | Enter| Space| * `-------------' `-------------' @@ -31,7 +31,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _________________QWERTY_L2_________________, KC_LBRC, KC_RBRC, _________________QWERTY_R2_________________, \ _________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \ _________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \ - _________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \ + _________________QWERTY_L5_________________, KC_ENC1, KC_ENC2, _________________QWERTY_R5_________________, \ KC_SPC, TD_DEL, KC_ENT, KC_SPC \ ), @@ -41,7 +41,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ___________________GAME_L2_________________, KC_LBRC, KC_RBRC, ___________________GAME_R2_________________, \ ___________________GAME_L3_________________, KC_GRV, KC_QUOT, ___________________GAME_R3_________________, \ ___________________GAME_L4_________________, RGB_TOG, RGBRST, ___________________GAME_R4_________________, \ - ___________________GAME_L5_________________, RGB_RMOD, RGB_MOD, ___________________GAME_R5_________________, \ + ___________________GAME_L5_________________, KC_ENC1, KC_ENC2, ___________________GAME_R5_________________, \ KC_SPC, KC_DEL, KC_ENT, KC_SPC \ ), #endif diff --git a/keyboards/rgbkb/sol/keymaps/xulkal/rules.mk b/keyboards/rgbkb/sol/keymaps/xulkal/rules.mk index 238d1cf23..6a14a99af 100644 --- a/keyboards/rgbkb/sol/keymaps/xulkal/rules.mk +++ b/keyboards/rgbkb/sol/keymaps/xulkal/rules.mk @@ -10,8 +10,14 @@ FULLHAND_ENABLE = yes # Enables the additional 24 Full Hand LEDs # Misc OLED_DRIVER_ENABLE = yes # Enable the OLED Driver - - +# Not using the encoder for rev1 +ifeq ($(strip $(KEYBOARD)), rgbkb/sol/rev1) + ENCODER_ENABLE = no + RGB_OLED_MENU = no +else + ENCODER_ENABLE = yes + RGB_OLED_MENU = 0 +endif # Do not edit past here 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 @@ #include "custom_encoder.h" +#include "custom_keycodes.h" + +#ifdef RGB_OLED_MENU +#include "custom_rgb.h" + +// I'm lazy and like constants over calculations, also using it as a compile time check +#if defined(RGB_MATRIX_ENABLE) + #define RGB_FUNCTION_COUNT 6 +#elif defined(RGBLIGHT_ENABLE) + #define RGB_FUNCTION_COUNT 5 +#endif + +typedef void (*rgb_f)(void); + +const rgb_f rgb_functions[RGB_FUNCTION_COUNT][2] = { +#if defined(RGB_MATRIX_ENABLE) + { rgb_matrix_increase_hue, rgb_matrix_decrease_hue }, + { rgb_matrix_increase_sat, rgb_matrix_decrease_sat }, + { rgb_matrix_increase_val, rgb_matrix_decrease_val }, + { rgb_matrix_increase_speed, rgb_matrix_decrease_speed }, + { rgb_matrix_step, rgb_matrix_step_reverse }, + { rgb_matrix_increase_flags, rgb_matrix_decrease_flags } +#elif defined(RGBLIGHT_ENABLE) + { rgblight_increase_hue, rgblight_decrease_hue }, + { rgblight_increase_sat, rgblight_decrease_sat }, + { rgblight_increase_val, rgblight_decrease_val }, + { rgblight_increase_speed, rgblight_decrease_speed }, + { rgblight_step, rgblight_step_reverse } +#endif +}; + +// Start at the end for mode +uint8_t rgb_encoder_state = 4; + +bool process_record_encoder(uint16_t keycode, keyrecord_t *record) +{ + switch (keycode) + { + case RGB_ENC: + if (record->event.pressed) { + if (get_mods() & MOD_MASK_SHIFT) { + rgb_encoder_state = (rgb_encoder_state - 1); + if (rgb_encoder_state >= RGB_FUNCTION_COUNT) + rgb_encoder_state = RGB_FUNCTION_COUNT - 1; + } else { + rgb_encoder_state = (rgb_encoder_state + 1) % RGB_FUNCTION_COUNT; + } + } + return false; + } + return true; +} +#endif // RGB_OLED_MENU -#ifdef ENCODER_ENABLE const uint16_t PROGMEM encoders[][2] = { { KC_PGUP, KC_PGDN }, - { KC_DOWN, KC_UP } + { KC_VOLU, KC_VOLD } }; void encoder_update_user(uint8_t index, bool clockwise) { - tap_code16(pgm_read_word(&encoders[index][clockwise])); + if (!is_keyboard_master()) + return; + +#ifdef RGB_OLED_MENU + if (index == RGB_OLED_MENU) + (*rgb_functions[rgb_encoder_state][clockwise])(); + else +#endif // RGB_OLED_MENU + tap_code16(pgm_read_word(&encoders[index][clockwise])); } -#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 @@ -9,6 +9,9 @@ enum custom_keycodes { TD_DEL, TD_DOT, TD_MAX, +#endif +#ifdef ENCODER_ENABLE + RGB_ENC, #endif KEYMAP_SAFE_RANGE }; @@ -26,3 +29,12 @@ enum custom_keycodes { #define LOWER MO(_LOWER) #define RAISE MO(_RAISE) + + +#ifdef ENCODER_ENABLE +#define KC_ENC1 RGB_ENC +#define KC_ENC2 KC_MPLY +#else +#define KC_ENC1 RGB_RMOD +#define KC_ENC2 RGB_MOD +#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 @@ #include -#ifdef OLED_DRIVER_ENABLE - #ifdef RGBLIGHT_ENABLE rgblight_config_t rgblight_config; #endif +#if KEYBOARD_helix_rev2 +extern uint8_t is_master; +bool is_keyboard_master(void) { return is_master; } +#endif + static void render_logo(void) { static const char PROGMEM font_logo[] = { @@ -18,21 +21,38 @@ static void render_logo(void) oled_write_P(font_logo, false); } -#if defined(OLED_90ROTATION) - -// TODO: Need to define this function / extern only for helix based split common keyboards -extern uint8_t is_master; -bool is_keyboard_master(void) +static void render_icon(void) { - return is_master; +#ifdef OLED_90ROTATION + static const char PROGMEM font_icon[] = { + 0x9b,0x9c,0x9d,0x9e,0x9f, + 0xbb,0xbc,0xbd,0xbe,0xbf, + 0xdb,0xdc,0xdd,0xde,0xdf,0 + }; +#else + static const char PROGMEM font_icon[] = { + // Use \r (0x0d) to jump to the next line without clearing the rest of the current line + 0x9b,0x9c,0x9d,0x9e,0x9f,0x0d, + 0xbb,0xbc,0xbd,0xbe,0xbf,0x0d, + 0xdb,0xdc,0xdd,0xde,0xdf,0 + }; +#endif + oled_write_P(font_icon, false); } -static void render_layer(uint8_t layer) +static void render_layer(void) { + uint8_t layer = layer_state ? biton(layer_state) : biton32(default_layer_state); +#ifdef OLED_90ROTATION + oled_write_P(PSTR("Layer"), false); +#else + oled_write_P(PSTR("Layer: "), false); +#endif + switch (layer) { case _QWERTY: - oled_write_P(PSTR("DFLT "), false); + oled_write_P(PSTR("BASE "), false); break; #ifndef GAMELAYER_DISABLE case _GAME: @@ -53,125 +73,110 @@ static void render_layer(uint8_t layer) } } +static void render_keyboard_leds(void) +{ + // Host Keyboard LED Status + uint8_t led_state = host_keyboard_leds(); +#ifdef OLED_90ROTATION + oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUMLK") : PSTR(" "), false); + oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false); + oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false); +#else + oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUM ") : PSTR(" "), false); + oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR(" "), false); + oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRL") : PSTR(" "), false); +#endif +} + +#ifdef RGB_OLED_MENU +extern uint8_t rgb_encoder_state; +#endif + +#if defined(OLED_90ROTATION) + +#ifdef RGB_ENABLE +static void render_rgb_state(void) +{ + // TODO: need to do a bit more handling here for horizontal rendering +#if defined(RGB_MATRIX_ENABLE) + static char buffer[31] = {0}; + 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()); +#elif defined(RGBLIGHT_ENABLE) + static char buffer[26] = {0}; + 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); +#endif + +#ifdef RGB_OLED_MENU + buffer[4 + rgb_encoder_state * 5] = '<'; +#endif + oled_write(buffer, false); +} +#endif + static void render_status(void) { - // Render to mode icon - static const char PROGMEM mode_logo[2][4] = { - {0x97,0x98,0x0a,0}, - {0xb7,0xb8,0x0a,0} }; - - oled_write_P(mode_logo[0], false); - oled_write_P(mode_logo[1], false); - - oled_write_P(PSTR("Layer"), false); - uint8_t layer = biton(layer_state); - if (layer != _QWERTY) - render_layer(layer); - else - render_layer(biton32(default_layer_state)); + render_icon(); + render_layer(); // Host Keyboard LED Status - uint8_t led_usb_state = host_keyboard_leds(); - oled_write_P(led_usb_state & (1<event.pressed) - { - eeconfig_update_rgblight_default(); - rgblight_enable(); - } -#elif defined(RGB_MATRIX_ENABLE) - if (record->event.pressed) - eeconfig_update_rgb_matrix_default(); +#ifdef RGB_ENABLE + if (record->event.pressed) + rgb_reset(); #endif - } return false; case RESET: { @@ -42,9 +38,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) reset_keyboard(); } return false; +#ifdef RGB_MATRIX_TOG_LAYERS + case RGB_TOG: + if (record->event.pressed) { + rgb_matrix_decrease_flags(); + } + return false; +#endif } - return process_record_keymap(keycode, record); + return process_record_encoder(keycode, record) && process_record_keymap(keycode, record); } __attribute__ ((weak)) @@ -52,3 +55,9 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } + +__attribute__ ((weak)) +bool process_record_encoder(uint16_t keycode, keyrecord_t *record) +{ + return true; +} 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 { }; bool process_record_keymap(uint16_t keycode, keyrecord_t *record); +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 @@ SRC += xulkal.c \ process_records.c \ custom_tap_dance.c \ - custom_encoder.c \ - custom_oled.c \ timer_utils.c # Some usual defaults @@ -15,3 +13,21 @@ ifneq ($(strip $(DISABLE_LTO)), yes) OPT_DEFS += -DNO_ACTION_MACRO OPT_DEFS += -DNO_ACTION_FUNCTION endif + +ifeq ($(strip $(ENCODER_ENABLE)), yes) + SRC += custom_encoder.c +endif + +ifneq ($(strip $(RGB_MATRIX_ENABLE)), no) + OPT_DEFS += -DRGB_ENABLE + SRC += custom_rgb.c +endif + +ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) + OPT_DEFS += -DRGB_ENABLE + SRC += custom_rgb.c +endif + +ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes) + SRC += custom_oled.c +endif