Skip to content

Commit 0382a25

Browse files
paulomp90drashna
andauthored
[Keymap] Add paulomp90 lily58 keymap (qmk#20327)
Co-authored-by: Drashna Jaelre <[email protected]>
1 parent 83dcbef commit 0382a25

File tree

6 files changed

+406
-0
lines changed

6 files changed

+406
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright 2023 Paulo Pereira
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 3 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+
20+
#define QUICK_TAP_TERM 0
21+
#define TAPPING_TERM 150
22+
#define TAP_CODE_DELAY 10
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* Copyright 2023 Paulo Pereira
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 3 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 "custom_shift_keys.h"
18+
19+
bool process_custom_shift_keys(uint16_t keycode, keyrecord_t *record) {
20+
static uint16_t registered_keycode = KC_NO;
21+
22+
// If a custom shift key is registered, then this event is either
23+
// releasing it or manipulating another key at the same time. Either way,
24+
// we release the currently registered key.
25+
if (registered_keycode != KC_NO) {
26+
unregister_code16(registered_keycode);
27+
registered_keycode = KC_NO;
28+
}
29+
30+
if (record->event.pressed) { // Press event.
31+
const uint8_t mods = get_mods();
32+
#ifndef NO_ACTION_ONESHOT
33+
if ((mods | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) {
34+
#else
35+
if ((mods | get_weak_mods()) & MOD_MASK_SHIFT) { // Shift is held.
36+
#endif // NO_ACTION_ONESHOT
37+
// Continue default handling if this is a tap-hold key being held.
38+
if ((IS_QK_MOD_TAP(keycode) || IS_QK_LAYER_TAP(keycode)) &&
39+
record->tap.count == 0) {
40+
return true;
41+
}
42+
43+
// Search for a custom shift key whose keycode is `keycode`.
44+
for (int i = 0; i < NUM_CUSTOM_SHIFT_KEYS; ++i) {
45+
if (keycode == custom_shift_keys[i].keycode) {
46+
registered_keycode = custom_shift_keys[i].shifted_keycode;
47+
if (IS_QK_MODS(registered_keycode) && // Should key be shifted?
48+
(QK_MODS_GET_MODS(registered_keycode) & MOD_LSFT) != 0) {
49+
register_code16(registered_keycode); // If so, press directly.
50+
} else {
51+
// If not, cancel shift mods, press the key, and restore mods.
52+
del_weak_mods(MOD_MASK_SHIFT);
53+
#ifndef NO_ACTION_ONESHOT
54+
del_oneshot_mods(MOD_MASK_SHIFT);
55+
#endif // NO_ACTION_ONESHOT
56+
unregister_mods(MOD_MASK_SHIFT);
57+
register_code16(registered_keycode);
58+
set_mods(mods);
59+
}
60+
return false;
61+
}
62+
}
63+
}
64+
}
65+
66+
return true; // Continue with default handling.
67+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright 2023 Paulo Pereira
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 3 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+
18+
#pragma once
19+
#include QMK_KEYBOARD_H
20+
21+
typedef struct {
22+
uint16_t keycode;
23+
uint16_t shifted_keycode;
24+
} custom_shift_key_t;
25+
26+
extern const custom_shift_key_t custom_shift_keys[];
27+
extern uint8_t NUM_CUSTOM_SHIFT_KEYS;
28+
29+
bool process_custom_shift_keys(uint16_t keycode, keyrecord_t *record);
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
/* Copyright 2023 Paulo Pereira
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 3 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 "keymap_portuguese.h"
19+
#include "features/custom_shift_keys.h"
20+
21+
enum layer_number {
22+
_QWERTY = 0,
23+
_LOWER,
24+
_RAISE,
25+
_ADJUST,
26+
};
27+
28+
/* tap dance shifts */
29+
typedef struct {
30+
bool is_press_action;
31+
int state;
32+
} tap;
33+
34+
typedef enum {
35+
TD_NONE,
36+
TD_UNKNOWN,
37+
TD_SINGLE_TAP,
38+
TD_SINGLE_HOLD,
39+
TD_DOUBLE_TAP
40+
} td_state_t;
41+
42+
enum { LEFT_SHIFT = 0, RIGHT_SHIFT = 1 };
43+
44+
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
45+
46+
/* QWERTY
47+
* ,-----------------------------------------. ,-----------------------------------------.
48+
* | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | '? |
49+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
50+
* | Tab | Q | W | E | R | T | | Y | U | I | O | P | +* |
51+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
52+
* |LShift| A | S | D | F | G |-------. ,-------| H | J | K | L | Ç | BACK |
53+
* |------+------+------+------+------+------| <> | | ´` |------+------+------+------+------+------|
54+
* |LCTRL | Z | X | C | V | B |-------| |-------| N | M | ,; | .: | _- |Shift|
55+
* `-----------------------------------------/ / \ \-----------------------------------------'
56+
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
57+
* | | | |/ / \ \ | | | |
58+
* `-------------------''-------' '------''--------------------'
59+
*/
60+
[_QWERTY] = LAYOUT(
61+
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
62+
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL,
63+
TD(LEFT_SHIFT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_BSPC,
64+
KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_GRV, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, TD(RIGHT_SHIFT),
65+
KC_LALT, KC_LGUI, TL_LOWR, KC_SPC, KC_ENT, TL_UPPR, KC_RGUI, KC_RALT
66+
),
67+
68+
/* LOWER
69+
* ,-----------------------------------------. ,-----------------------------------------.
70+
* | | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | |
71+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
72+
* | F1 | | | | | | | PgUp | HOME | Up | END | ºª | F12 |
73+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
74+
* | | | | | | |-------. ,-------| PgDn | Left | Down |Right | ~^ | DEL |
75+
* |------+------+------+------+------+------| <> | | ´` |------+------+------+------+------+------|
76+
* | | | | << | >|| | >> |-------| |-------| | Vol+ | Vol- | Mute | \| | |
77+
* `-----------------------------------------/ / \ \-----------------------------------------'
78+
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
79+
* | | | |/ / \ \ | | | |
80+
* `-------------------''-------' '------''--------------------'
81+
*/
82+
[_LOWER] = LAYOUT(
83+
_______, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______,
84+
KC_F1, _______, _______, _______, _______, _______, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_LBRC, KC_F12,
85+
_______, _______, _______, _______, _______, _______, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_QUOT, KC_DEL,
86+
_______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, _______, KC_VOLU, KC_VOLD, KC_MUTE, KC_BSLS, _______,
87+
_______, _______, _______, _______, _______, _______, _______, _______
88+
),
89+
90+
/* RAISE
91+
* ,-----------------------------------------. ,-----------------------------------------.
92+
* | | | | | | | | | | | | | |
93+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
94+
* | | 1 | 2 | 3 | 4 | 5 | | PgUp | HOME | Up | END | ºª | |
95+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
96+
* | | 6 | 7 | 8 | 9 | 0 |-------. ,-------| PgDn | Left | Down |Right | ~^ | |
97+
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
98+
* | | | | << | >|| | >> |-------| |-------| | Vol+ | Vol- | Mute | \| | |
99+
* `-----------------------------------------/ / \ \-----------------------------------------'
100+
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
101+
* | | | |/ / \ \ | | | |
102+
* `-------------------''-------' '------''--------------------'
103+
*/
104+
[_RAISE] = LAYOUT(
105+
_______, _______, _______, _______, _______, _______, _______, _______, _______,_______, _______, _______,
106+
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_LBRC, _______,
107+
_______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_QUOT, _______,
108+
_______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, _______, KC_VOLU, KC_VOLD, KC_MUTE, KC_BSLS, _______,
109+
_______, _______, _______, _______, _______, _______, _______, _______
110+
),
111+
112+
/* ADJUST
113+
* ,-----------------------------------------. ,-----------------------------------------.
114+
* | | | | | | | | | | | | | |
115+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
116+
* | | | | | | | | | | | | | |
117+
* |------+------+------+------+------+------| |------+------+------+------+------+------|
118+
* |RGB ON| HUE+ | SAT+ | VAL+ | | BRG+ |-------. ,-------| | | | | | |
119+
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
120+
* | MODE | HUE- | SAT- | VAL- | | BRG- |-------| |-------| | | | | | |
121+
* `-----------------------------------------/ / \ \-----------------------------------------'
122+
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
123+
* | | | |/ / \ \ | | | |
124+
* `----------------------------' '------''--------------------'
125+
*/
126+
127+
[_ADJUST] = LAYOUT(
128+
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
129+
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
130+
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, KC_BRIU, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
131+
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, KC_BRID, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
132+
_______, _______, _______, _______, _______, _______, _______, _______
133+
)
134+
};
135+
136+
// SSD1306 OLED update loop, make sure to enable OLED_ENABLE=yes in rules.mk
137+
#ifdef OLED_ENABLE
138+
139+
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
140+
if (!is_keyboard_master()) return OLED_ROTATION_180; // flips the display 180 degrees if offhand
141+
return rotation;
142+
}
143+
144+
// When you add source files to SRC in rules.mk, you can use functions.
145+
const char *read_layer_state(void);
146+
const char *read_logo(void);
147+
void set_keylog(uint16_t keycode, keyrecord_t *record);
148+
const char *read_keylog(void);
149+
const char *read_keylogs(void);
150+
151+
bool oled_task_user(void) {
152+
if (is_keyboard_master()) {
153+
oled_write_ln(read_layer_state(), false);
154+
oled_write_ln(read_keylog(), false);
155+
oled_write_ln(read_keylogs(), false);
156+
} else {
157+
oled_write(read_logo(), false);
158+
}
159+
return false;
160+
}
161+
#endif // OLED_ENABLE
162+
163+
164+
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
165+
if (record->event.pressed) {
166+
#ifdef OLED_ENABLE
167+
set_keylog(keycode, record);
168+
#endif
169+
}
170+
171+
return true;
172+
}
173+
174+
/* Tap dance shifts */
175+
td_state_t cur_dance(tap_dance_state_t *state) {
176+
if (state->count == 1) {
177+
if (state->interrupted || !state->pressed) {
178+
return TD_SINGLE_TAP;
179+
} else {
180+
return TD_SINGLE_HOLD;
181+
}
182+
} else if (state->count == 2) {
183+
return TD_DOUBLE_TAP;
184+
}
185+
186+
return TD_UNKNOWN;
187+
}
188+
189+
static tap lshifttap_state = {.is_press_action = true, .state = TD_NONE};
190+
191+
static tap rshifttap_state = {.is_press_action = true, .state = TD_NONE};
192+
193+
void lshift_finished(tap_dance_state_t *state, void *user_data) {
194+
lshifttap_state.state = cur_dance(state);
195+
196+
switch (lshifttap_state.state) {
197+
case TD_SINGLE_TAP:
198+
register_code16(LALT(KC_LEFT));
199+
break;
200+
case TD_SINGLE_HOLD:
201+
register_code(KC_LSFT);
202+
break;
203+
case TD_DOUBLE_TAP:
204+
tap_code16(LALT(KC_LEFT));
205+
register_code16(LALT(KC_LEFT));
206+
break;
207+
default:
208+
break;
209+
}
210+
}
211+
212+
void lshift_reset(tap_dance_state_t *state, void *user_data) {
213+
switch (lshifttap_state.state) {
214+
case TD_SINGLE_TAP:
215+
unregister_code16(LALT(KC_LEFT));
216+
break;
217+
case TD_SINGLE_HOLD:
218+
unregister_code(KC_LSFT);
219+
break;
220+
case TD_DOUBLE_TAP:
221+
unregister_code16(LALT(KC_LEFT));
222+
break;
223+
}
224+
lshifttap_state.state = TD_NONE;
225+
}
226+
227+
void rshift_finished(tap_dance_state_t *state, void *user_data) {
228+
rshifttap_state.state = cur_dance(state);
229+
230+
switch (rshifttap_state.state) {
231+
case TD_SINGLE_TAP:
232+
register_code16(LALT(KC_RGHT));
233+
break;
234+
case TD_SINGLE_HOLD:
235+
register_code(KC_RSFT);
236+
break;
237+
case TD_DOUBLE_TAP:
238+
tap_code16(LALT(KC_RGHT));
239+
register_code16(LALT(KC_RGHT));
240+
break;
241+
default:
242+
break;
243+
}
244+
}
245+
246+
void rshift_reset(tap_dance_state_t *state, void *user_data) {
247+
switch (rshifttap_state.state) {
248+
case TD_SINGLE_TAP:
249+
unregister_code16(LALT(KC_RGHT));
250+
break;
251+
case TD_SINGLE_HOLD:
252+
unregister_code(KC_RSFT);
253+
break;
254+
case TD_DOUBLE_TAP:
255+
unregister_code16(LALT(KC_RGHT));
256+
break;
257+
}
258+
rshifttap_state.state = TD_NONE;
259+
}
260+
261+
tap_dance_action_t tap_dance_actions[] = {
262+
[LEFT_SHIFT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, lshift_finished, lshift_reset),
263+
[RIGHT_SHIFT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, rshift_finished, rshift_reset),
264+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Paulo Lily58
2+
3+
Lily58 is 6×4 column-staggered split keyboard.
4+
5+
![Keymap first layer](https://i.postimg.cc/HWcgcxb8/lily58.png "Keymap first layer")
6+
7+
- Add portuguese include
8+
- Add custom shift behaviour, when tap move by 1 word left <> right, when held act as shift.
9+
idea taken from [here](https://getreuer.info/posts/keyboards/custom-shift-keys/index.html).
10+

0 commit comments

Comments
 (0)