Skip to content

Commit b995b5a

Browse files
committed
feat: no need for layout modification anymore
1 parent d91440d commit b995b5a

7 files changed

Lines changed: 594 additions & 32 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#undef MATRIX_COLS
2+
#define MATRIX_COLS 12 // 7 columns for the main matrix, 5 virtual columns for buttons
3+
#define VIRTUAL_COL_START 7

keyboards/splitkb/kyria/rev3/keymaps/default_hlc/keymap.c

Lines changed: 269 additions & 0 deletions
Large diffs are not rendered by default.

keyboards/splitkb/kyria/rev3/keymaps/default_hlc/readme.md

Lines changed: 242 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENCODER_MAP_ENABLE = yes
2+
3+
# This adds module functionality to your keyboard (files found in users/halcyon_modules)
4+
USER_NAME := halcyon_modules
5+
CONVERT_TO=halcyon

keyboards/splitkb/kyria/rev3/keymaps/vial_hlc/config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616

1717
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
1818

19-
#undef MATRIX_ROWS
20-
#define MATRIX_ROWS 16
19+
#undef MATRIX_COLS
20+
#define MATRIX_COLS 12 // 7 columns for the main matrix, 5 virtual columns for buttons
21+
#define VIRTUAL_COL_START 7
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"lighting": "vialrgb",
33
"matrix": {
4-
"rows": 16,
5-
"cols": 7
4+
"rows": 8,
5+
"cols": 12
66
},
77
"layouts": {
88
"labels": [
@@ -20,37 +20,37 @@
2020
]
2121
],
2222
"keymap": [
23-
[{"y":0.25,"x":3},"0,3",{"x":9},"5,3"],
24-
[{"y":-0.75,"x":2},"0,4",{"x":1},"0,2",{"x":7},"5,2",{"x":1},"5,4"],
25-
[{"y":-0.875,"x":5},"0,1",{"x":5},"5,1"],
26-
[{"y":-0.625},"0,6","0,5",{"x":13},"5,5","5,6"],
27-
[{"y":-0.75,"x":3},"1,3",{"x":9},"6,3"],
28-
[{"y":-0.75,"x":2},"1,4",{"x":1},"1,2",{"x":7},"6,2",{"x":1},"6,4"],
29-
[{"y":-0.875,"x":5},"1,1",{"x":5},"6,1"],
30-
[{"y":-0.625},"1,6","1,5",{"x":13},"6,5","6,6"],
31-
[{"y":-0.75,"x":3},"2,3",{"x":9},"7,3"],
32-
[{"y":-0.75,"x":2},"2,4",{"x":1},"2,2",{"x":7},"7,2",{"x":1},"7,4"],
33-
[{"y":-0.875,"x":5},"2,1",{"x":5},"7,1"],
34-
[{"y":-0.625},"2,6","2,5",{"x":13},"7,5","7,6"],
35-
[{"y":-0.5,"x":2.5},"3,4",{"x":10},"8,4"],
23+
[{"y":0.25,"x":3},"0,3",{"x":9},"4,3"],
24+
[{"y":-0.75,"x":2},"0,4",{"x":1},"0,2",{"x":7},"4,2",{"x":1},"4,4"],
25+
[{"y":-0.875,"x":5},"0,1",{"x":5},"4,1"],
26+
[{"y":-0.625},"0,6","0,5",{"x":13},"4,5","4,6"],
27+
[{"y":-0.75,"x":3},"1,3",{"x":9},"5,3"],
28+
[{"y":-0.75,"x":2},"1,4",{"x":1},"1,2",{"x":7},"5,2",{"x":1},"5,4"],
29+
[{"y":-0.875,"x":5},"1,1",{"x":5},"5,1"],
30+
[{"y":-0.625},"1,6","1,5",{"x":13},"5,5","5,6"],
31+
[{"y":-0.75,"x":3},"2,3",{"x":9},"6,3"],
32+
[{"y":-0.75,"x":2},"2,4",{"x":1},"2,2",{"x":7},"6,2",{"x":1},"6,4"],
33+
[{"y":-0.875,"x":5},"2,1",{"x":5},"6,1"],
34+
[{"y":-0.625},"2,6","2,5",{"x":13},"6,5","6,6"],
35+
[{"y":-0.5,"x":2.5},"3,4",{"x":10},"7,4"],
3636
[{"rx":4,"ry":8.175,"y":-4.675,"x":-0.5},"3,2"],
37-
[{"rx":10.5,"ry":4.1,"y":2.25,"x":-10.5,"d":true},"1,0\n\n\n1,0\n\n\n\n\n\ne",{"d":true},"4,2\n\n\n1,0",{"d":true},"1,1\n\n\n1,0\n\n\n\n\n\ne",{"x":1,"d":true},"0,0\n\n\n0,0\n\n\n\n\n\ne",{"d":true},"0,1\n\n\n0,0\n\n\n\n\n\ne",{"x":5.25,"d":true},"2,0\n\n\n2,0\n\n\n\n\n\ne",{"d":true},"2,1\n\n\n2,0\n\n\n\n\n\ne",{"x":0.75,"d":true},"3,0\n\n\n3,0\n\n\n\n\n\ne",{"d":true},"9,2\n\n\n3,0",{"d":true},"3,1\n\n\n3,0\n\n\n\n\n\ne"],
38-
[{"x":-10.5,"d":true},"4,1\n\n\n1,0",{"d":true},"15,0\n\n\n1,0",{"d":true},"4,3\n\n\n1,0",{"x":1},"0,0\n\n\n0,1\n\n\n\n\n\ne","0,1\n\n\n0,1\n\n\n\n\n\ne",{"x":5.25},"2,0\n\n\n2,1\n\n\n\n\n\ne","2,1\n\n\n2,1\n\n\n\n\n\ne",{"x":0.75,"d":true},"9,1\n\n\n3,0",{"d":true},"9,0\n\n\n3,0",{"d":true},"9,3\n\n\n3,0"],
39-
[{"x":-9.5,"d":true},"4,4\n\n\n1,0",{"x":13,"d":true},"9,4\n\n\n3,0"],
40-
[{"y":0.5,"x":-10.5},"1,0\n\n\n1,1\n\n\n\n\n\ne",{"d":true},"4,2\n\n\n1,1","1,1\n\n\n1,1\n\n\n\n\n\ne",{"x":11},"3,0\n\n\n3,1\n\n\n\n\n\ne",{"d":true},"9,2\n\n\n3,1","3,1\n\n\n3,1\n\n\n\n\n\ne"],
41-
[{"x":-10.5,"d":true},"4,1\n\n\n1,1","15,0\n\n\n1,1",{"d":true},"4,3\n\n\n1,1",{"x":11,"d":true},"9,1\n\n\n3,1","9,0\n\n\n3,1",{"d":true},"9,3\n\n\n3,1"],
42-
[{"x":-9.5,"d":true},"4,4\n\n\n1,1",{"x":13,"d":true},"9,4\n\n\n3,1"],
43-
[{"rx":13,"ry":8.175,"y":-4.675,"x":-0.5},"8,2"],
37+
[{"rx":10.5,"ry":4.1,"y":2.25,"x":-10.5,"d":true},"1,0\n\n\n1,0\n\n\n\n\n\ne",{"d":true},"3,9\n\n\n1,0",{"d":true},"1,1\n\n\n1,0\n\n\n\n\n\ne",{"x":1,"d":true},"0,0\n\n\n0,0\n\n\n\n\n\ne",{"d":true},"0,1\n\n\n0,0\n\n\n\n\n\ne",{"x":5.25,"d":true},"2,0\n\n\n2,0\n\n\n\n\n\ne",{"d":true},"2,1\n\n\n2,0\n\n\n\n\n\ne",{"x":0.75,"d":true},"3,0\n\n\n3,0\n\n\n\n\n\ne",{"d":true},"7,9\n\n\n3,0",{"d":true},"3,1\n\n\n3,0\n\n\n\n\n\ne"],
38+
[{"x":-10.5,"d":true},"3,8\n\n\n1,0",{"d":true},"3,7\n\n\n1,0",{"d":true},"3,10\n\n\n1,0",{"x":1},"0,0\n\n\n0,1\n\n\n\n\n\ne","0,1\n\n\n0,1\n\n\n\n\n\ne",{"x":5.25},"2,0\n\n\n2,1\n\n\n\n\n\ne","2,1\n\n\n2,1\n\n\n\n\n\ne",{"x":0.75,"d":true},"7,8\n\n\n3,0",{"d":true},"7,7\n\n\n3,0",{"d":true},"7,10\n\n\n3,0"],
39+
[{"x":-9.5,"d":true},"3,11\n\n\n1,0",{"x":13,"d":true},"7,11\n\n\n3,0"],
40+
[{"y":0.5,"x":-10.5},"1,0\n\n\n1,1\n\n\n\n\n\ne",{"d":true},"3,9\n\n\n1,1","1,1\n\n\n1,1\n\n\n\n\n\ne",{"x":11},"3,0\n\n\n3,1\n\n\n\n\n\ne",{"d":true},"7,9\n\n\n3,1","3,1\n\n\n3,1\n\n\n\n\n\ne"],
41+
[{"x":-10.5,"d":true},"3,8\n\n\n1,1","3,7\n\n\n1,1",{"d":true},"3,10\n\n\n1,1",{"x":11,"d":true},"7,8\n\n\n3,1","7,7\n\n\n3,1",{"d":true},"7,10\n\n\n3,1"],
42+
[{"x":-9.5,"d":true},"3,11\n\n\n1,1",{"x":13,"d":true},"7,11\n\n\n3,1"],
43+
[{"rx":13,"ry":8.175,"y":-4.675,"x":-0.5},"7,2"],
4444
[{"r":15,"rx":4,"y":-4.675,"x":-0.5},"3,1"],
4545
[{"r":30,"y":-2,"x":-0.5},"3,3"],
4646
[{"x":-0.5},"3,5"],
4747
[{"r":45,"y":-2,"x":-0.5},"2,0"],
4848
[{"x":-0.5},"3,0"],
49-
[{"r":-45,"rx":13,"y":-5.675,"x":-0.5},"7,0"],
50-
[{"x":-0.5},"8,0"],
51-
[{"r":-30,"y":-2,"x":-0.5},"8,3"],
52-
[{"x":-0.5},"8,5"],
53-
[{"r":-15,"y":-1,"x":-0.5},"8,1"]
49+
[{"r":-45,"rx":13,"y":-5.675,"x":-0.5},"6,0"],
50+
[{"x":-0.5},"7,0"],
51+
[{"r":-30,"y":-2,"x":-0.5},"7,3"],
52+
[{"x":-0.5},"7,5"],
53+
[{"r":-15,"y":-1,"x":-0.5},"7,1"]
5454
]
5555
}
5656
}

