aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryhaliaw <43424755+yhaliaw@users.noreply.github.com>2021-03-15 04:19:05 +0800
committerGitHub <noreply@github.com>2021-03-14 13:19:05 -0700
commitb44bffe954dca574bf6ef16b8c8d985e9547d3e1 (patch)
tree1dab8b29b3ff07bcad63ad59bfb6f78c25c21657
parent739925c902488e39cced8f8ef03c77ef6cfee751 (diff)
downloadqmk_firmware-b44bffe954dca574bf6ef16b8c8d985e9547d3e1.tar.gz
qmk_firmware-b44bffe954dca574bf6ef16b8c8d985e9547d3e1.zip
[Keymap] Add yhaliaw keymap for Planck/Rev6.1. (#11318)
-rw-r--r--keyboards/planck/keymaps/yhaliaw/config.h29
-rw-r--r--keyboards/planck/keymaps/yhaliaw/keymap.c221
-rw-r--r--keyboards/planck/keymaps/yhaliaw/readme.md32
-rw-r--r--keyboards/planck/keymaps/yhaliaw/rules.mk5
-rw-r--r--keyboards/preonic/keymaps/yhaliaw/config.h12
-rw-r--r--keyboards/preonic/keymaps/yhaliaw/keymap.c231
-rw-r--r--keyboards/preonic/keymaps/yhaliaw/rules.mk4
7 files changed, 534 insertions, 0 deletions
diff --git a/keyboards/planck/keymaps/yhaliaw/config.h b/keyboards/planck/keymaps/yhaliaw/config.h
new file mode 100644
index 000000000..ac241b8a6
--- /dev/null
+++ b/keyboards/planck/keymaps/yhaliaw/config.h
@@ -0,0 +1,29 @@
1/* Copyright 2020 Andrew Liaw
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#ifdef AUDIO_ENABLE
20#define STARTUP_SONG SONG(PLANCK_SOUND)
21#endif
22
23#define RGBLIGHT_LAYERS
24#define RGBLIGHT_LED_MAP {8, 2, 3, 7, 6, 5, 4, 0, 1}
25
26#define MK_COMBINED
27
28#define LEADER_TIMEOUT 200
29#define LEADER_PER_KEY_TIMING
diff --git a/keyboards/planck/keymaps/yhaliaw/keymap.c b/keyboards/planck/keymaps/yhaliaw/keymap.c
new file mode 100644
index 000000000..8b7851cee
--- /dev/null
+++ b/keyboards/planck/keymaps/yhaliaw/keymap.c
@@ -0,0 +1,221 @@
1/* Copyright 2020 Andrew Liaw
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include QMK_KEYBOARD_H
18
19enum planck_layers {
20 _BASE,
21 _LOWER,
22 _RAISE,
23 _ADJUST,
24};
25
26enum planck_keycodes {
27 L_RESET = SAFE_RANGE,
28};
29
30#ifdef AUDIO_ENABLE
31float planck_sound[][2] = SONG(PLANCK_SOUND);
32#endif
33
34#define LOWER MO(_LOWER)
35#define RAISE MO(_RAISE)
36
37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
38 /* Base
39 * ,-----------------------------------------------------------------------------------.
40 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
41 * |------+------+------+------+------+------+------+------+------+------+------+------|
42 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
43 * |------+------+------+------+------+------+------+------+------+------+------+------|
44 * | Shift| Z | X | C | V | B | N | M | , | . | / | Shift|
45 * |------+------+------+------+------+------+------+------+------+------+------+------|
46 * |Leader| Ctrl | Alt | GUI | Lower| Enter| Space| Raise| GUI | Alt | Ctrl | Del |
47 * `-----------------------------------------------------------------------------------'
48 */
49 [_BASE] = LAYOUT_planck_grid(
50 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
51 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
52 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
53 KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_ENT, KC_SPC, RAISE, KC_RGUI, KC_RALT, KC_RCTL, KC_DEL
54 ),
55
56 /* Lower
57 * ,-----------------------------------------------------------------------------------.
58 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
59 * |------+------+------+------+------+-------------+------+------+------+------+------|
60 * | Caps | | | | | | Left | Down | Up | Right| | \ |
61 * |------+------+------+------+------+------|------+------+------+------+------+------|
62 * | | | | | | | | Home | End | Pg Up| Pg Dn| |
63 * |------+------+------+------+------+------+------+------+------+------+------+------|
64 * | | | | | | | | | | | | |
65 * `-----------------------------------------------------------------------------------'
66 */
67 [_LOWER] = LAYOUT_planck_grid(
68 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
69 KC_CAPS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, XXXXXXX, KC_BSLS,
70 _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_END, KC_PGUP, KC_PGDN, _______,
71 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
72 ),
73
74 /* Raise
75 * ,-----------------------------------------------------------------------------------.
76 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | |
77 * |------+------+------+------+------+-------------+------+------+------+------+------|
78 * | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | | |
79 * |------+------+------+------+------+------|------+------+------+------+------+------|
80 * | | F7 | F8 | F9 | F10 | F11 | F12 | _ | + | { | } | |
81 * |------+------+------+------+------+------+------+------+------+------+------+------|
82 * | | | | | | | | | | | | |
83 * `-----------------------------------------------------------------------------------'
84 */
85 [_RAISE] = LAYOUT_planck_grid(
86 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
87 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_PIPE,
88 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______,
89 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
90 ),
91
92
93 /* Adjust (Lower + Raise)
94 * ,-----------------------------------------------------------------------------------.
95 * | | Reset| Debug| Clear| RGB | HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| |
96 * |------+------+------+------+------+------+------+------+------+------+------+------|
97 * | | | |Aud on|Audoff| Swap | Norm | | | | | |
98 * |------+------+------+------+------+------+------+------+------+------+------+------|
99 * | | | |Mus on|Musoff| NKRO | 6KRO | | | | | |
100 * |------+------+------+------+------+------+------+------+------+------+------+------|
101 * | | | | | | | | | | | | |
102 * `-----------------------------------------------------------------------------------'
103 */
104 [_ADJUST] = LAYOUT_planck_grid(
105 _______, L_RESET, DEBUG, EEP_RST, RGB_TOG, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______,
106 _______, XXXXXXX, XXXXXXX, AU_ON, AU_OFF, AG_SWAP, AG_NORM, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
107 _______, XXXXXXX, XXXXXXX, MU_ON, MU_OFF, NK_ON, NK_OFF, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
108 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
109 )
110};
111
112const rgblight_segment_t PROGMEM base_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 9, 0, 0, 0});
113
114const rgblight_segment_t PROGMEM lower_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_RED});
115
116const rgblight_segment_t PROGMEM raise_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_GREEN});
117
118const rgblight_segment_t PROGMEM adjust_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_BLUE});
119
120const rgblight_segment_t PROGMEM capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS({4, 5, HSV_WHITE});
121
122// Later layers take precedence.
123const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
124 base_layer,
125 lower_layer,
126 raise_layer,
127 adjust_layer,
128 capslock_layer
129);
130
131bool audio_disable = false;
132
133void keyboard_pre_init_user(void) {
134 // If the audio is off during hardware init,
135 // it causes problem when the audio is turn on later.
136 // The workaround is to always set the audio on during hardware init,
137 // then toggle audio back to the setting.
138#ifdef AUDIO_ENABLE
139 if (!is_audio_on()) {
140 audio_disable = true;
141 audio_on();
142 }
143#endif
144}
145
146void matrix_init_user(void) {
147 // To fix a audio related problem. See comments in keyboard_pre_init_user().
148#ifdef AUDIO_ENABLE
149 if (audio_disable) {
150 audio_off();
151 }
152#endif
153}
154
155void keyboard_post_init_user(void) {
156 rgblight_layers = rgb_layers;
157 rgblight_set_layer_state(0, true);
158}
159
160bool leader_found;
161LEADER_EXTERNS();
162
163void matrix_scan_user(void) {
164 LEADER_DICTIONARY() {
165 leading = false;
166 leader_found = false;
167 SEQ_ONE_KEY(L_RESET) {
168 leader_found = true;
169 reset_keyboard();
170 }
171 else
172 SEQ_ONE_KEY(KC_DEL) {
173 leader_found = true;
174 layer_clear();
175 }
176 else
177 SEQ_ONE_KEY(LOWER) {
178 leader_found = true;
179 layer_on(_LOWER);
180 }
181 else
182 SEQ_ONE_KEY(RAISE) {
183 leader_found = true;
184 layer_on(_RAISE);
185 }
186 leader_end();
187 }
188}
189
190void leader_end(void) {
191 // Plays sound on if leader sequence found.
192 if (leader_found) {
193#ifdef AUDIO_ENABLE
194 PLAY_SONG(planck_sound);
195#endif
196 }
197}
198
199bool led_update_user(led_t led_state) {
200 // Turn on RBG for capslock.
201 rgblight_set_layer_state(4, led_state.caps_lock);
202 return true;
203}
204
205layer_state_t layer_state_set_user(layer_state_t state) {
206 // Set RBG layer according to active keymap layer.
207 rgblight_set_layer_state(1, layer_state_cmp(state, 1));
208 rgblight_set_layer_state(2, layer_state_cmp(state, 2));
209 rgblight_set_layer_state(3, layer_state_cmp(state, 1) && layer_state_cmp(state, 2));
210 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
211}
212
213bool music_mask_user(uint16_t keycode) {
214 switch (keycode) {
215 case RAISE:
216 case LOWER:
217 return false;
218 default:
219 return true;
220 }
221}
diff --git a/keyboards/planck/keymaps/yhaliaw/readme.md b/keyboards/planck/keymaps/yhaliaw/readme.md
new file mode 100644
index 000000000..a10e54bd9
--- /dev/null
+++ b/keyboards/planck/keymaps/yhaliaw/readme.md
@@ -0,0 +1,32 @@
1# yhaliaw Planck layout
2
3The layout for Planck by yhaliaw.
4
5Developed and tested on Planck Rev 6.1.
6
7## Features
8
9Leader sequences can be used to turn on layers without holding the key and reset the layers.
10Leader sequences are triggered by key the series of key in quick succession.
11See Base layer notes in Layout section.
12
13Successful leader sequences will play the planck sound if sound is enabled.
14
15The RGB underglow is linked to the layers and capslock.
16
17## Keycodes
18
19Most Keycodes are standard [QMK keycodes](https://docs.qmk.fm/#/keycodes).
20
21### Custom Keycodes
22
23The `RESET` key to start the bootloader is access by a leader sequence.
24This is done to prevent a mispress.
25See Adjust layer notes in Layout section.
26
27The `Clear` key is used to clear the EEPROM of the keyboard.
28This can be seen as resetting the state of the keyboard.
29Replug the keyboard to load in the resetted states.
30
31## Layout
32![yhaliaw planck layout](https://i.imgur.com/HvYva64.png) \ No newline at end of file
diff --git a/keyboards/planck/keymaps/yhaliaw/rules.mk b/keyboards/planck/keymaps/yhaliaw/rules.mk
new file mode 100644
index 000000000..2c8510c3e
--- /dev/null
+++ b/keyboards/planck/keymaps/yhaliaw/rules.mk
@@ -0,0 +1,5 @@
1LEADER_ENABLE = yes
2
3RGBLIGHT_ENABLE = yes
4ENCODER_ENABLE = no
5DIP_SWITCH_ENABLE = no
diff --git a/keyboards/preonic/keymaps/yhaliaw/config.h b/keyboards/preonic/keymaps/yhaliaw/config.h
new file mode 100644
index 000000000..84ec6e1af
--- /dev/null
+++ b/keyboards/preonic/keymaps/yhaliaw/config.h
@@ -0,0 +1,12 @@
1
2#pragma once
3
4#ifdef AUDIO_ENABLE
5#define STARTUP_SONG SONG(PLANCK_SOUND)
6#endif
7
8#define RGBLIGHT_LAYERS
9#define RGBLIGHT_LED_MAP {8, 2, 3, 7, 6, 5, 4, 0, 1}
10
11#define LEADER_TIMEOUT 200
12#define LEADER_PER_KEY_TIMING
diff --git a/keyboards/preonic/keymaps/yhaliaw/keymap.c b/keyboards/preonic/keymaps/yhaliaw/keymap.c
new file mode 100644
index 000000000..252806189
--- /dev/null
+++ b/keyboards/preonic/keymaps/yhaliaw/keymap.c
@@ -0,0 +1,231 @@
1/* Copyright 2021 Andrew Liaw
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include QMK_KEYBOARD_H
17
18enum preonic_layers {
19 _BASE,
20 _LOWER,
21 _RAISE,
22 _ADJUST,
23};
24
25enum preonic_keycodes {
26 L_RESET = SAFE_RANGE,
27};
28
29#ifdef AUDIO_ENABLE
30float planck_sound[][2] = SONG(PLANCK_SOUND);
31#endif
32
33#define LOWER MO(_LOWER)
34#define RAISE MO(_RAISE)
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37 /* Base
38 * ,-----------------------------------------------------------------------------------.
39 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del |
40 * |------+------+------+------+------+------+------+------+------+------+------+------|
41 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
42 * |------+------+------+------+------+-------------+------+------+------+------+------|
43 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
44 * |------+------+------+------+------+------|------+------+------+------+------+------|
45 * | Shift| Z | X | C | V | B | N | M | , | . | / | Shift|
46 * |------+------+------+------+------+------+------+------+------+------+------+------|
47 * |Leader| Ctrl | Alt | GUI | Lower| Enter| Space| Raise| GUI | Alt | Ctrl | Del |
48 * `-----------------------------------------------------------------------------------'
49 */
50 [_BASE] = LAYOUT_preonic_grid(
51 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
52 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
53 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
54 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
55 KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_ENT, KC_SPC, RAISE, KC_RGUI, KC_RALT, KC_RCTL, KC_DEL
56 ),
57
58 /* Lower
59 * ,-----------------------------------------------------------------------------------.
60 * | | | | | | | | | | | | |
61 * |------+------+------+------+------+-------------+------+------+------+------+------|
62 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
63 * |------+------+------+------+------+-------------+------+------+------+------+------|
64 * | Caps | | | | | | Left | Down | Up | Right| | \ |
65 * |------+------+------+------+------+------|------+------+------+------+------+------|
66 * | | | | | | | | Home | End | Pg Up| Pg Dn| |
67 * |------+------+------+------+------+------+------+------+------+------+------+------|
68 * | | | | | | | | | | | | |
69 * `-----------------------------------------------------------------------------------'
70 */
71 [_LOWER] = LAYOUT_preonic_grid(
72 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
73 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
74 KC_CAPS, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, XXXXXXX, KC_BSLS,
75 _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_END, KC_PGUP, KC_PGDN, _______,
76 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
77 ),
78
79 /* Raise
80 * ,-----------------------------------------------------------------------------------.
81 * | | | | | | | | | | | | |
82 * |------+------+------+------+------+------+------+------+------+------+------+------|
83 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | |
84 * |------+------+------+------+------+-------------+------+------+------+------+------|
85 * | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | | |
86 * |------+------+------+------+------+------|------+------+------+------+------+------|
87 * | | F7 | F8 | F9 | F10 | F11 | F12 | _ | + | { | } | |
88 * |------+------+------+------+------+------+------+------+------+------+------+------|
89 * | | | | | | | | Next | Vol- | Vol+ | Play |
90 * `-----------------------------------------------------------------------------------'
91 */
92 [_RAISE] = LAYOUT_preonic_grid(
93 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
94 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
95 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_PIPE,
96 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______,
97 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
98 ),
99
100 /* Adjust (Lower + Raise)
101 * ,-----------------------------------------------------------------------------------.
102 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
103 * |------+------+------+------+------+------+------+------+------+------+------+------|
104 * | | Reset| Debug| Clear| RGB | HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| |
105 * |------+------+------+------+------+------+------+------+------+------+------+------|
106 * | | | |Aud on|Audoff| Swap | Norm | | | | | |
107 * |------+------+------+------+------+------+------+------+------+------+------+------|
108 * | | | |Mus on|Musoff| NKRO | 6KRO | | | | | |
109 * |------+------+------+------+------+------+------+------+------+------+------+------|
110 * | | | | | | | | | | | | |
111 * `-----------------------------------------------------------------------------------'
112 */
113 [_ADJUST] = LAYOUT_preonic_grid(
114 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
115 _______, L_RESET, DEBUG, EEP_RST, RGB_TOG, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______,
116 _______, XXXXXXX, XXXXXXX, AU_ON, AU_OFF, AG_SWAP, AG_NORM, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
117 _______, XXXXXXX, XXXXXXX, MU_ON, MU_OFF, NK_ON, NK_OFF, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______,
118 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
119 )
120};
121
122const rgblight_segment_t PROGMEM base_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 9, 0, 0, 0});
123
124const rgblight_segment_t PROGMEM lower_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_RED});
125
126const rgblight_segment_t PROGMEM raise_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_GREEN});
127
128const rgblight_segment_t PROGMEM adjust_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 8, HSV_BLUE});
129
130const rgblight_segment_t PROGMEM capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS({4, 5, HSV_WHITE});
131
132// Later layers take precedence.
133const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
134 base_layer,
135 lower_layer,
136 raise_layer,
137 adjust_layer,
138 capslock_layer
139);
140
141bool audio_disable = false;
142
143void keyboard_pre_init_user(void) {
144 // If the audio is off during hardware init,
145 // it causes problem when the audio is turn on later.
146 // The workaround is to always set the audio on during hardware init,
147 // then toggle audio back to the setting.
148#ifdef AUDIO_ENABLE
149 if (!is_audio_on()) {
150 audio_disable = true;
151 audio_on();
152 }
153#endif
154}
155
156void matrix_init_user(void) {
157 // To fix a audio related problem. See comments in keyboard_pre_init_user().
158#ifdef AUDIO_ENABLE
159 if (audio_disable) {
160 audio_off();
161 }
162#endif
163}
164
165void keyboard_post_init_user(void) {
166 rgblight_layers = rgb_layers;
167 rgblight_set_layer_state(0, true);
168}
169
170bool leader_found;
171LEADER_EXTERNS();
172
173void matrix_scan_user(void) {
174 LEADER_DICTIONARY() {
175 leading = false;
176 leader_found = false;
177 SEQ_ONE_KEY(L_RESET) {
178 leader_found = true;
179 reset_keyboard();
180 }
181 else
182 SEQ_ONE_KEY(KC_DEL) {
183 leader_found = true;
184 layer_clear();
185 }
186 else
187 SEQ_ONE_KEY(LOWER) {
188 leader_found = true;
189 layer_on(_LOWER);
190 }
191 else
192 SEQ_ONE_KEY(RAISE) {
193 leader_found = true;
194 layer_on(_RAISE);
195 }
196 leader_end();
197 }
198}
199
200void leader_end(void) {
201 // Plays sound on if leader sequence found.
202 if (leader_found) {
203#ifdef AUDIO_ENABLE
204 PLAY_SONG(planck_sound);
205#endif
206 }
207}
208
209bool led_update_user(led_t led_state) {
210 // Turn on RBG for capslock.
211 rgblight_set_layer_state(4, led_state.caps_lock);
212 return true;
213}
214
215layer_state_t layer_state_set_user(layer_state_t state) {
216 // Set RBG layer according to active keymap layer.
217 rgblight_set_layer_state(1, layer_state_cmp(state, 1));
218 rgblight_set_layer_state(2, layer_state_cmp(state, 2));
219 rgblight_set_layer_state(3, layer_state_cmp(state, 1) && layer_state_cmp(state, 2));
220 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
221}
222
223bool music_mask_user(uint16_t keycode) {
224 switch (keycode) {
225 case RAISE:
226 case LOWER:
227 return false;
228 default:
229 return true;
230 }
231}
diff --git a/keyboards/preonic/keymaps/yhaliaw/rules.mk b/keyboards/preonic/keymaps/yhaliaw/rules.mk
new file mode 100644
index 000000000..8762502b5
--- /dev/null
+++ b/keyboards/preonic/keymaps/yhaliaw/rules.mk
@@ -0,0 +1,4 @@
1LEADER_ENABLE = yes
2
3ENCODER_ENABLE = no
4DIP_SWITCH_ENABLE = no