aboutsummaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-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
14 files changed, 295 insertions, 83 deletions
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"