aboutsummaryrefslogtreecommitdiff
path: root/keyboards/chidori/keymaps/oled_sample/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/chidori/keymaps/oled_sample/keymap.c')
-rw-r--r--keyboards/chidori/keymaps/oled_sample/keymap.c218
1 files changed, 218 insertions, 0 deletions
diff --git a/keyboards/chidori/keymaps/oled_sample/keymap.c b/keyboards/chidori/keymaps/oled_sample/keymap.c
new file mode 100644
index 000000000..78107a18e
--- /dev/null
+++ b/keyboards/chidori/keymaps/oled_sample/keymap.c
@@ -0,0 +1,218 @@
1/* Copyright 2019 ENDO Katsuhiro <[email protected]>
2 * Copyright 2020 Masaya Uno
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include QMK_KEYBOARD_H
18
19#include "board.h"
20
21enum layer_number {
22 _QWERTY,
23 _COLEMAK,
24 _DVORAK,
25 _LOWER,
26 _RAISE,
27 _ADJUST,
28};
29
30// Defines the keycodes used by our macros in process_record_user
31enum custom_keycodes {
32 QWERTY = SAFE_RANGE,
33 COLEMAK,
34 DVORAK,
35};
36
37#define LOWER MO(_LOWER)
38#define RAISE MO(_RAISE)
39#define ADJUST MO(_ADJUST)
40
41// clang-format off
42const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
43 /* Qwerty
44 * ,-----------------------------------------. ,-----------------------------------------.
45 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
46 * |------+------+------+------+------+------| |------+------+------+------+------+------|
47 * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
48 * |------+------+------+------+------+------| |------+------+------+------+------+------|
49 * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
50 * |------+------+------+------+------+------| |------+------+------+------+------+------|
51 * |ADJUST| Esc | Alt | GUI |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
52 * `-----------------------------------------' `-----------------------------------------'
53 */
54 [_QWERTY] = LAYOUT(
55 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
56 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
57 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
58 ADJUST, KC_ESC, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
59 ),
60 /* Colemak
61 * ,-----------------------------------------. ,-----------------------------------------.
62 * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
63 * |------+------+------+------+------+------| |------+------+------+------+------+------|
64 * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
65 * |------+------+------+------+------+------| |------+------+------+------+------+------|
66 * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter |
67 * |------+------+------+------+------+------| |------+------+------+------+------+------|
68 * |ADJUST| Esc | Alt | GUI |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
69 * `-----------------------------------------' `-----------------------------------------'
70 */
71 [_COLEMAK] = LAYOUT(
72 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
73 KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT,
74 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
75 ADJUST, KC_ESC, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
76 ),
77
78 /* Dvorak
79 * ,-----------------------------------------. ,-----------------------------------------.
80 * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Bksp |
81 * |------+------+------+------+------+------| |------+------+------+------+------+------|
82 * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
83 * |------+------+------+------+------+------| |------+------+------+------+------+------|
84 * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter |
85 * |------+------+------+------+------+------| |------+------+------+------+------+------|
86 * |ADJUST| Esc | Alt | GUI |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
87 * `-----------------------------------------' `-----------------------------------------'
88 */
89 [_DVORAK] = LAYOUT(
90 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC,
91 KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH,
92 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT,
93 ADJUST, KC_ESC, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
94 ),
95
96 /* Lower
97 * ,-----------------------------------------. ,-----------------------------------------.
98 * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
99 * |------+------+------+------+------+------| |------+------+------+------+------+------|
100 * | | | | | | | | - | _ | + | { | } | | |
101 * |------+------+------+------+------+------| |------+------+------+------+------+------|
102 * | | | | | | | | | | | Home | End | |
103 * |------+------+------+------+------+------| |------+------+------+------+------+------|
104 * | | | | | | | | | | Next | Vol- | Vol+ | Play |
105 * `-----------------------------------------' `-----------------------------------------'
106 */
107 [_LOWER] = LAYOUT(
108 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
109 _______, _______, _______, _______, _______, _______, KC_MINS, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
110 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, _______,
111 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
112 ),
113
114 /* Raise
115 * ,-----------------------------------------. ,-----------------------------------------.
116 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
117 * |------+------+------+------+------+------| |------+------+------+------+------+------|
118 * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
119 * |------+------+------+------+------+------| |------+------+------+------+------+------|
120 * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | |
121 * |------+------+------+------+------+------| |------+------+------+------+------+------|
122 * | | | | | | | | | | Next | Vol- | Vol+ | Play |
123 * `-----------------------------------------' `-----------------------------------------'
124 */
125 [_RAISE] = LAYOUT(
126 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
127 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
128 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______,
129 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
130 ),
131
132 /* Adjust (Lower + Raise)
133 * ,-----------------------------------------. ,-----------------------------------------.
134 * | | Reset| | | | | | |Qwerty|Colemk|Dvorak| | Ins |
135 * |------+------+------+------+------+------| |------+------+------+------+------+------|
136 * | Caps | | | | | Mac | | Win | - | = |Print |ScLock|Pause |
137 * |------+------+------+------+------+------| |------+------+------+------+------+------|
138 * | | | | | | | | | | | | | |
139 * |------+------+------+------+------+------| |------+------+------+------+------+------|
140 * | | | | | | | | KANA | | Home |PageDn|PageUp| End |
141 * `-----------------------------------------' `-----------------------------------------'
142 */
143 [_ADJUST] = LAYOUT(
144 _______, RESET, _______, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, KC_INS,
145 KC_CAPS, _______, _______, _______, _______, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SLCK, KC_PAUS,
146 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
147 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
148 )
149};
150// clang-format on
151
152layer_state_t layer_state_set_user(layer_state_t state) {
153 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
154}
155
156bool process_record_user(uint16_t keycode, keyrecord_t *record) {
157 switch (keycode) {
158 case QWERTY:
159 if (record->event.pressed) {
160 set_single_persistent_default_layer(_QWERTY);
161 }
162 return false;
163 case COLEMAK:
164 if (record->event.pressed) {
165 set_single_persistent_default_layer(_COLEMAK);
166 }
167 return false;
168 case DVORAK:
169 if (record->event.pressed) {
170 set_single_persistent_default_layer(_DVORAK);
171 }
172 return false;
173 }
174 return true;
175}
176
177bool led_update_user(led_t led_state) {
178 board_set_led_by_index(0, LED_YELLOW, led_state.caps_lock);
179 board_set_led_by_index(1, LED_YELLOW, led_state.scroll_lock);
180
181 return false;
182}
183
184#ifdef OLED_ENABLE
185
186void oled_write_layer_state(void) {
187 oled_write_P(PSTR("Layer: "), false);
188 switch (get_highest_layer(layer_state | default_layer_state)) {
189 case _QWERTY:
190 oled_write_ln_P(PSTR("Qwerty"), false);
191 break;
192 case _COLEMAK:
193 oled_write_ln_P(PSTR("Colemak"), false);
194 break;
195 case _DVORAK:
196 oled_write_ln_P(PSTR("Dvorak"), false);
197 break;
198 case _LOWER:
199 oled_write_ln_P(PSTR("Lower"), false);
200 break;
201 case _RAISE:
202 oled_write_ln_P(PSTR("Raise"), false);
203 break;
204 case _ADJUST:
205 oled_write_ln_P(PSTR("Adjust"), false);
206 break;
207 default:
208 oled_write_ln_P(PSTR("Undef"), false);
209 break;
210 }
211}
212
213bool oled_task_user(void) {
214 // If you want to change the display of OLED, you need to change here
215 oled_write_layer_state();
216 return false;
217}
218#endif