[Keymap] Xulkal user changes (#6044)
* Xulkal user changes Xulkal user changes * Reduce code duplication * Massive user code refactor
This commit is contained in:
parent
02b3fadbac
commit
4f788c2ae9
18 changed files with 334 additions and 260 deletions
|
@ -13,23 +13,35 @@ enum ctrl_keycodes {
|
||||||
|
|
||||||
#define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode
|
#define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode
|
||||||
|
|
||||||
keymap_config_t keymap_config;
|
#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__)
|
||||||
|
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
[0] = LAYOUT(
|
[_QWERTY] = LAYOUT(
|
||||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS, \
|
KC_GESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS, \
|
||||||
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_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_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LOWER, KC_APP, KC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||||
|
),
|
||||||
|
|
||||||
|
#ifndef GAMELAYER_DISABLE
|
||||||
|
[_GAME] = LAYOUT(
|
||||||
|
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS, \
|
||||||
|
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, KC_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, KC_DEL, KC_END, KC_PGDN, \
|
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, KC_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_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, KC_DOT, KC_SLSH, KC_RSPC, KC_UP, \
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, \
|
||||||
KC_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT \
|
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LOWER, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||||
),
|
),
|
||||||
[1] = LAYOUT(
|
#endif
|
||||||
|
|
||||||
|
[_LOWER] = LAYOUT(
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \
|
||||||
_______, RGB_RMOD, RGB_MOD,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \
|
_______, RGB_RMOD,RGB_MOD, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \
|
||||||
RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, MD_BOOT, _______, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \
|
RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, MD_BOOT, QWERTY, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \
|
||||||
RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, RGBRST, GAME, _______, _______, _______, _______, _______, _______, _______, \
|
||||||
_______, RGB_TOG, _______, _______, _______, _______, TG_NKRO, _______, _______, _______, _______, _______, _______, \
|
_______, _______, _______, _______, _______, _______, TG_NKRO, _______, _______, _______, _______, _______, _______, \
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
|
||||||
),
|
),
|
||||||
/*
|
/*
|
||||||
|
@ -44,62 +56,46 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// Runs just one time when the keyboard initializes.
|
|
||||||
void matrix_init_user(void) {
|
|
||||||
};
|
|
||||||
|
|
||||||
// Runs constantly in the background, in a loop.
|
|
||||||
void matrix_scan_user(void) {
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
|
#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
|
||||||
#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
|
#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
|
||||||
#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
|
#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
|
||||||
|
|
||||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
|
||||||
static uint32_t key_timer;
|
{
|
||||||
|
static uint16_t reset_timer;
|
||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case U_T_AUTO:
|
case U_T_AUTO:
|
||||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
if (record->event.pressed && MODS_SHIFT && MODS_CTRL)
|
||||||
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case U_T_AGCR:
|
case U_T_AGCR:
|
||||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
if (record->event.pressed && MODS_SHIFT && MODS_CTRL)
|
||||||
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case DBG_TOG:
|
case DBG_TOG:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case DBG_MTRX:
|
case DBG_MTRX:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case DBG_KBD:
|
case DBG_KBD:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case DBG_MOU:
|
case DBG_MOU:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
case MD_BOOT:
|
case MD_BOOT:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
key_timer = timer_read32();
|
reset_timer = timer_read() + 500;
|
||||||
} else {
|
else if (timer_expired(reset_timer))
|
||||||
if (timer_elapsed32(key_timer) >= 500) {
|
|
||||||
reset_keyboard();
|
reset_keyboard();
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
default:
|
|
||||||
return true; //Process all other keycodes normally
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
#include "split_util.h"
|
#include "split_util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OLED_DRIVER_ENABLE
|
|
||||||
#include "oled_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__)
|
#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__)
|
||||||
|
|
||||||
// Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns
|
// Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns
|
||||||
|
@ -36,7 +32,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
_________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \
|
_________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \
|
||||||
_________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \
|
_________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \
|
||||||
_________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \
|
_________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \
|
||||||
KC_SPC, KC_DEL, KC_ENT, KC_SPC \
|
KC_SPC, TD_DEL, KC_ENT, KC_SPC \
|
||||||
),
|
),
|
||||||
|
|
||||||
#ifndef GAMELAYER_DISABLE
|
#ifndef GAMELAYER_DISABLE
|
||||||
|
@ -79,90 +75,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
),
|
),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
|
|
||||||
#ifdef OLED_DRIVER_ENABLE
|
|
||||||
|
|
||||||
static void render_logo(void) {
|
|
||||||
static const char PROGMEM sol_logo[] = {
|
|
||||||
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
|
|
||||||
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
|
|
||||||
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
|
|
||||||
|
|
||||||
oled_write_P(sol_logo, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void render_status(void) {
|
|
||||||
// Render to mode icon
|
|
||||||
static const char PROGMEM mode_logo[2][3] = {
|
|
||||||
{0x97,0x98,0},
|
|
||||||
{0xb7,0xb8,0} };
|
|
||||||
|
|
||||||
oled_write_P(mode_logo[0], false);
|
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE)
|
|
||||||
static char buffer[20] = {0};
|
|
||||||
snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
|
|
||||||
oled_write(buffer, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
oled_write_P(mode_logo[1], false);
|
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE)
|
|
||||||
snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
|
|
||||||
oled_write(buffer, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
oled_write_P(PSTR("Layer: "), false);
|
|
||||||
switch (biton32(layer_state)) {
|
|
||||||
case _QWERTY:
|
|
||||||
#ifndef GAMELAYER_DISABLE
|
|
||||||
switch (biton32(default_layer_state)) {
|
|
||||||
case _QWERTY:
|
|
||||||
oled_write_P(PSTR("Default\n"), false);
|
|
||||||
break;
|
|
||||||
case _GAME:
|
|
||||||
oled_write_P(PSTR("Game\n"), false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
oled_write_P(PSTR("Undefined\n"), false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
oled_write_P(PSTR("Default\n"), false);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case _LOWER:
|
|
||||||
oled_write_P(PSTR("Lower\n"), false);
|
|
||||||
break;
|
|
||||||
case _RAISE:
|
|
||||||
oled_write_P(PSTR("Raise\n"), false);
|
|
||||||
break;
|
|
||||||
#ifdef TRILAYER_ENABLED
|
|
||||||
case _ADJUST:
|
|
||||||
oled_write_P(PSTR("Adjust\n"), false);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
oled_write_P(PSTR("Undefined\n"), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Host Keyboard LED Status
|
|
||||||
uint8_t led_usb_state = host_keyboard_leds();
|
|
||||||
oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
|
|
||||||
oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
|
|
||||||
oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_task_user(void) {
|
|
||||||
if (is_keyboard_master()) {
|
|
||||||
render_status();
|
|
||||||
} else {
|
|
||||||
render_logo();
|
|
||||||
oled_scroll_left();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
This is the c configuration file for the keymap
|
|
||||||
|
|
||||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
// place overrides here
|
|
||||||
|
|
|
@ -67,21 +67,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
),
|
),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENCODER_ENABLE
|
|
||||||
void encoder_update_user(uint8_t index, bool clockwise) {
|
|
||||||
if (index == 0) { /* First encoder */
|
|
||||||
if (clockwise) {
|
|
||||||
tap_code(KC_PGDN);
|
|
||||||
} else {
|
|
||||||
tap_code(KC_PGUP);
|
|
||||||
}
|
|
||||||
} else if (index == 1) { /* Second encoder from slave */
|
|
||||||
if (clockwise) {
|
|
||||||
tap_code(KC_UP);
|
|
||||||
} else {
|
|
||||||
tap_code(KC_DOWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
13
users/xulkal/custom_encoder.c
Normal file
13
users/xulkal/custom_encoder.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include "custom_encoder.h"
|
||||||
|
|
||||||
|
#ifdef ENCODER_ENABLE
|
||||||
|
const uint16_t PROGMEM encoders[][2] = {
|
||||||
|
{ KC_PGUP, KC_PGDN },
|
||||||
|
{ KC_DOWN, KC_UP }
|
||||||
|
}
|
||||||
|
|
||||||
|
void encoder_update_user(uint8_t index, bool clockwise)
|
||||||
|
{
|
||||||
|
tap_code16(pgm_read_word(&encoders[index][clockwise]));
|
||||||
|
}
|
||||||
|
#endif
|
2
users/xulkal/custom_encoder.h
Normal file
2
users/xulkal/custom_encoder.h
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#pragma once
|
||||||
|
#include "quantum.h"
|
28
users/xulkal/custom_keycodes.h
Normal file
28
users/xulkal/custom_keycodes.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
enum custom_keycodes {
|
||||||
|
RGBRST = SAFE_RANGE,
|
||||||
|
#ifndef TAP_DANCE_ENABLE
|
||||||
|
TD_MIN,
|
||||||
|
TD_COMM = TD_MIN,
|
||||||
|
TD_BSPC,
|
||||||
|
TD_DEL,
|
||||||
|
TD_DOT,
|
||||||
|
TD_MAX,
|
||||||
|
#endif
|
||||||
|
KEYMAP_SAFE_RANGE
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RIS_ESC LT(_RAISE, KC_ESC)
|
||||||
|
#define RIS_CAPS LT(_RAISE, KC_CAPS)
|
||||||
|
|
||||||
|
#define QWERTY DF(_QWERTY)
|
||||||
|
|
||||||
|
#ifndef GAMELAYER_DISABLE
|
||||||
|
#define GAME DF(_GAME)
|
||||||
|
#else
|
||||||
|
#define GAME KC_TRANSPARENT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LOWER MO(_LOWER)
|
||||||
|
#define RAISE MO(_RAISE)
|
96
users/xulkal/custom_oled.c
Normal file
96
users/xulkal/custom_oled.c
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#include "custom_oled.h"
|
||||||
|
#include "process_records.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef OLED_DRIVER_ENABLE
|
||||||
|
|
||||||
|
static void render_logo(void)
|
||||||
|
{
|
||||||
|
static const char PROGMEM sol_logo[] = {
|
||||||
|
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
|
||||||
|
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
|
||||||
|
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
|
||||||
|
oled_write_P(sol_logo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_status(void)
|
||||||
|
{
|
||||||
|
// Render to mode icon
|
||||||
|
static const char PROGMEM mode_logo[2][3] = {
|
||||||
|
{0x97,0x98,0},
|
||||||
|
{0xb7,0xb8,0}
|
||||||
|
};
|
||||||
|
|
||||||
|
oled_write_P(mode_logo[0], false);
|
||||||
|
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
static char buffer[20] = {0};
|
||||||
|
snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
|
||||||
|
oled_write(buffer, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
oled_write_P(mode_logo[1], false);
|
||||||
|
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
|
||||||
|
oled_write(buffer, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 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
|
||||||
|
oled_write_P(PSTR("Layer: "), false);
|
||||||
|
switch (biton32(layer_state))
|
||||||
|
{
|
||||||
|
case _QWERTY:
|
||||||
|
#ifndef GAMELAYER_DISABLE
|
||||||
|
switch (biton32(default_layer_state))
|
||||||
|
{
|
||||||
|
case _QWERTY:
|
||||||
|
oled_write_P(PSTR("Default\n"), false);
|
||||||
|
break;
|
||||||
|
case _GAME:
|
||||||
|
oled_write_P(PSTR("Game\n"), false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oled_write_P(PSTR("Undefined\n"), false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
oled_write_P(PSTR("Default\n"), false);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case _LOWER:
|
||||||
|
oled_write_P(PSTR("Lower\n"), false);
|
||||||
|
break;
|
||||||
|
case _RAISE:
|
||||||
|
oled_write_P(PSTR("Raise\n"), false);
|
||||||
|
break;
|
||||||
|
#ifdef TRILAYER_ENABLED
|
||||||
|
case _ADJUST:
|
||||||
|
oled_write_P(PSTR("Adjust\n"), false);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
oled_write_P(PSTR("Undefined\n"), false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Host Keyboard LED Status
|
||||||
|
uint8_t led_usb_state = host_keyboard_leds();
|
||||||
|
oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
|
||||||
|
oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
|
||||||
|
oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void oled_task_user(void)
|
||||||
|
{
|
||||||
|
if (is_keyboard_master())
|
||||||
|
render_status();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
render_logo();
|
||||||
|
oled_scroll_left();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
2
users/xulkal/custom_oled.h
Normal file
2
users/xulkal/custom_oled.h
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#pragma once
|
||||||
|
#include "quantum.h"
|
61
users/xulkal/custom_tap_dance.c
Normal file
61
users/xulkal/custom_tap_dance.c
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#include "custom_tap_dance.h"
|
||||||
|
#include "custom_keycodes.h"
|
||||||
|
#include "timer_utils.h"
|
||||||
|
|
||||||
|
#ifdef TAP_DANCE_ENABLE
|
||||||
|
|
||||||
|
//Tap Dance Definitions
|
||||||
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
||||||
|
[COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT),
|
||||||
|
[BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)),
|
||||||
|
[DELETE] = ACTION_TAP_DANCE_DOUBLE (KC_DELETE, LCTL(KC_DELETE))
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static uint16_t td_keycode;
|
||||||
|
static uint16_t td_timer;
|
||||||
|
|
||||||
|
const uint16_t PROGMEM td_keymaps[TD_MAX - TD_MIN][2] = {
|
||||||
|
[TD_COMM - TD_MIN] = { KC_COMM, KC_QUOT },
|
||||||
|
[TD_BSPC - TD_MIN] = { KC_BSPACE, LCTL(KC_BSPACE) },
|
||||||
|
[TD_DEL - TD_MIN] = { KC_DELETE, LCTL(KC_DELETE) },
|
||||||
|
[TD_DOT - TD_MIN] = { KC_DOT, KC_GRAVE }
|
||||||
|
};
|
||||||
|
|
||||||
|
void run_tap_dance_double(uint8_t i)
|
||||||
|
{
|
||||||
|
tap_code16(pgm_read_word(&td_keymaps[td_keycode - TD_MIN][i]));
|
||||||
|
td_keycode = KC_TRANSPARENT;
|
||||||
|
td_timer = timer_read() + TAPPING_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record)
|
||||||
|
{
|
||||||
|
if (TD_MIN <= keycode && keycode < TD_MAX)
|
||||||
|
{
|
||||||
|
if (record->event.pressed)
|
||||||
|
{
|
||||||
|
if (td_keycode != keycode || timer_expired(td_timer))
|
||||||
|
{
|
||||||
|
td_keycode = keycode;
|
||||||
|
td_timer = timer_read() + TAPPING_TERM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
run_tap_dance_double(1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (td_keycode != KC_TRANSPARENT)
|
||||||
|
run_tap_dance_double(0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_scan_user(void)
|
||||||
|
{
|
||||||
|
if (td_keycode != KC_TRANSPARENT && timer_expired(td_timer))
|
||||||
|
run_tap_dance_double(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
26
users/xulkal/custom_tap_dance.h
Normal file
26
users/xulkal/custom_tap_dance.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
#ifdef TAP_DANCE_ENABLE
|
||||||
|
|
||||||
|
#include "process_tap_dance.h"
|
||||||
|
|
||||||
|
//Tap Dance Declarations
|
||||||
|
enum {
|
||||||
|
COMM_QUOT = 0,
|
||||||
|
BACKSPACE,
|
||||||
|
DELETE,
|
||||||
|
DOT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define TD_COMM TD(COMM_QUOT)
|
||||||
|
#define TD_BSPC TD(BACKSPACE)
|
||||||
|
#define TD_DEL TD(DELETE)
|
||||||
|
#define TD_DOT TD(DOT)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void run_tap_dance_double(uint8_t i);
|
||||||
|
bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
|
#endif
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _________________QWERTY_L1_________________ KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5
|
#define _________________QWERTY_L1_________________ KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5
|
||||||
#define _________________QWERTY_L2_________________ TD_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T
|
#define _________________QWERTY_L2_________________ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T
|
||||||
#define _________________QWERTY_L3_________________ RIS_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G
|
#define _________________QWERTY_L3_________________ RIS_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G
|
||||||
#define _________________QWERTY_L4_________________ KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B
|
#define _________________QWERTY_L4_________________ KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B
|
||||||
#define _________________QWERTY_L5_________________ KC_LCPO, KC_LGUI, LOWER, RAISE, KC_LALT, KC_SPC
|
#define _________________QWERTY_L5_________________ KC_LCPO, KC_LGUI, LOWER, RAISE, KC_LALT, KC_SPC
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
#define _________________QWERTY_R1_________________ KC_6, KC_7, KC_8, KC_9, KC_0, TD_BSPC
|
#define _________________QWERTY_R1_________________ KC_6, KC_7, KC_8, KC_9, KC_0, TD_BSPC
|
||||||
#define _________________QWERTY_R2_________________ KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS
|
#define _________________QWERTY_R2_________________ KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS
|
||||||
#define _________________QWERTY_R3_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT
|
#define _________________QWERTY_R3_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT
|
||||||
#define _________________QWERTY_R4_________________ KC_N, KC_M, TD_COMM, KC_DOT, KC_SLASH, KC_RSPC
|
#define _________________QWERTY_R4_________________ KC_N, KC_M, TD_COMM, TD_DOT, KC_SLASH, KC_RSPC
|
||||||
#define _________________QWERTY_R5_________________ KC_SPC, KC_LEFT, KC_UP, KC_DOWN, KC_RIGHT, KC_RCPC
|
#define _________________QWERTY_R5_________________ KC_SPC, KC_LEFT, KC_UP, KC_DOWN, KC_RIGHT, KC_RCPC
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,49 +1,50 @@
|
||||||
#include "process_records.h"
|
#include "process_records.h"
|
||||||
|
#include "custom_keycodes.h"
|
||||||
#ifdef TAP_DANCE_ENABLE
|
#include "timer_utils.h"
|
||||||
//Tap Dance Definitions
|
|
||||||
qk_tap_dance_action_t tap_dance_actions[] = {
|
|
||||||
[COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT),
|
|
||||||
[BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)),
|
|
||||||
[TAP_TAB] = ACTION_TAP_DANCE_DOUBLE (KC_TAB, LSFT(KC_TAB)),
|
|
||||||
[CTRL_MINUS] = ACTION_TAP_DANCE_DOUBLE (KC_LCTL, KC_MINS),
|
|
||||||
[CTRL_PLUS] = ACTION_TAP_DANCE_DOUBLE (KC_RCTL, KC_EQL)
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE)
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
extern void eeconfig_update_rgb_matrix_default(void);
|
extern void eeconfig_update_rgb_matrix_default(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TRILAYER_ENABLED
|
#ifdef TRILAYER_ENABLED
|
||||||
uint32_t layer_state_set_user(uint32_t state) {
|
uint32_t layer_state_set_user(uint32_t state)
|
||||||
|
{
|
||||||
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record)
|
||||||
|
{
|
||||||
static uint16_t reset_timer;
|
static uint16_t reset_timer;
|
||||||
switch (keycode) {
|
|
||||||
|
#ifndef TAP_DANCE_ENABLE
|
||||||
|
if (!process_tap_dance_double(keycode, record))
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (keycode)
|
||||||
|
{
|
||||||
case RGBRST:
|
case RGBRST:
|
||||||
|
{
|
||||||
#if defined(RGBLIGHT_ENABLE)
|
#if defined(RGBLIGHT_ENABLE)
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
|
{
|
||||||
eeconfig_update_rgblight_default();
|
eeconfig_update_rgblight_default();
|
||||||
rgblight_enable();
|
rgblight_enable();
|
||||||
}
|
}
|
||||||
#elif defined(RGB_MATRIX_ENABLE)
|
#elif defined(RGB_MATRIX_ENABLE)
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed)
|
||||||
eeconfig_update_rgb_matrix_default();
|
eeconfig_update_rgb_matrix_default();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
case RESET:
|
case RESET:
|
||||||
if (record->event.pressed) {
|
{
|
||||||
reset_timer = timer_read();
|
if (record->event.pressed)
|
||||||
} else {
|
reset_timer = timer_read() + 500;
|
||||||
if (timer_elapsed(reset_timer) >= 500) {
|
else if (timer_expired(reset_timer))
|
||||||
reset_keyboard();
|
reset_keyboard();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
#include "custom_tap_dance.h"
|
||||||
#define RIS_ESC LT(_RAISE, KC_ESC)
|
|
||||||
#define RIS_CAPS LT(_RAISE, KC_CAPS)
|
|
||||||
|
|
||||||
#define QWERTY DF(_QWERTY)
|
|
||||||
|
|
||||||
#ifndef GAMELAYER_DISABLE
|
|
||||||
#define GAME DF(_GAME)
|
|
||||||
#else
|
|
||||||
#define GAME KC_TRANSPARENT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOWER MO(_LOWER)
|
|
||||||
#define RAISE MO(_RAISE)
|
|
||||||
|
|
||||||
#ifdef TAP_DANCE_ENABLE
|
|
||||||
#include "process_tap_dance.h"
|
|
||||||
|
|
||||||
//Tap Dance Declarations
|
|
||||||
enum {
|
|
||||||
COMM_QUOT = 0,
|
|
||||||
BACKSPACE,
|
|
||||||
TAP_TAB,
|
|
||||||
CTRL_MINUS,
|
|
||||||
CTRL_PLUS
|
|
||||||
};
|
|
||||||
|
|
||||||
#define TD_COMM TD(COMM_QUOT)
|
|
||||||
#define TD_BSPC TD(BACKSPACE)
|
|
||||||
#define TD_TAB TD(TAP_TAB)
|
|
||||||
#define TD_LCTL TD(CTRL_MINUS)
|
|
||||||
#define TD_RCTL TD(CTRL_PLUS)
|
|
||||||
#else
|
|
||||||
#define TD_COMM KC_COMM
|
|
||||||
#define TD_BSPC KC_BSPACE
|
|
||||||
#define TD_TAB KC_TAB
|
|
||||||
#define TD_LCTL KC_LCTL
|
|
||||||
#define TD_RCTL KC_RCTL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum layer_number {
|
enum layer_number {
|
||||||
_QWERTY = 0,
|
_QWERTY = 0,
|
||||||
|
@ -52,8 +14,4 @@ enum layer_number {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum custom_keycodes {
|
|
||||||
RGBRST = SAFE_RANGE
|
|
||||||
};
|
|
||||||
|
|
||||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
SRC += xulkal.c \
|
SRC += xulkal.c \
|
||||||
process_records.c
|
process_records.c \
|
||||||
|
custom_tap_dance.c \
|
||||||
|
custom_encoder.c \
|
||||||
|
custom_oled.c \
|
||||||
|
timer_utils.c
|
||||||
|
|
||||||
# Some usual defaults
|
# Some usual defaults
|
||||||
MOUSEKEY_ENABLE = no # Mouse keys (+4700)
|
MOUSEKEY_ENABLE = no # Mouse keys (+4700)
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control (+450)
|
EXTRAKEY_ENABLE = yes # Audio control and System control (+450)
|
||||||
TAP_DANCE_ENABLE = yes # Enable the tap dance feature. (+1100)
|
|
||||||
|
|
||||||
ifneq ($(strip $(DISABLE_LTO)), yes)
|
ifneq ($(strip $(DISABLE_LTO)), yes)
|
||||||
EXTRAFLAGS += -flto
|
EXTRAFLAGS += -flto
|
||||||
|
|
12
users/xulkal/timer_utils.c
Normal file
12
users/xulkal/timer_utils.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include "timer_utils.h"
|
||||||
|
|
||||||
|
bool timer_expired(uint16_t last)
|
||||||
|
{
|
||||||
|
return timer_read() - last < 0x8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool timer_expired32(uint32_t last)
|
||||||
|
{
|
||||||
|
return timer_read32() - last < 0x80000000;
|
||||||
|
}
|
||||||
|
|
6
users/xulkal/timer_utils.h
Normal file
6
users/xulkal/timer_utils.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
#include "timer.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool timer_expired(uint16_t last);
|
||||||
|
bool timer_expired32(uint32_t last);
|
|
@ -2,3 +2,6 @@
|
||||||
|
|
||||||
#include "process_records.h"
|
#include "process_records.h"
|
||||||
#include "layouts.h"
|
#include "layouts.h"
|
||||||
|
#include "timer_utils.h"
|
||||||
|
#include "custom_keycodes.h"
|
||||||
|
#include "custom_tap_dance.h"
|
||||||
|
|
Loading…
Reference in a new issue