aboutsummaryrefslogtreecommitdiff
path: root/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/crkbd/keymaps/thumb_ctrl/keymap.c')
-rwxr-xr-xkeyboards/crkbd/keymaps/thumb_ctrl/keymap.c250
1 files changed, 250 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c b/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c
new file mode 100755
index 000000000..cbd7a4689
--- /dev/null
+++ b/keyboards/crkbd/keymaps/thumb_ctrl/keymap.c
@@ -0,0 +1,250 @@
1#include QMK_KEYBOARD_H
2#include "bootloader.h"
3#ifdef PROTOCOL_LUFA
4 #include "lufa.h"
5 #include "split_util.h"
6#endif
7#ifdef SSD1306OLED
8 #include "ssd1306.h"
9#endif
10
11extern keymap_config_t keymap_config;
12
13#ifdef RGBLIGHT_ENABLE
14//Following line allows macro to read current RGB settings
15extern rgblight_config_t rgblight_config;
16#endif
17
18// Each layer gets a name for readability, which is then used in the keymap matrix below.
19// The underscores don't mean anything - you can have a layer called STUFF or any other name.
20// Layer names don't all need to be of the same length, obviously, and you can also skip them
21// entirely and just use numbers.
22enum layer_names {
23 _QWERTY,
24 _LOWER,
25 _RAISE,
26 _ADJUST
27};
28
29enum custom_keycodes {
30 QWERTY = SAFE_RANGE,
31 LOWER,
32 RAISE,
33 ADJUST,
34 BACKLIT,
35 RGBRST
36};
37
38#define KC_ KC_TRNS
39#define KC______ KC_TRNS
40#define KC_XXXXX KC_NO
41#define KC_LOWER LOWER
42#define KC_RAISE RAISE
43#define KC_RST RESET
44#define KC_LRST RGBRST
45#define KC_LTOG RGB_TOG
46#define KC_LHUI RGB_HUI
47#define KC_LHUD RGB_HUD
48#define KC_LSAI RGB_SAI
49#define KC_LSAD RGB_SAD
50#define KC_LVAI RGB_VAI
51#define KC_LVAD RGB_VAD
52#define KC_LMOD RGB_MOD
53#define KC_CTLTB CTL_T(KC_TAB)
54#define KC_GUIEI GUI_T(KC_LANG2)
55#define KC_ALTKN ALT_T(KC_LANG1)
56#define KC_CTLEN CTL_T(KC_LANG2) // for Linux and Windows
57#define KC_GUIEN GUI_T(KC_LANG2) // for Mac
58#define KC_SFTJP SFT_T(KC_LANG1)
59#define KC_ALTSP ALT_T(KC_SPACE)
60#define KC_ALTDL ALT_T(KC_DEL)
61
62const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
63 [_QWERTY] = LAYOUT(
64 //,-----------------------------------------. ,-----------------------------------------.
65 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
66 //|------+------+------+------+------+------| |------+------+------+------+------+------|
67 KC_CTLTB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
68 //|------+------+------+------+------+------| |------+------+------+------+------+------|
69 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
70 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
71 KC_ALTSP, KC_LOWER, KC_GUIEN, KC_SFTJP, KC_RAISE, KC_ALTDL
72 //`--------------------' `--------------------'
73 ),
74
75 [_LOWER] = LAYOUT(
76 //,-----------------------------------------. ,-----------------------------------------.
77 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
78 //|------+------+------+------+------+------| |------+------+------+------+------+------|
79 _______, KC_HOME, KC_END, KC_PGDN, KC_PGUP, KC_F11, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_F12, KC_PIPE,
80 //|------+------+------+------+------+------| |------+------+------+------+------+------|
81 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______,
82 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
83 _______, _______, _______, _______, _______, _______
84 //`--------------------' `--------------------'
85 ),
86
87 [_RAISE] = LAYOUT(
88 //,-----------------------------------------. ,-----------------------------------------.
89 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
90 //|------+------+------+------+------+------| |------+------+------+------+------+------|
91 _______, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_PSCR, KC_GRV, KC_MINS, KC_PLUS, KC_LCBR, KC_RCBR, KC_BSLS,
92 //|------+------+------+------+------+------| |------+------+------+------+------+------|
93 _______, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_TILD, KC_UNDS, KC_EQL, KC_LBRC, KC_RBRC, _______,
94 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
95 _______, _______, _______, _______, _______, _______
96 //`--------------------' `--------------------'
97 ),
98
99 [_ADJUST] = LAYOUT(
100 //,-----------------------------------------. ,-----------------------------------------.
101 KC_RST, KC_LRST, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX,
102 //|------+------+------+------+------+------| |------+------+------+------+------+------|
103 KC_LTOG, KC_LHUI, KC_LSAI, KC_LVAI, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX,
104 //|------+------+------+------+------+------| |------+------+------+------+------+------|
105 KC_LMOD, KC_LHUD, KC_LSAD, KC_LVAD, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX, KC_XXXXX,
106 //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
107 KC_GUIEI, KC_LOWER, KC_SPC, KC_ENT, KC_RAISE, KC_ALTKN
108 //`--------------------' `--------------------'
109 )
110};
111
112int RGB_current_mode;
113
114void persistent_default_layer_set(uint16_t default_layer) {
115 eeconfig_update_default_layer(default_layer);
116 default_layer_set(default_layer);
117}
118
119// Setting ADJUST layer RGB back to default
120void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
121 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
122 layer_on(layer3);
123 } else {
124 layer_off(layer3);
125 }
126}
127
128void matrix_init_user(void) {
129 #ifdef RGBLIGHT_ENABLE
130 RGB_current_mode = rgblight_config.mode;
131 #endif
132 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
133 #ifdef SSD1306OLED
134 iota_gfx_init(!has_usb()); // turns on the display
135 #endif
136}
137
138//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
139#ifdef SSD1306OLED
140
141// When add source files to SRC in rules.mk, you can use functions.
142const char *read_layer_state(void);
143const char *read_logo(void);
144void set_keylog(uint16_t keycode, keyrecord_t *record);
145const char *read_keylog(void);
146const char *read_keylogs(void);
147
148// const char *read_mode_icon(bool swap);
149// const char *read_host_led_state(void);
150// void set_timelog(void);
151// const char *read_timelog(void);
152
153void matrix_scan_user(void) {
154 iota_gfx_task();
155}
156
157void matrix_render_user(struct CharacterMatrix *matrix) {
158 if (is_master) {
159 // If you want to change the display of OLED, you need to change here
160 matrix_write_ln(matrix, read_layer_state());
161 matrix_write_ln(matrix, read_keylog());
162 matrix_write_ln(matrix, read_keylogs());
163 //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
164 //matrix_write_ln(matrix, read_host_led_state());
165 //matrix_write_ln(matrix, read_timelog());
166 } else {
167 matrix_write(matrix, read_logo());
168 }
169}
170
171void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
172 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
173 memcpy(dest->display, source->display, sizeof(dest->display));
174 dest->dirty = true;
175 }
176}
177
178void iota_gfx_task_user(void) {
179 struct CharacterMatrix matrix;
180 matrix_clear(&matrix);
181 matrix_render_user(&matrix);
182 matrix_update(&display, &matrix);
183}
184#endif//SSD1306OLED
185
186bool process_record_user(uint16_t keycode, keyrecord_t *record) {
187 if (record->event.pressed) {
188#ifdef SSD1306OLED
189 set_keylog(keycode, record);
190#endif
191 // set_timelog();
192 }
193
194 switch (keycode) {
195 case QWERTY:
196 if (record->event.pressed) {
197 persistent_default_layer_set(1UL<<_QWERTY);
198 }
199 return false;
200 break;
201 case LOWER:
202 if (record->event.pressed) {
203 layer_on(_LOWER);
204 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
205 } else {
206 layer_off(_LOWER);
207 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
208 }
209 return false;
210 break;
211 case RAISE:
212 if (record->event.pressed) {
213 layer_on(_RAISE);
214 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
215 } else {
216 layer_off(_RAISE);
217 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
218 }
219 return false;
220 break;
221 case ADJUST:
222 if (record->event.pressed) {
223 layer_on(_ADJUST);
224 } else {
225 layer_off(_ADJUST);
226 }
227 return false;
228 break;
229 case RGB_MOD:
230 #ifdef RGBLIGHT_ENABLE
231 if (record->event.pressed) {
232 rgblight_mode(RGB_current_mode);
233 rgblight_step();
234 RGB_current_mode = rgblight_config.mode;
235 }
236 #endif
237 return false;
238 break;
239 case RGBRST:
240 #ifdef RGBLIGHT_ENABLE
241 if (record->event.pressed) {
242 eeconfig_update_rgblight_default();
243 rgblight_enable();
244 RGB_current_mode = rgblight_config.mode;
245 }
246 #endif
247 break;
248 }
249 return true;
250}