aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c76
-rw-r--r--keyboards/rgbkb/sol/keymaps/xulkal/keymap.c93
-rw-r--r--keyboards/rgbkb/zygomorph/keymaps/xulkal/config.h25
-rw-r--r--keyboards/rgbkb/zygomorph/keymaps/xulkal/keymap.c18
-rw-r--r--users/xulkal/custom_encoder.c13
-rw-r--r--users/xulkal/custom_encoder.h2
-rw-r--r--users/xulkal/custom_keycodes.h28
-rw-r--r--users/xulkal/custom_oled.c96
-rw-r--r--users/xulkal/custom_oled.h2
-rw-r--r--users/xulkal/custom_tap_dance.c61
-rw-r--r--users/xulkal/custom_tap_dance.h26
-rw-r--r--users/xulkal/layouts.h4
-rw-r--r--users/xulkal/process_records.c74
-rw-r--r--users/xulkal/process_records.h44
-rw-r--r--users/xulkal/rules.mk7
-rw-r--r--users/xulkal/timer_utils.c12
-rw-r--r--users/xulkal/timer_utils.h6
-rw-r--r--users/xulkal/xulkal.h3
18 files changed, 332 insertions, 258 deletions
diff --git a/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c b/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c
index 1e50b4a53..8b45b53ec 100644
--- a/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c
+++ b/keyboards/massdrop/ctrl/keymaps/xulkal/keymap.c
@@ -13,23 +13,35 @@ enum ctrl_keycodes {
13 13
14#define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode 14#define TG_NKRO MAGIC_TOGGLE_NKRO //Toggle 6KRO / NKRO mode
15 15
16keymap_config_t keymap_config; 16#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__)
17 17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19 [0] = LAYOUT( 19 [_QWERTY] = LAYOUT(
20 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, \ 20 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, \
21 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, \ 21 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, \
22 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, \
23 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, \
24 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, \
25 KC_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LOWER, KC_APP, KC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT \
26 ),
27
28#ifndef GAMELAYER_DISABLE
29 [_GAME] = LAYOUT(
30 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, \
31 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, \
22 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, \ 32 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, \
23 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, \ 33 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, \
24 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, \ 34 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, \
25 KC_LCPO, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCPC, KC_LEFT, KC_DOWN, KC_RGHT \ 35 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LOWER, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
26 ), 36 ),
27 [1] = LAYOUT( 37#endif
38
39 [_LOWER] = LAYOUT(
28 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \ 40 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, \
29 _______, RGB_RMOD, RGB_MOD,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \ 41 _______, RGB_RMOD,RGB_MOD, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MSTP, KC_VOLU, \
30 RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, MD_BOOT, _______, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \ 42 RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, MD_BOOT, QWERTY, _______, U_T_AUTO,U_T_AGCR,_______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_VOLD, \
31 RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ 43 RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, RGBRST, GAME, _______, _______, _______, _______, _______, _______, _______, \
32 _______, RGB_TOG, _______, _______, _______, _______, TG_NKRO, _______, _______, _______, _______, _______, _______, \ 44 _______, _______, _______, _______, _______, _______, TG_NKRO, _______, _______, _______, _______, _______, _______, \
33 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ 45 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
34 ), 46 ),
35 /* 47 /*
@@ -44,62 +56,46 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44 */ 56 */
45}; 57};
46 58
47// Runs just one time when the keyboard initializes.
48void matrix_init_user(void) {
49};
50
51// Runs constantly in the background, in a loop.
52void matrix_scan_user(void) {
53};
54
55#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT)) 59#define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
56#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL)) 60#define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
57#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT)) 61#define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
58 62
59bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { 63bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
60 static uint32_t key_timer; 64{
65 static uint16_t reset_timer;
61 66
62 switch (keycode) { 67 switch (keycode) {
63 case U_T_AUTO: 68 case U_T_AUTO:
64 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { 69 if (record->event.pressed && MODS_SHIFT && MODS_CTRL)
65 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode"); 70 TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
66 }
67 return false; 71 return false;
68 case U_T_AGCR: 72 case U_T_AGCR:
69 if (record->event.pressed && MODS_SHIFT && MODS_CTRL) { 73 if (record->event.pressed && MODS_SHIFT && MODS_CTRL)
70 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode"); 74 TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
71 }
72 return false; 75 return false;
73 case DBG_TOG: 76 case DBG_TOG:
74 if (record->event.pressed) { 77 if (record->event.pressed)
75 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode"); 78 TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
76 }
77 return false; 79 return false;
78 case DBG_MTRX: 80 case DBG_MTRX:
79 if (record->event.pressed) { 81 if (record->event.pressed)
80 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix"); 82 TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
81 }
82 return false; 83 return false;
83 case DBG_KBD: 84 case DBG_KBD:
84 if (record->event.pressed) { 85 if (record->event.pressed)
85 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard"); 86 TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
86 }
87 return false; 87 return false;
88 case DBG_MOU: 88 case DBG_MOU:
89 if (record->event.pressed) { 89 if (record->event.pressed)
90 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse"); 90 TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
91 }
92 return false; 91 return false;
93 case MD_BOOT: 92 case MD_BOOT:
94 if (record->event.pressed) { 93 if (record->event.pressed)
95 key_timer = timer_read32(); 94 reset_timer = timer_read() + 500;
96 } else { 95 else if (timer_expired(reset_timer))
97 if (timer_elapsed32(key_timer) >= 500) {
98 reset_keyboard(); 96 reset_keyboard();
99 }
100 }
101 return false; 97 return false;
102 default:
103 return true; //Process all other keycodes normally
104 } 98 }
99
100 return true;
105} 101}
diff --git a/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c b/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c
index 5c560abad..09c27428e 100644
--- a/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c
+++ b/keyboards/rgbkb/sol/keymaps/xulkal/keymap.c
@@ -6,10 +6,6 @@
6#include "split_util.h" 6#include "split_util.h"
7#endif 7#endif
8 8
9#ifdef OLED_DRIVER_ENABLE
10 #include "oled_driver.h"
11#endif
12
13#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__) 9#define EXPAND_LAYOUT(...) LAYOUT(__VA_ARGS__)
14 10
15// Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns 11// 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] = {
36 _________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \ 32 _________________QWERTY_L3_________________, KC_GRV, KC_QUOT, _________________QWERTY_R3_________________, \
37 _________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \ 33 _________________QWERTY_L4_________________, RGB_TOG, RGBRST, _________________QWERTY_R4_________________, \
38 _________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \ 34 _________________QWERTY_L5_________________, RGB_RMOD, RGB_MOD, _________________QWERTY_R5_________________, \
39 KC_SPC, KC_DEL, KC_ENT, KC_SPC \ 35 KC_SPC, TD_DEL, KC_ENT, KC_SPC \
40 ), 36 ),
41 37
42#ifndef GAMELAYER_DISABLE 38#ifndef GAMELAYER_DISABLE
@@ -79,90 +75,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
79 ), 75 ),
80#endif 76#endif
81}; 77};
82
83//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
84#ifdef OLED_DRIVER_ENABLE
85
86static void render_logo(void) {
87 static const char PROGMEM sol_logo[] = {
88 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
89 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
90 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
91
92 oled_write_P(sol_logo, false);
93}
94
95
96static void render_status(void) {
97 // Render to mode icon
98 static const char PROGMEM mode_logo[2][3] = {
99 {0x97,0x98,0},
100 {0xb7,0xb8,0} };
101
102 oled_write_P(mode_logo[0], false);
103
104#if defined(RGB_MATRIX_ENABLE)
105 static char buffer[20] = {0};
106 snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
107 oled_write(buffer, false);
108#endif
109
110 oled_write_P(mode_logo[1], false);
111
112#if defined(RGB_MATRIX_ENABLE)
113 snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
114 oled_write(buffer, false);
115#endif
116
117 // 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
118 oled_write_P(PSTR("Layer: "), false);
119 switch (biton32(layer_state)) {
120 case _QWERTY:
121#ifndef GAMELAYER_DISABLE
122 switch (biton32(default_layer_state)) {
123 case _QWERTY:
124 oled_write_P(PSTR("Default\n"), false);
125 break;
126 case _GAME:
127 oled_write_P(PSTR("Game\n"), false);
128 break;
129 default:
130 oled_write_P(PSTR("Undefined\n"), false);
131 break;
132 }
133#else
134 oled_write_P(PSTR("Default\n"), false);
135#endif
136 break;
137 case _LOWER:
138 oled_write_P(PSTR("Lower\n"), false);
139 break;
140 case _RAISE:
141 oled_write_P(PSTR("Raise\n"), false);
142 break;
143#ifdef TRILAYER_ENABLED
144 case _ADJUST:
145 oled_write_P(PSTR("Adjust\n"), false);
146 break;
147#endif
148 default:
149 oled_write_P(PSTR("Undefined\n"), false);
150 }
151
152 // Host Keyboard LED Status
153 uint8_t led_usb_state = host_keyboard_leds();
154 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
155 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
156 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
157}
158
159void oled_task_user(void) {
160 if (is_keyboard_master()) {
161 render_status();
162 } else {
163 render_logo();
164 oled_scroll_left();
165 }
166}
167
168#endif
diff --git a/keyboards/rgbkb/zygomorph/keymaps/xulkal/config.h b/keyboards/rgbkb/zygomorph/keymaps/xulkal/config.h
deleted file mode 100644
index 452cdda82..000000000
--- a/keyboards/rgbkb/zygomorph/keymaps/xulkal/config.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2This is the c configuration file for the keymap
3
4Copyright 2012 Jun Wako <wakojun@gmail.com>
5Copyright 2015 Jack Humbert
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23
24// place overrides here
25
diff --git a/keyboards/rgbkb/zygomorph/keymaps/xulkal/keymap.c b/keyboards/rgbkb/zygomorph/keymaps/xulkal/keymap.c
index f886cb454..70155e1cd 100644
--- a/keyboards/rgbkb/zygomorph/keymaps/xulkal/keymap.c
+++ b/keyboards/rgbkb/zygomorph/keymaps/xulkal/keymap.c
@@ -67,21 +67,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
67 ), 67 ),
68#endif 68#endif
69}; 69};
70
71#ifdef ENCODER_ENABLE
72void encoder_update_user(uint8_t index, bool clockwise) {
73 if (index == 0) { /* First encoder */
74 if (clockwise) {
75 tap_code(KC_PGDN);
76 } else {
77 tap_code(KC_PGUP);
78 }
79 } else if (index == 1) { /* Second encoder from slave */
80 if (clockwise) {
81 tap_code(KC_UP);
82 } else {
83 tap_code(KC_DOWN);
84 }
85 }
86}
87#endif
diff --git a/users/xulkal/custom_encoder.c b/users/xulkal/custom_encoder.c
new file mode 100644
index 000000000..09f1cda0d
--- /dev/null
+++ b/users/xulkal/custom_encoder.c
@@ -0,0 +1,13 @@
1#include "custom_encoder.h"
2
3#ifdef ENCODER_ENABLE
4const uint16_t PROGMEM encoders[][2] = {
5 { KC_PGUP, KC_PGDN },
6 { KC_DOWN, KC_UP }
7}
8
9void encoder_update_user(uint8_t index, bool clockwise)
10{
11 tap_code16(pgm_read_word(&encoders[index][clockwise]));
12}
13#endif
diff --git a/users/xulkal/custom_encoder.h b/users/xulkal/custom_encoder.h
new file mode 100644
index 000000000..010d4b138
--- /dev/null
+++ b/users/xulkal/custom_encoder.h
@@ -0,0 +1,2 @@
1#pragma once
2#include "quantum.h"
diff --git a/users/xulkal/custom_keycodes.h b/users/xulkal/custom_keycodes.h
new file mode 100644
index 000000000..d4ae0bd47
--- /dev/null
+++ b/users/xulkal/custom_keycodes.h
@@ -0,0 +1,28 @@
1#pragma once
2
3enum custom_keycodes {
4 RGBRST = SAFE_RANGE,
5#ifndef TAP_DANCE_ENABLE
6 TD_MIN,
7 TD_COMM = TD_MIN,
8 TD_BSPC,
9 TD_DEL,
10 TD_DOT,
11 TD_MAX,
12#endif
13 KEYMAP_SAFE_RANGE
14};
15
16#define RIS_ESC LT(_RAISE, KC_ESC)
17#define RIS_CAPS LT(_RAISE, KC_CAPS)
18
19#define QWERTY DF(_QWERTY)
20
21#ifndef GAMELAYER_DISABLE
22#define GAME DF(_GAME)
23#else
24#define GAME KC_TRANSPARENT
25#endif
26
27#define LOWER MO(_LOWER)
28#define RAISE MO(_RAISE)
diff --git a/users/xulkal/custom_oled.c b/users/xulkal/custom_oled.c
new file mode 100644
index 000000000..77e580b95
--- /dev/null
+++ b/users/xulkal/custom_oled.c
@@ -0,0 +1,96 @@
1#include "custom_oled.h"
2#include "process_records.h"
3
4#include <stdio.h>
5
6#ifdef OLED_DRIVER_ENABLE
7
8static void render_logo(void)
9{
10 static const char PROGMEM sol_logo[] = {
11 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
12 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
13 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
14 oled_write_P(sol_logo, false);
15}
16
17static void render_status(void)
18{
19 // Render to mode icon
20 static const char PROGMEM mode_logo[2][3] = {
21 {0x97,0x98,0},
22 {0xb7,0xb8,0}
23 };
24
25 oled_write_P(mode_logo[0], false);
26
27#if defined(RGB_MATRIX_ENABLE)
28 static char buffer[20] = {0};
29 snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
30 oled_write(buffer, false);
31#endif
32
33 oled_write_P(mode_logo[1], false);
34
35#if defined(RGB_MATRIX_ENABLE)
36 snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
37 oled_write(buffer, false);
38#endif
39
40 // 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
41 oled_write_P(PSTR("Layer: "), false);
42 switch (biton32(layer_state))
43 {
44 case _QWERTY:
45#ifndef GAMELAYER_DISABLE
46 switch (biton32(default_layer_state))
47 {
48 case _QWERTY:
49 oled_write_P(PSTR("Default\n"), false);
50 break;
51 case _GAME:
52 oled_write_P(PSTR("Game\n"), false);
53 break;
54 default:
55 oled_write_P(PSTR("Undefined\n"), false);
56 break;
57 }
58#else
59 oled_write_P(PSTR("Default\n"), false);
60#endif
61 break;
62 case _LOWER:
63 oled_write_P(PSTR("Lower\n"), false);
64 break;
65 case _RAISE:
66 oled_write_P(PSTR("Raise\n"), false);
67 break;
68#ifdef TRILAYER_ENABLED
69 case _ADJUST:
70 oled_write_P(PSTR("Adjust\n"), false);
71 break;
72#endif
73 default:
74 oled_write_P(PSTR("Undefined\n"), false);
75 break;
76 }
77
78 // Host Keyboard LED Status
79 uint8_t led_usb_state = host_keyboard_leds();
80 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
81 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
82 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
83}
84
85void oled_task_user(void)
86{
87 if (is_keyboard_master())
88 render_status();
89 else
90 {
91 render_logo();
92 oled_scroll_left();
93 }
94}
95
96#endif
diff --git a/users/xulkal/custom_oled.h b/users/xulkal/custom_oled.h
new file mode 100644
index 000000000..010d4b138
--- /dev/null
+++ b/users/xulkal/custom_oled.h
@@ -0,0 +1,2 @@
1#pragma once
2#include "quantum.h"
diff --git a/users/xulkal/custom_tap_dance.c b/users/xulkal/custom_tap_dance.c
new file mode 100644
index 000000000..a1c644efd
--- /dev/null
+++ b/users/xulkal/custom_tap_dance.c
@@ -0,0 +1,61 @@
1#include "custom_tap_dance.h"
2#include "custom_keycodes.h"
3#include "timer_utils.h"
4
5#ifdef TAP_DANCE_ENABLE
6
7//Tap Dance Definitions
8qk_tap_dance_action_t tap_dance_actions[] = {
9 [COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT),
10 [BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)),
11 [DELETE] = ACTION_TAP_DANCE_DOUBLE (KC_DELETE, LCTL(KC_DELETE))
12};
13
14#else
15
16static uint16_t td_keycode;
17static uint16_t td_timer;
18
19const uint16_t PROGMEM td_keymaps[TD_MAX - TD_MIN][2] = {
20 [TD_COMM - TD_MIN] = { KC_COMM, KC_QUOT },
21 [TD_BSPC - TD_MIN] = { KC_BSPACE, LCTL(KC_BSPACE) },
22 [TD_DEL - TD_MIN] = { KC_DELETE, LCTL(KC_DELETE) },
23 [TD_DOT - TD_MIN] = { KC_DOT, KC_GRAVE }
24};
25
26void run_tap_dance_double(uint8_t i)
27{
28 tap_code16(pgm_read_word(&td_keymaps[td_keycode - TD_MIN][i]));
29 td_keycode = KC_TRANSPARENT;
30 td_timer = timer_read() + TAPPING_TERM;
31}
32
33bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record)
34{
35 if (TD_MIN <= keycode && keycode < TD_MAX)
36 {
37 if (record->event.pressed)
38 {
39 if (td_keycode != keycode || timer_expired(td_timer))
40 {
41 td_keycode = keycode;
42 td_timer = timer_read() + TAPPING_TERM;
43 }
44 else
45 run_tap_dance_double(1);
46 }
47 return false;
48 }
49
50 if (td_keycode != KC_TRANSPARENT)
51 run_tap_dance_double(0);
52 return true;
53}
54
55void matrix_scan_user(void)
56{
57 if (td_keycode != KC_TRANSPARENT && timer_expired(td_timer))
58 run_tap_dance_double(0);
59}
60
61#endif
diff --git a/users/xulkal/custom_tap_dance.h b/users/xulkal/custom_tap_dance.h
new file mode 100644
index 000000000..33398808d
--- /dev/null
+++ b/users/xulkal/custom_tap_dance.h
@@ -0,0 +1,26 @@
1#pragma once
2#include "quantum.h"
3
4#ifdef TAP_DANCE_ENABLE
5
6#include "process_tap_dance.h"
7
8//Tap Dance Declarations
9enum {
10 COMM_QUOT = 0,
11 BACKSPACE,
12 DELETE,
13 DOT
14};
15
16#define TD_COMM TD(COMM_QUOT)
17#define TD_BSPC TD(BACKSPACE)
18#define TD_DEL TD(DELETE)
19#define TD_DOT TD(DOT)
20
21#else
22
23void run_tap_dance_double(uint8_t i);
24bool process_tap_dance_double(uint16_t keycode, keyrecord_t *record);
25
26#endif
diff --git a/users/xulkal/layouts.h b/users/xulkal/layouts.h
index 5180992a8..65dad8c63 100644
--- a/users/xulkal/layouts.h
+++ b/users/xulkal/layouts.h
@@ -15,7 +15,7 @@
15 */ 15 */
16 16
17#define _________________QWERTY_L1_________________ KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5 17#define _________________QWERTY_L1_________________ KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5
18#define _________________QWERTY_L2_________________ TD_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T 18#define _________________QWERTY_L2_________________ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T
19#define _________________QWERTY_L3_________________ RIS_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G 19#define _________________QWERTY_L3_________________ RIS_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G
20#define _________________QWERTY_L4_________________ KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B 20#define _________________QWERTY_L4_________________ KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B
21#define _________________QWERTY_L5_________________ KC_LCPO, KC_LGUI, LOWER, RAISE, KC_LALT, KC_SPC 21#define _________________QWERTY_L5_________________ KC_LCPO, KC_LGUI, LOWER, RAISE, KC_LALT, KC_SPC
@@ -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, KC_DOT, KC_SLASH, KC_RSPC 26#define _________________QWERTY_R4_________________ KC_N, KC_M, TD_COMM, TD_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
diff --git a/users/xulkal/process_records.c b/users/xulkal/process_records.c
index 5ba59965f..115623caa 100644
--- a/users/xulkal/process_records.c
+++ b/users/xulkal/process_records.c
@@ -1,56 +1,58 @@
1#include "process_records.h" 1#include "process_records.h"
2 2#include "custom_keycodes.h"
3#ifdef TAP_DANCE_ENABLE 3#include "timer_utils.h"
4//Tap Dance Definitions
5qk_tap_dance_action_t tap_dance_actions[] = {
6 [COMM_QUOT] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_QUOT),
7 [BACKSPACE] = ACTION_TAP_DANCE_DOUBLE (KC_BSPACE, LCTL(KC_BSPACE)),
8 [TAP_TAB] = ACTION_TAP_DANCE_DOUBLE (KC_TAB, LSFT(KC_TAB)),
9 [CTRL_MINUS] = ACTION_TAP_DANCE_DOUBLE (KC_LCTL, KC_MINS),
10 [CTRL_PLUS] = ACTION_TAP_DANCE_DOUBLE (KC_RCTL, KC_EQL)
11};
12#endif
13 4
14#if defined(RGB_MATRIX_ENABLE) 5#if defined(RGB_MATRIX_ENABLE)
15extern void eeconfig_update_rgb_matrix_default(void); 6extern void eeconfig_update_rgb_matrix_default(void);
16#endif 7#endif
17 8
18#ifdef TRILAYER_ENABLED 9#ifdef TRILAYER_ENABLED
19uint32_t layer_state_set_user(uint32_t state) { 10uint32_t layer_state_set_user(uint32_t state)
20 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); 11{
12 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
21} 13}
22#endif 14#endif
23 15
24bool process_record_user(uint16_t keycode, keyrecord_t *record) { 16bool process_record_user(uint16_t keycode, keyrecord_t *record)
25 static uint16_t reset_timer; 17{
26 switch (keycode) { 18 static uint16_t reset_timer;
27 case RGBRST: 19
20#ifndef TAP_DANCE_ENABLE
21 if (!process_tap_dance_double(keycode, record))
22 return false;
23#endif
24
25 switch (keycode)
26 {
27 case RGBRST:
28 {
28#if defined(RGBLIGHT_ENABLE) 29#if defined(RGBLIGHT_ENABLE)
29 if (record->event.pressed) { 30 if (record->event.pressed)
30 eeconfig_update_rgblight_default(); 31 {
31 rgblight_enable(); 32 eeconfig_update_rgblight_default();
32 } 33 rgblight_enable();
34 }
33#elif defined(RGB_MATRIX_ENABLE) 35#elif defined(RGB_MATRIX_ENABLE)
34 if (record->event.pressed) { 36 if (record->event.pressed)
35 eeconfig_update_rgb_matrix_default(); 37 eeconfig_update_rgb_matrix_default();
36 }
37#endif 38#endif
38 return false; 39 }
39 case RESET: 40 return false;
40 if (record->event.pressed) { 41 case RESET:
41 reset_timer = timer_read(); 42 {
42 } else { 43 if (record->event.pressed)
43 if (timer_elapsed(reset_timer) >= 500) { 44 reset_timer = timer_read() + 500;
44 reset_keyboard(); 45 else if (timer_expired(reset_timer))
45 } 46 reset_keyboard();
46 } 47 }
47 return false; 48 return false;
48 } 49 }
49 50
50 return process_record_keymap(keycode, record); 51 return process_record_keymap(keycode, record);
51} 52}
52 53
53__attribute__ ((weak)) 54__attribute__ ((weak))
54bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { 55bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
55 return true; 56{
57 return true;
56} 58}
diff --git a/users/xulkal/process_records.h b/users/xulkal/process_records.h
index 8a195df5c..701ef7e74 100644
--- a/users/xulkal/process_records.h
+++ b/users/xulkal/process_records.h
@@ -1,44 +1,6 @@
1#pragma once 1#pragma once
2#include "quantum.h" 2#include "quantum.h"
3 3#include "custom_tap_dance.h"
4#define RIS_ESC LT(_RAISE, KC_ESC)
5#define RIS_CAPS LT(_RAISE, KC_CAPS)
6
7#define QWERTY DF(_QWERTY)
8
9#ifndef GAMELAYER_DISABLE
10#define GAME DF(_GAME)
11#else
12#define GAME KC_TRANSPARENT
13#endif
14
15#define LOWER MO(_LOWER)
16#define RAISE MO(_RAISE)
17
18#ifdef TAP_DANCE_ENABLE
19#include "process_tap_dance.h"
20
21//Tap Dance Declarations
22enum {
23 COMM_QUOT = 0,
24 BACKSPACE,
25 TAP_TAB,
26 CTRL_MINUS,
27 CTRL_PLUS
28};
29
30#define TD_COMM TD(COMM_QUOT)
31#define TD_BSPC TD(BACKSPACE)
32#define TD_TAB TD(TAP_TAB)
33#define TD_LCTL TD(CTRL_MINUS)
34#define TD_RCTL TD(CTRL_PLUS)
35#else
36#define TD_COMM KC_COMM
37#define TD_BSPC KC_BSPACE
38#define TD_TAB KC_TAB
39#define TD_LCTL KC_LCTL
40#define TD_RCTL KC_RCTL
41#endif
42 4
43enum layer_number { 5enum layer_number {
44 _QWERTY = 0, 6 _QWERTY = 0,
@@ -52,8 +14,4 @@ enum layer_number {
52#endif 14#endif
53}; 15};
54 16
55enum custom_keycodes {
56 RGBRST = SAFE_RANGE
57};
58
59bool process_record_keymap(uint16_t keycode, keyrecord_t *record); 17bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
diff --git a/users/xulkal/rules.mk b/users/xulkal/rules.mk
index 6758f52f5..50dc75d61 100644
--- a/users/xulkal/rules.mk
+++ b/users/xulkal/rules.mk
@@ -1,10 +1,13 @@
1SRC += xulkal.c \ 1SRC += xulkal.c \
2 process_records.c 2 process_records.c \
3 custom_tap_dance.c \
4 custom_encoder.c \
5 custom_oled.c \
6 timer_utils.c
3 7
4# Some usual defaults 8# Some usual defaults
5MOUSEKEY_ENABLE = no # Mouse keys (+4700) 9MOUSEKEY_ENABLE = no # Mouse keys (+4700)
6EXTRAKEY_ENABLE = yes # Audio control and System control (+450) 10EXTRAKEY_ENABLE = yes # Audio control and System control (+450)
7TAP_DANCE_ENABLE = yes # Enable the tap dance feature. (+1100)
8 11
9ifneq ($(strip $(DISABLE_LTO)), yes) 12ifneq ($(strip $(DISABLE_LTO)), yes)
10 EXTRAFLAGS += -flto 13 EXTRAFLAGS += -flto
diff --git a/users/xulkal/timer_utils.c b/users/xulkal/timer_utils.c
new file mode 100644
index 000000000..5f5d9a1eb
--- /dev/null
+++ b/users/xulkal/timer_utils.c
@@ -0,0 +1,12 @@
1#include "timer_utils.h"
2
3bool timer_expired(uint16_t last)
4{
5 return timer_read() - last < 0x8000;
6}
7
8bool timer_expired32(uint32_t last)
9{
10 return timer_read32() - last < 0x80000000;
11}
12
diff --git a/users/xulkal/timer_utils.h b/users/xulkal/timer_utils.h
new file mode 100644
index 000000000..7e2a0b74d
--- /dev/null
+++ b/users/xulkal/timer_utils.h
@@ -0,0 +1,6 @@
1#pragma once
2#include "timer.h"
3#include <stdbool.h>
4
5bool timer_expired(uint16_t last);
6bool timer_expired32(uint32_t last);
diff --git a/users/xulkal/xulkal.h b/users/xulkal/xulkal.h
index ae7359923..9bc83b7de 100644
--- a/users/xulkal/xulkal.h
+++ b/users/xulkal/xulkal.h
@@ -2,3 +2,6 @@
2 2
3#include "process_records.h" 3#include "process_records.h"
4#include "layouts.h" 4#include "layouts.h"
5#include "timer_utils.h"
6#include "custom_keycodes.h"
7#include "custom_tap_dance.h"