users/halcyon_modules/splitkb/halcyon.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module_t module;
5555
bool backlight_off = false;
5656

5757
extern matrix_row_t matrix[MATRIX_ROWS];
58+
5859
#ifndef BUTTON_PINS
5960
# define BUTTON_PINS (const uint8_t[]){ }
6061
#endif
@@ -163,21 +164,62 @@ static void scan_buttons(void) {
163164
size_t num_pins = sizeof(BUTTON_PINS)/sizeof(BUTTON_PINS[0]);
164165
if (num_pins == 0) return;
165166

166-
uint8_t row = MATRIX_ROWS - 1;
167+
uint8_t row = is_keyboard_left() ? ROWS_PER_HAND - 1 : MATRIX_ROWS - 1;
167168

168169
for (size_t i = 0; i < num_pins; i++) {
169170
if (gpio_read_pin(BUTTON_PINS[i]) == 0) {
170-
matrix[row] |= (1 << i);
171+
matrix[row] |= (1 << (VIRTUAL_COL_START + i));
171172
} else {
172-
matrix[row] &= ~(1 << i);
173+
matrix[row] &= ~(1 << (VIRTUAL_COL_START + i));
173174
}
174175
}
175176
}
176177

177178
void matrix_scan_kb(void) {
178179
scan_buttons();
180+
181+
matrix_scan_user();
179182
}
180183

