aboutsummaryrefslogtreecommitdiff
path: root/keyboards/yosino58/keymaps/default/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/yosino58/keymaps/default/keymap.c')
-rw-r--r--keyboards/yosino58/keymaps/default/keymap.c337
1 files changed, 337 insertions, 0 deletions
diff --git a/keyboards/yosino58/keymaps/default/keymap.c b/keyboards/yosino58/keymaps/default/keymap.c
new file mode 100644
index 000000000..79b507569
--- /dev/null
+++ b/keyboards/yosino58/keymaps/default/keymap.c
@@ -0,0 +1,337 @@
1#include QMK_KEYBOARD_H
2#ifdef PROTOCOL_LUFA
3 #include "lufa.h"
4 #include "split_util.h"
5#endif
6#ifdef SSD1306OLED
7 #include "ssd1306.h"
8#endif
9
10extern keymap_config_t keymap_config;
11
12#ifdef RGBLIGHT_ENABLE
13//Following line allows macro to read current RGB settings
14extern rgblight_config_t rgblight_config;
15#endif
16
17extern uint8_t is_master;
18
19// Each layer gets a name for readability, which is then used in the keymap matrix below.
20// The underscores don't mean anything - you can have a layer called STUFF or any other name.
21// Layer names don't all need to be of the same length, obviously, and you can also skip them
22// entirely and just use numbers.
23#define _QWERTY 0
24#define _LOWER 1
25#define _RAISE 2
26#define _ADJUST 3
27
28enum custom_keycodes {
29 QWERTY = SAFE_RANGE,
30 LOWER,
31 RAISE,
32 ADJUST,
33 RGBRST
34};
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37/* QWERTY
38 * ,-----------------------------------------. ,-----------------------------------------.
39 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
40 * |------+------+------+------+------+------| |------+------+------+------+------+------|
41 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | = |
42 * |------+------+------+------+------+------| |------+------+------+------+------+------|
43 * |LShift| A | S | D | F | G | | H | J | K | L | ; | ' |
44 * |------+------+------+------+------+------| |------+------+------+------+------+------|
45 * |LCTRL | Z | X | C | V | B |-------.-------. ,---------------| N | M | , | . | / | \ |
46 * `-----------------------------------------/ Del / / \ \ Bksp \----------------------------------------'
47 * | LAlt |ADJUST| /-------/ Space / \ Enter \-------\ | [ | ] |
48 * | | |/ LOWER / / \ \ RAISE \ | | |
49 * `-----------------------------' '------------------------------'
50 */
51 [_QWERTY] = LAYOUT( \
52 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, \
53 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL, \
54 KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
55 KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_DEL, KC_SPC, KC_ENT, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, \
56 KC_LALT, ADJUST, LOWER, RAISE, KC_LBRC, KC_RBRC\
57 ),
58
59/* LOWER
60 * ,-----------------------------------------. ,-----------------------------------------.
61 * | ESC | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
62 * |------+------+------+------+------+------| |------+------+------+------+------+------|
63 * | Tab | / | - | 7 | 8 | 9 | | ! | @ | # | $ | % | F12 |
64 * |------+------+------+------+------+------| |------+------+------+------+------+------|
65 * |LShift| * | + | 4 | 5 | 6 | | ^ | & | * | ( | ) | - |
66 * |------+------+------+------+------+------| |------+------+------+------+------+------|
67 * |LCTRL | . | 0 | 1 | 2 | 3 |-------.-------. ,---------------| | _ | + | { | } | | |
68 * `-----------------------------------------/ F11 / / \ \ F12 \----------------------------------------'
69 * | LAlt | LGUI | /-------/ Space / \ Enter \-------\ | Caps | Num |
70 * | | |/ LOWER / / \ \ \ | | |
71 * `-----------------------------' '------------------------------'
72 */
73 [_LOWER] = LAYOUT( \
74 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, \
75 _______, KC_PSLS, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_F12, \
76 _______, KC_PAST, KC_PPLS, KC_P4, KC_P5, KC_P6, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TILD, \
77 _______, KC_PDOT, KC_P0, KC_P1, KC_P2, KC_P3, _______, _______, _______, _______, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
78 _______, KC_LGUI, _______, XXXXXXX, KC_CLCK, KC_NLCK\
79
80 ),
81
82/* RAISE
83 * ,-----------------------------------------. ,-----------------------------------------.
84 * | | | | | | | | | | | | | |
85 * |------+------+------+------+------+------| |------+------+------+------+------+------|
86 * | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
87 * |------+------+------+------+------+------| |------+------+------+------+------+------|
88 * | F1 | F2 | F3 | F4 | F5 | F6 | | | | | | | |
89 * |------+------+------+------+------+------| |------+------+------+------+------+------|
90 * | F7 | F8 | F9 | F10 | F11 | F12 |-------.-------. ,---------------| | | | | | |
91 * `-----------------------------------------/ / / \ \ \----------------------------------------'
92 * | | | /-------/ Space / \ Enter \-------\ | | |
93 * | | |/ / / \ \ RAISE \ | | |
94 * `-----------------------------' '------------------------------'
95 */
96 [_RAISE] = LAYOUT( \
97 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
98 XXXXXXX, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, XXXXXXX, \
99 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, KC_UP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
100 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, _______, _______, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, XXXXXXX, \
101 XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX \
102 ),
103
104/* ADJUST
105 * ,-----------------------------------------. ,-----------------------------------------.
106 * |RESET | | | | | | | Mute | Vol+ | Play | | | |
107 * |------+------+------+------+------+------| |------+------+------+------+------+------|
108 * | | | | PSCR | SLCK | Pause| | Prev | Vol- | Next | | | |
109 * |------+------+------+------+------+------| |------+------+------+------+------+------|
110 * | | | |Insert| Home |PageUP| | | |RGB ON| HUE+ | SAT+ | VAL+ |
111 * |------+------+------+------+------+------| |------+------+------+------+------+------|
112 * | | | | Del | End |PageDN|-------.-------. ,---------------| |RGB Re| MODE | HUE- | SAT- | VAL- |
113 * `-----------------------------------------/ / / \ \ \----------------------------------------'
114 * | |ADJUST| /-------/ Space / \ Enter \-------\ | | |
115 * | | |/ / / \ \ \ | | |
116 * `-----------------------------' '------------------------------'
117 */
118 [_ADJUST] = LAYOUT( \
119 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MUTE, KC_VOLU, KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX, \
120 XXXXXXX, XXXXXXX, XXXXXXX, KC_PSCR, KC_SLCK, KC_PAUS, KC_MPRV, KC_VOLD, KC_MNXT, XXXXXXX, XXXXXXX, XXXXXXX, \
121 XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, KC_HOME, KC_PGUP, XXXXXXX, XXXXXXX, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
122 XXXXXXX, XXXXXXX, XXXXXXX, KC_DEL, KC_END, KC_PGDN, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, RGBRST, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, \
123 XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
124 )
125};
126
127
128int RGB_current_mode;
129
130void persistent_default_layer_set(uint16_t default_layer) {
131 eeconfig_update_default_layer(default_layer);
132 default_layer_set(default_layer);
133}
134
135// Setting ADJUST layer RGB back to default
136void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
137 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
138 layer_on(layer3);
139 } else {
140 layer_off(layer3);
141 }
142}
143
144void matrix_init_user(void) {
145 #ifdef RGBLIGHT_ENABLE
146 RGB_current_mode = rgblight_config.mode;
147 #endif
148 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
149 #ifdef SSD1306OLED
150 #ifdef SSD1306_128X64
151 iota_gfx_init(false); // turns on the display
152 #else
153 iota_gfx_init(!has_usb()); // turns on the display
154 #endif
155 #endif
156}
157
158//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
159#ifdef SSD1306OLED
160
161//assign the right code to your layers for OLED display
162#define L_QWERTY 0
163#define L_LOWER 2
164#define L_RAISE 4
165#define L_ADJUST 8
166
167// When add source files to SRC in rules.mk, you can use functions.
168const char *read_logo(void);
169
170void matrix_scan_user(void) {
171 iota_gfx_task();
172}
173
174void matrix_render_user(struct CharacterMatrix *matrix) {
175 if (is_master) {
176 static char indctr[2][20][5]=
177 {
178 // white icon
179 {
180 {0x80,0x81,0x82,0x83,0},
181 {0x88,0x89,0x8A,0x8B,0},
182 {0x90,0x91,0x92,0x93,0},
183 {0x98,0x99,0x9A,0x9B,0},
184 {0x01,0x02,0x03,0x04,0},
185 {0xA0,0xA1,0xA2,0xA3,0},
186 {0xA8,0xA9,0xAA,0xAB,0},
187 {0xB0,0xB1,0xB2,0xB3,0},
188 {0xB8,0xB9,0xBA,0xBB,0},
189 {0x21,0x22,0x23,0x24,0},
190 {0xC0,0xC1,0xC2,0xC3,0},
191 {0xC8,0xC9,0xCA,0xCB,0},
192 {0xD0,0xD1,0xD2,0xD3,0},
193 {0xD8,0xD9,0xDA,0xDB,0},
194 {0x41,0x42,0x43,0x44,0},
195 {0xE0,0xE1,0xE2,0xE3,0},
196 {0xE8,0xE9,0xEA,0xEB,0},
197 {0xF0,0xF1,0xF2,0xF3,0},
198 {0xF8,0xF9,0xFA,0xFB,0},
199 {0x61,0x62,0x63,0x64,0}
200 },
201 // Black icon
202 {
203 {0x84,0x85,0x86,0x87,0},
204 {0x8C,0x8D,0x8E,0x8F,0},
205 {0x94,0x95,0x96,0x97,0},
206 {0x9C,0x9D,0x9E,0x9F,0},
207 {0x05,0x06,0x07,0x08,0},
208 {0xA4,0xA5,0xA6,0xA7,0},
209 {0xAC,0xAD,0xAE,0xAF,0},
210 {0xB4,0xB5,0xB6,0xB7,0},
211 {0xBC,0xBD,0xBE,0xBF,0},
212 {0x25,0x26,0x27,0x28,0},
213 {0xC4,0xC5,0xC6,0xC7,0},
214 {0xCC,0xCD,0xCE,0xCF,0},
215 {0xD4,0xD5,0xD6,0xD7,0},
216 {0xDC,0xDD,0xDE,0xDF,0},
217 {0x45,0x46,0x47,0x48,0},
218 {0xE4,0xE5,0xE6,0xE7,0},
219 {0xEC,0xED,0xEE,0xEF,0},
220 {0xF4,0xF5,0xF6,0xF7,0},
221 {0xFC,0xFD,0xFE,0xFF,0},
222 {0x65,0x66,0x67,0x68,0}
223 }
224 };
225
226 int rown = 0;
227 int rowc = 0;
228 int rowl = 0;
229 int rowr = 0;
230 int rowa = 0;
231
232 //Set Indicator icon
233 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; }
234 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; }
235 if (layer_state == L_LOWER) { rowl = 1; }
236 if (layer_state == L_RAISE) { rowr = 1; }
237 if (layer_state == L_ADJUST) { rowa = 1; }
238
239 matrix_write(matrix, indctr[rowl] [0]);
240 matrix_write(matrix, indctr[rowr] [1]);
241 matrix_write(matrix, indctr[rowa] [2]);
242 matrix_write(matrix, indctr[rowc] [3]);
243 matrix_write(matrix, indctr[rown] [4]);
244 matrix_write_char(matrix, 0x13);
245 matrix_write(matrix, indctr[rowl] [5]);
246 matrix_write(matrix, indctr[rowr] [6]);
247 matrix_write(matrix, indctr[rowa] [7]);
248 matrix_write(matrix, indctr[rowc] [8]);
249 matrix_write(matrix, indctr[rown] [9]);
250 matrix_write_char(matrix, 0x13);
251 matrix_write(matrix, indctr[rowl] [10]);
252 matrix_write(matrix, indctr[rowr] [11]);
253 matrix_write(matrix, indctr[rowa] [12]);
254 matrix_write(matrix, indctr[rowc] [13]);
255 matrix_write(matrix, indctr[rown] [14]);
256 matrix_write_char(matrix, 0x13);
257 matrix_write(matrix, indctr[rowl] [15]);
258 matrix_write(matrix, indctr[rowr] [16]);
259 matrix_write(matrix, indctr[rowa] [17]);
260 matrix_write(matrix, indctr[rowc] [18]);
261 matrix_write(matrix, indctr[rown] [19]);
262
263 }else{
264 matrix_write(matrix, read_logo());
265 }
266}
267
268void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
269 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
270 memcpy(dest->display, source->display, sizeof(dest->display));
271 dest->dirty = true;
272 }
273}
274
275void iota_gfx_task_user(void) {
276 struct CharacterMatrix matrix;
277 matrix_clear(&matrix);
278 matrix_render_user(&matrix);
279 matrix_update(&display, &matrix);
280}
281#endif//SSD1306OLED
282
283bool process_record_user(uint16_t keycode, keyrecord_t *record) {
284 switch (keycode) {
285 case QWERTY:
286 if (record->event.pressed) {
287 persistent_default_layer_set(1UL<<_QWERTY);
288 }
289 return false;
290 break;
291 case LOWER:
292 if (record->event.pressed) {
293 layer_on(_LOWER);
294 } else {
295 layer_off(_LOWER);
296 }
297 return false;
298 break;
299 case RAISE:
300 if (record->event.pressed) {
301 layer_on(_RAISE);
302 } else {
303 layer_off(_RAISE);
304 }
305 return false;
306 break;
307 case ADJUST:
308 if (record->event.pressed) {
309 layer_on(_ADJUST);
310 } else {
311 layer_off(_ADJUST);
312 }
313 return false;
314 break;
315 case RGB_MOD:
316 #ifdef RGBLIGHT_ENABLE
317 if (record->event.pressed) {
318 rgblight_mode(RGB_current_mode);
319 rgblight_step();
320 RGB_current_mode = rgblight_config.mode;
321 }
322 #endif
323 return false;
324 break;
325 case RGBRST:
326 #ifdef RGBLIGHT_ENABLE
327 if (record->event.pressed) {
328 eeconfig_update_rgblight_default();
329 rgblight_enable();
330 RGB_current_mode = rgblight_config.mode;
331 }
332 #endif
333 break;
334 }
335 return true;
336}
337