aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Gehrig <romain.gehrig@gmail.com>2019-10-20 20:20:01 +0200
committerDrashna Jaelre <drashna@live.com>2019-10-20 11:20:01 -0700
commita4c008fe90940169abb653eb17558be205a645a9 (patch)
tree0205ec85434a9f7b4baa43aea463c0ac1a4ee40b
parent4c90277236395e076afa57bb11b83c80fdbf381e (diff)
downloadqmk_firmware-a4c008fe90940169abb653eb17558be205a645a9.tar.gz
qmk_firmware-a4c008fe90940169abb653eb17558be205a645a9.zip
[Keymap] Romain's Preonic layout (#7067)
* Add customized preonic layout * Add a README detailing a bit the differences from the default preonic layout * Apply suggestions from code review Co-Authored-By: fauxpark <fauxpark@gmail.com> * Remove unnecessary end-of-line backslashes * Import fix for startup sound (thanks @drashna) * Remove unnecessary layers and keycodes * Bring back the _QWERTY layer code Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>
-rw-r--r--keyboards/preonic/keymaps/cranium/config.h38
-rw-r--r--keyboards/preonic/keymaps/cranium/keymap.c224
-rw-r--r--keyboards/preonic/keymaps/cranium/readme.md72
-rw-r--r--keyboards/preonic/keymaps/cranium/rules.mk1
4 files changed, 335 insertions, 0 deletions
diff --git a/keyboards/preonic/keymaps/cranium/config.h b/keyboards/preonic/keymaps/cranium/config.h
new file mode 100644
index 000000000..6d73958ad
--- /dev/null
+++ b/keyboards/preonic/keymaps/cranium/config.h
@@ -0,0 +1,38 @@
1#pragma once
2
3
4#ifdef AUDIO_ENABLE
5 #define STARTUP_SONG SONG(PREONIC_SOUND)
6 // #define STARTUP_SONG SONG(NO_SOUND)
7
8 #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
9 SONG(COLEMAK_SOUND), \
10 SONG(DVORAK_SOUND) \
11 }
12#endif
13
14#define MUSIC_MASK (keycode != KC_NO)
15
16/*
17 * MIDI options
18 */
19
20/* Prevent use of disabled MIDI features in the keymap */
21//#define MIDI_ENABLE_STRICT 1
22
23/* enable basic MIDI features:
24 - MIDI notes can be sent when in Music mode is on
25*/
26
27#define MIDI_BASIC
28
29/* enable advanced MIDI features:
30 - MIDI notes can be added to the keymap
31 - Octave shift and transpose
32 - Virtual sustain, portamento, and modulation wheel
33 - etc.
34*/
35//#define MIDI_ADVANCED
36
37/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
38//#define MIDI_TONE_KEYCODE_OCTAVES 2
diff --git a/keyboards/preonic/keymaps/cranium/keymap.c b/keyboards/preonic/keymaps/cranium/keymap.c
new file mode 100644
index 000000000..d640ff849
--- /dev/null
+++ b/keyboards/preonic/keymaps/cranium/keymap.c
@@ -0,0 +1,224 @@
1/* Copyright 2015-2017 Jack Humbert
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#include "muse.h"
19
20enum preonic_layers {
21 _QWERTY,
22 _LOWER,
23 _RAISE,
24 _ADJUST
25};
26
27enum preonic_keycodes {
28 LOWER = SAFE_RANGE,
29 RAISE,
30};
31
32const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
33
34/* Qwerty (base layer)
35 * ,-----------------------------------------------------------------------------------.
36 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Esc |
37 * |------+------+------+------+------+------+------+------+------+------+------+------|
38 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Esc |
39 * |------+------+------+------+------+-------------+------+------+------+------+------|
40 * | Bksp | A | S | D | F | G | H | J | K | L | ; | " |
41 * |------+------+------+------+------+------|------+------+------+------+------+------|
42 * | Shift| Z | X | C | V | B | N | M | , | . | / | | |
43 * |------+------+------+------+------+------+------+------+------+------+------+------|
44 * | Ctrl | F12 | GUI | Alt |Lower | Space |Raise |AltGr | [ | ] |Enter |
45 * `-----------------------------------------------------------------------------------'
46 */
47[_QWERTY] = LAYOUT_preonic_grid(
48 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_ESC,
49 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_ESC,
50 KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
51 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS,
52 KC_LCTL, KC_F12, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_SPC, RAISE, KC_RALT, KC_LBRC, KC_RBRC, KC_ENT
53),
54
55/* Lower
56 * ,-----------------------------------------------------------------------------------.
57 * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 |
58 * |------+------+------+------+------+-------------+------+------+------+------+------|
59 * | | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del |
60 * |------+------+------+------+------+-------------+------+------+------+------+------|
61 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | + | = | | |
62 * |------+------+------+------+------+------|------+------+------+------+------+------|
63 * | LGUI | F7 | F8 | F9 | F10 | F11 | F12 | 1 | 2 | 3 | 4 | |
64 * |------+------+------+------+------+------+------+------+------+------+------+------|
65 * | | | | | | _ | | | | | |
66 * `-----------------------------------------------------------------------------------'
67 */
68[_LOWER] = LAYOUT_preonic_grid(
69 KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
70 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
71 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_PLUS, KC_EQL, _______, _______,
72 KC_LGUI, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_1, KC_2, KC_3, KC_4, _______,
73 _______, _______, _______, _______, _______, KC_UNDS, KC_UNDS, _______, _______, _______, _______, _______
74),
75
76/* Raise
77 * ,-----------------------------------------------------------------------------------.
78 * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
79 * |------+------+------+------+------+------+------+------+------+------+------+------|
80 * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
81 * |------+------+------+------+------+-------------+------+------+------+------+------|
82 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | Up | Down | Left |Right | |
83 * |------+------+------+------+------+------|------+------+------+------+------+------|
84 * | | F7 | F8 | F9 | F10 | F11 | F12 | Home | End | | | Shift|
85 * |------+------+------+------+------+------+------+------+------+------+------+------|
86 * | | | | | | _ | | | | | |
87 * `-----------------------------------------------------------------------------------'
88 */
89[_RAISE] = LAYOUT_preonic_grid(
90 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
91 _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
92 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UP, KC_DOWN, KC_LEFT, KC_RIGHT,_______,
93 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_END, _______, _______, KC_RSFT,
94 _______, _______, _______, _______, _______, KC_UNDS, KC_UNDS, _______, _______, _______, _______, _______
95),
96
97/* Adjust (Lower + Raise)
98 * ,-----------------------------------------------------------------------------------.
99 * | | | | | | | | | | | | Sleep|
100 * |------+------+------+------+------+------+------+------+------+------+------+------|
101 * | | Reset| Debug| | | | | | | | | |
102 * |------+------+------+------+------+-------------+------+------+------+------+------|
103 * | | | |Aud on|AudOff|AGnorm|AGswap| Vol+ | Vol- | Prev | Next | |
104 * |------+------+------+------+------+------|------+------+------+------+------+------|
105 * | |Voice-|Voice+|Mus on|MusOff|MidiOn|MidOff| | | | | |
106 * |------+------+------+------+------+------+------+------+------+------+------+------|
107 * | | | | | | Play | | | | | PrScr|
108 * `-----------------------------------------------------------------------------------'
109 */
110[_ADJUST] = LAYOUT_preonic_grid(
111 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_SLEP,
112 _______, RESET, DEBUG, _______, _______, _______, _______, TERM_ON, TERM_OFF,_______, _______, _______,
113 _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, KC_VOLU, KC_VOLD, KC_MPRV, KC_MNXT, _______,
114 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______,
115 _______, _______, _______, _______, _______, KC_MPLY, KC_MPLY, _______, _______, _______, _______, KC_PSCR
116)
117
118
119};
120
121bool process_record_user(uint16_t keycode, keyrecord_t *record) {
122 switch (keycode) {
123 case LOWER:
124 if (record->event.pressed) {
125 layer_on(_LOWER);
126 update_tri_layer(_LOWER, _RAISE, _ADJUST);
127 } else {
128 layer_off(_LOWER);
129 update_tri_layer(_LOWER, _RAISE, _ADJUST);
130 }
131 return false;
132 break;
133 case RAISE:
134 if (record->event.pressed) {
135 layer_on(_RAISE);
136 update_tri_layer(_LOWER, _RAISE, _ADJUST);
137 } else {
138 layer_off(_RAISE);
139 update_tri_layer(_LOWER, _RAISE, _ADJUST);
140 }
141 return false;
142 break;
143 }
144 return true;
145};
146
147bool muse_mode = false;
148uint8_t last_muse_note = 0;
149uint16_t muse_counter = 0;
150uint8_t muse_offset = 70;
151uint16_t muse_tempo = 50;
152
153void encoder_update_user(uint8_t index, bool clockwise) {
154 if (muse_mode) {
155 if (IS_LAYER_ON(_RAISE)) {
156 if (clockwise) {
157 muse_offset++;
158 } else {
159 muse_offset--;
160 }
161 } else {
162 if (clockwise) {
163 muse_tempo+=1;
164 } else {
165 muse_tempo-=1;
166 }
167 }
168 } else {
169 if (clockwise) {
170 tap_code(KC_PGDN);
171 } else {
172 tap_code(KC_PGUP);
173 }
174 }
175}
176
177void dip_update(uint8_t index, bool active) {
178 switch (index) {
179 case 0:
180 if (active) {
181 layer_on(_ADJUST);
182 } else {
183 layer_off(_ADJUST);
184 }
185 break;
186 case 1:
187 if (active) {
188 muse_mode = true;
189 } else {
190 muse_mode = false;
191 }
192 }
193}
194
195void matrix_scan_user(void) {
196 #ifdef AUDIO_ENABLE
197 if (muse_mode) {
198 if (muse_counter == 0) {
199 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
200 if (muse_note != last_muse_note) {
201 stop_note(compute_freq_for_midi_note(last_muse_note));
202 play_note(compute_freq_for_midi_note(muse_note), 0xF);
203 last_muse_note = muse_note;
204 }
205 }
206 muse_counter = (muse_counter + 1) % muse_tempo;
207 } else {
208 if (muse_counter) {
209 stop_all_notes();
210 muse_counter = 0;
211 }
212 }
213 #endif
214}
215
216bool music_mask_user(uint16_t keycode) {
217 switch (keycode) {
218 case RAISE:
219 case LOWER:
220 return false;
221 default:
222 return true;
223 }
224}
diff --git a/keyboards/preonic/keymaps/cranium/readme.md b/keyboards/preonic/keymaps/cranium/readme.md
new file mode 100644
index 000000000..0f1d99598
--- /dev/null
+++ b/keyboards/preonic/keymaps/cranium/readme.md
@@ -0,0 +1,72 @@
1# Cranium's Preonic layout
2
3This layout is based on the Preonic default with some changes I find interesting to share.
4
5## Default layer
6```
7 ,-----------------------------------------------------------------------------------.
8 | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Esc |
9 |------|------|------|------|------|------|------|------|------|------|------|------|
10 | Tab | Q | W | E | R | T | Y | U | I | O | P | Esc |
11 |------|------|------|------|------|-------------|------|------|------|------|------|
12 | Bksp | A | S | D | F | G | H | J | K | L | ; | " |
13 |------|------|------|------|------|------|------|------|------|------|------|------|
14 | Shift| Z | X | C | V | B | N | M | , | . | / | | |
15 |------|------|------|------|------|------|------|------|------|------|------|------|
16 | Ctrl | F12 | GUI | Alt |Lower | Space |Raise |AltGr | [ | ] |Enter |
17 `-----------------------------------------------------------------------------------'
18```
19- As a Colemak user, Capslock was rebound to Backspace.
20- Escape was moved to the top-right of the keyboard
21- Enter was moved to the bottom-right of the keyboard. It's now easy to hit and can even be activated with the palm.
22- An F12 was put next to the left CTRL => it's the shortcut I use to toggle the Guake terminal.
23- I don't really use the key below my Escape (top-right, 2nd row), so I'll consider any ideas for the moment.
24
25
26## Lower
27```
28 ,-----------------------------------------------------------------------------------.
29 | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 |
30 |------|------|------|------|------|-------------|------|------|------|------|------|
31 | | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del |
32 |------|------|------|------|------|-------------|------|------|------|------|------|
33 | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | + | = | | |
34 |------|------|------|------|------|------|------|------|------|------|------|------|
35 | LGUI | F7 | F8 | F9 | F10 | F11 | F12 | 1 | 2 | 3 | 4 | |
36 |------|------|------|------|------|------|------|------|------|------|------|------|
37 | | | | | | _ | | | | | |
38 `-----------------------------------------------------------------------------------'
39```
40- Not much changes here
41
42## Raise
43```
44 ,-----------------------------------------------------------------------------------.
45 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
46 |------|------|------|------|------|------|------|------|------|------|------|------|
47 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
48 |------|------|------|------|------|-------------|------|------|------|------|------|
49 | Del | F1 | F2 | F3 | F4 | F5 | F6 | Up | Down | Left |Right | |
50 |------|------|------|------|------|------|------|------|------|------|------|------|
51 | | F7 | F8 | F9 | F10 | F11 | F12 | Home | End | | | Shift|
52 |------|------|------|------|------|------|------|------|------|------|------|------|
53 | | | | | | _ | | | | | |
54 `-----------------------------------------------------------------------------------'
55```
56- Perhaps one of the most interesting change: the arrow keys were moved to the right-hand home row, activated with the Raise layer. It means I can use the arrow keys without moving my hand from the home row, by activating the Raise layer with my thumb. It took a while to adapt but it was totally worth it. To note, I also put Home/End on the same layer but one row below, with I also find really useful.
57
58## Adjust
59```
60 ,-----------------------------------------------------------------------------------.
61 | | | | | | | | | | | | Sleep|
62 |------|------|------|------|------|------|------|------|------|------|------|------|
63 | | Reset| Debug| | | | | | | | | |
64 |------|------|------|------|------|-------------|------|------|------|------|------|
65 | | | |Aud on|AudOff|AGnorm|AGswap| Vol+ | Vol- | Prev | Next | |
66 |------|------|------|------|------|------|------|------|------|------|------|------|
67 | |Voice-|Voice+|Mus on|MusOff|MidiOn|MidOff| | | | | |
68 |------|------|------|------|------|------|------|------|------|------|------|------|
69 | | | | | | Play | | | | | PrScr|
70 `-----------------------------------------------------------------------------------'
71```
72- The "arrow" keys act as Vol+/Vol-/Previous/Next on the Adjust layer (which is quite a natural mapping for these media keys).
diff --git a/keyboards/preonic/keymaps/cranium/rules.mk b/keyboards/preonic/keymaps/cranium/rules.mk
new file mode 100644
index 000000000..dcf16bef3
--- /dev/null
+++ b/keyboards/preonic/keymaps/cranium/rules.mk
@@ -0,0 +1 @@
SRC += muse.c