181184
void matrix_slave_scan_kb(void) {
182185
scan_buttons();
186+
187+
matrix_slave_scan_user();
188+
}
189+
190+
__attribute__((weak)) const uint16_t left_halcyon_buttons[10][5];
191+
__attribute__((weak)) const uint16_t right_halcyon_buttons[10][5];
192+
193+
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
194+
195+
#ifndef VIAL_ENABLE
196+
if (record->event.key.col >= VIRTUAL_COL_START) {
197+
uint8_t btn = record->event.key.col - VIRTUAL_COL_START;
198+
199+
if (btn < 5) {
200+
uint8_t row = record->event.key.row;
201+
uint8_t max_layer = get_highest_layer(layer_state | default_layer_state);
202+
203+
for (int8_t l = max_layer; l >= 0; l--) {
204+
if (!((layer_state | default_layer_state) & (1UL << l))) continue;
205+
206+
uint16_t code = KC_TRNS;
207+
208+
if (row < ROWS_PER_HAND) {
209+
code = left_halcyon_buttons[l][btn];
210+
} else {
211+
code = right_halcyon_buttons[l][btn];
212+
}
213+
214+
if (code != KC_TRNS) {
215+
record->event.pressed ? register_code16(code) : unregister_code16(code);
216+
break;
217+
}
218+
}
219+
}
220+
return false;
221+
}
222+
#endif // VIAL_ENABLE
223+
224+
return process_record_user(keycode, record);
183225
}

0 commit comments

Comments
 (0)