configs/keymap.c
keymap.cRaw
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include QMK_KEYBOARD_H
20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [0] = LAYOUT_split_3x6_3(
23 //,-----------------------------------------------------. ,-----------------------------------------------------.
24 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
25 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
26 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
27 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
28 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
29 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
30 KC_LGUI, MO(1), KC_SPC, KC_ENT, MO(2), KC_RALT
31 //`--------------------------' `--------------------------'
32
33 ),
34
35 [1] = LAYOUT_split_3x6_3(
36 //,-----------------------------------------------------. ,-----------------------------------------------------.
37 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
38 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
39 KC_LCTL,KC__MUTE,KC__VOLDOWN,KC__VOLUP, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, XXXXXXX, XXXXXXX,
40 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
41 KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
42 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
43 KC_LGUI, _______, KC_SPC, KC_ENT, MO(3), KC_RALT
44 //`--------------------------' `--------------------------'
45 ),
46
47 [2] = LAYOUT_split_3x6_3(
48 //,-----------------------------------------------------. ,-----------------------------------------------------.
49 KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
50 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
51 KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_GRV,
52 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
53 KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
54 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
55 KC_LGUI, MO(3), KC_SPC, KC_ENT, _______, KC_RALT
56 //`--------------------------' `--------------------------'
57 ),
58
59 [3] = LAYOUT_split_3x6_3(
60 //,-----------------------------------------------------. ,-----------------------------------------------------.
61 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
62 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
63 RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
64 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
65 RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
66 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
67 KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT
68 //`--------------------------' `--------------------------'
69 )
70};
71
72#ifdef OLED_DRIVER_ENABLE
73oled_rotation_t oled_init_user(oled_rotation_t rotation) {
74 if (!is_master) {
75 return OLED_ROTATION_180; // flips the display 180 degrees if offhand
76 }
77 return rotation;
78}
79
80#define L_BASE 0
81#define L_LOWER 2
82#define L_RAISE 4
83#define L_ADJUST 8
84
85void oled_render_layer_state(void) {
86 oled_write_P(PSTR("Layer: "), false);
87 switch (layer_state) {
88 case L_BASE:
89 oled_write_ln_P(PSTR("Default"), false);
90 break;
91 case L_LOWER:
92 oled_write_ln_P(PSTR("Lower"), false);
93 break;
94 case L_RAISE:
95 oled_write_ln_P(PSTR("Raise"), false);
96 break;
97 case L_ADJUST:
98 case L_ADJUST|L_LOWER:
99 case L_ADJUST|L_RAISE:
100 case L_ADJUST|L_LOWER|L_RAISE:
101 oled_write_ln_P(PSTR("Adjust"), false);
102 break;
103 }
104}
105
106
107char keylog_str[24] = {};
108
109const char code_to_name[60] = {
110 ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
111 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
112 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
113 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
114 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
115 '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
116
117void set_keylog(uint16_t keycode, keyrecord_t *record) {
118 char name = ' ';
119 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) ||
120 (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; }
121 if (keycode < 60) {
122 name = code_to_name[keycode];
123 }
124
125 // update keylog
126 snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
127 record->event.key.row, record->event.key.col,
128 keycode, name);
129}
130
131void oled_render_keylog(void) {
132 oled_write(keylog_str, false);
133}
134
135void render_bootmagic_status(bool status) {
136 /* Show Ctrl-Gui Swap options */
137 static const char PROGMEM logo[][2][3] = {
138 {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
139 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
140 };
141 if (status) {
142 oled_write_ln_P(logo[0][0], false);
143 oled_write_ln_P(logo[0][1], false);
144 } else {
145 oled_write_ln_P(logo[1][0], false);
146 oled_write_ln_P(logo[1][1], false);
147 }
148}
149
150void oled_render_logo(void) {
151 static const char PROGMEM crkbd_logo[] = {
152 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
153 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
154 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
155 0};
156 oled_write_P(crkbd_logo, false);
157}
158
159void oled_task_user(void) {
160 if (is_master) {
161 oled_render_layer_state();
162 oled_render_keylog();
163 } else {
164 oled_render_logo();
165 }
166}
167
168bool process_record_user(uint16_t keycode, keyrecord_t *record) {
169 if (record->event.pressed) {
170 set_keylog(keycode, record);
171 }
172 return true;
173}
174#endif // OLED_DRIVER_ENABLE