4 #include "action_layer.h"
5 #include "keymap_extras/keymap_bepo.h"
8 // Each layer gets a name for readability, which is then used in the keymap matrix below.
9 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
15 #define PEDAL_DELAY 250
22 M_SFS, // shift and space
23 M_L1E, // L1 and space
24 L2INS, // L2 and insert
31 M_SFU, // shift and underscore
34 static uint16_t key_timer_left_pedal;
35 static uint16_t key_timer_right_pedal;
36 static uint16_t key_timer_shift;
37 static uint16_t key_timer_1;
38 static uint16_t key_timer_2;
40 static uint16_t shift_count = 0; //this is used to keep track of shift state and avoid inserting non breakable space
41 static uint16_t l2_locked = 0; //this indicate wether L2 is locked
43 #define BP_CBSP CTL_T(KC_BSPC)
44 #define BP_CDEL CTL_T(KC_DEL)
46 //layout : http://www.keyboard-layout-editor.com/#/gists/4480e3ab8026eb7c710a7e22203ef4aa
47 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
49 * left foot clicked is right click
50 * left foot pressed is layer 2
51 * right foot clicked is left click
52 * right foot pressed is layer 1 + scroll lock (used with autohotkey for easier scrolling with trackballs)
53 * ,------. .. ,------. *
54 * ,------| F3 |-------------. .. ,-------------| F10 |------. *
55 * ,------| F2 |------| F4 | F5 |------. .. ,------| F8 | F9 |------| F11 |------. *
56 * | F1 |------| »/3 |------|------| F6 | .. | F7 |------|------| -/8 |------| F12 | *
57 * ,------+------| «/2 |------| (/4 | )/5 |------| .. |------| @/6 | +/7 |------| //9 |------+------. *
58 * | ESC | "/1 |------| O |------|------| ¨ | .. | ^ |------|------| D |------| * /0 |BCKSP | *
59 * |------+------| É |------| P | È |------| .. |------| K | V |------| L |------+------| *
60 * | TAB | B |------| E |------|------| _ | .. | =/° |------|------| S |------| J |ENTER | *
61 * |------+------| U |------| I | F |------| .. |------| C | T |------| R |------+------| *
62 * | ` | A |------| Y |------|------| ; | .. | ! |------|------| UP |------| N | '/? | *
63 * |------+------| À |------| X | W |------|-------------. .. .-------------|------| M | G |------| H |------+------| *
64 * | SHIFT| Z |------| . |------|------|sp/sh |bsp/ct|L2/ins| .. |L2lock|del/CT|sp/sh |------|------| DOWN |------| Q |SHIFT | *
65 * |------+------| / |------| , | space|------|------|------ .. ------|------|------| L1/sp| LEFT |------| UP |------+------| *
66 * | CTRL | win |------/ \-------------| L1 | alt | .. | CAPS | L1 |-------------/ \------| : | CTRL | *
67 * `-------------/ \-------------/ .. \-------------/ \-------------/ *
71 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
72 KC_ESC, BP_DQOT, BP_LGIL, BP_RGIL, BP_LPRN, BP_RPRN, BP_DTRM, BP_DCRC, BP_AT, BP_PLUS, BP_MINS, BP_SLSH, BP_ASTR, KC_BSPC, \
73 KC_TAB, BP_B, BP_ECUT, BP_O, BP_P, BP_EGRV, BP_UNDS, BP_EQL, BP_K, BP_V, BP_D, BP_L, BP_J, KC_ENT, \
74 BP_GRV, BP_A, BP_U, BP_E, BP_I, BP_F, BP_SCLN, BP_EXLM, BP_C, BP_T, BP_S, BP_R, BP_N, BP_APOS, \
75 M(M_SF), BP_Z, BP_AGRV, BP_Y, BP_X, KC_RBRACKET, M(M_SFS), BP_CBSP, M(L2INS), M(L2LOC), BP_CDEL, M(M_SFS),BP_M, BP_G, KC_UP, BP_H, BP_Q, M(M_SF), \
76 KC_LCTL, KC_LGUI, KC_PSLS, BP_DOT, BP_COMM, KC_SPACE,M(M_L1E), KC_LALT, KC_CAPS, M(M_L1E),KC_SPACE,KC_LEFT, KC_DOWN, KC_RIGHT,BP_COLN, KC_RCTL, \
78 M(M_LP), M(M_RP), KC_TRNS, \
80 M(M_LP), M(M_RP), KC_TRNS \
83 /* Larer 1 for symbols.
84 * left foot is middle click
85 * ,------. .. ,------. *
86 * ,------| |-------------. .. ,-------------| |------. *
87 * ,------| |------| | |------. .. ,------| | |------| |------. *
88 * | |------| § |------|------| | .. | |------|------| ± |------| | *
89 * ,------+------| ¶ |------| µ | |------| .. |------| ≤ | ≥ |------| ÷ |------+------. *
90 * | | ¤ |------| { |------|------| ~ | .. | ˇ |------|------| ] |------| × | | *
91 * |------+------| * |------| } | ` |------| .. |------| # | [ |------| % |------+------| *
92 * | | \ |------| ( |------|------| | .. | ≠ |------|------| > |------| ‰ | | *
93 * |------+------| Ù |------| ) | + |------| .. |------| Ç | < |------| & |------+------| *
94 * | | = |------| copy |------|------| : | .. | ? |------|------| PGUP |------| _ | | *
95 * |------+------| cut |------| paste|search|------|-------------. .. .-------------|------| $ | = |------| | |------+------| *
96 * | | undo |------| \ |------|------| | | | .. | | | |------|------| PGDN |------| / | | *
97 * |------+------| |------| | |------|------|------ .. ------|------|------| | HOME |------| PGDN |------+------| *
98 * | | |------/ \-------------| | | .. | | |-------------/ \------| | | *
99 * `-------------/ \-------------/ .. \-------------/ \-------------/ *
103 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
104 KC_TRNS, BP_DCUR, BP_PARG, BP_SECT, BP_DGRK, KC_TRNS, BP_TILD, BP_DCAR, BP_LEQL, BP_GEQL, BP_PSMS, BP_OBEL, BP_TIMS, KC_TRNS, \
105 KC_TRNS, BP_BSLS, BP_ASTR, BP_LCBR, BP_RCBR, BP_GRV, KC_TRNS, BP_DIFF, BP_HASH, BP_LBRC, BP_RBRC, BP_PERC, BP_PMIL, KC_TRNS, \
106 KC_TRNS, BP_EQL, BP_UGRV, BP_LPRN, BP_RPRN, BP_PLUS, BP_COLN, BP_QEST, BP_CCED, BP_LESS, BP_GRTR, BP_AMPR, BP_UNDS, KC_TRNS, \
107 KC_TRNS, M(M_UN), M(M_CUT),M(M_CP), M(M_PS), M(M_SE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BP_DLR, BP_EQL, KC_PGUP, BP_PIPE, BP_SLSH, KC_TRNS, \
108 KC_TRNS, KC_TRNS, BP_BSLS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_END, KC_TRNS, KC_TRNS, \
110 KC_TRNS, KC_BTN1, KC_TRNS, \
112 KC_TRNS, KC_BTN1, KC_TRNS \
115 /* MEDIA, mouse and numpad.
116 * right pedal is left clic
117 * ,------. .. ,------. *
118 * ,------|PAUSE |-------------. .. ,-------------| PRINT|------. *
119 * ,------|SCROLL|------|MUTE |VOLUD |------. .. ,------| pre | next |------| calc |------. *
120 * |RESET |------| stop |------|------|VOLDU | .. | play |------|------| stop |------| num | *
121 * ,------+------| |------| pre | next |------| .. |------| pre | next |------| |------+------. *
122 * | | |------|scrolu|------|------| play | .. | play |------|------| 8 |------| - | | *
123 * |------+------| |------| | bt4 |------| .. |------| next | 7 |------| 9 |------+------| *
124 * | | |------|scrold|------|------| bt5 | .. | pre |------|------| 5 |------| + | | *
125 * |------+------| |------|mclic | rclic|------| .. |------| rclic| 4 |------| 6 |------+------| *
126 * | | |------| |------|------| lclic| .. | lclic|------|------| 2 |------| * | | *
127 * |------+------| |------| | mclck|------|-------------. .. .-------------|------| mclic| 1 |------| 3 |------+------| *
128 * | | |------| |------|------| | | | .. | | | |------|------| num. |------| / | | *
129 * |------+------| |------| | |------|------|------ .. ------|------|------| | 0 |------| . |------+------| *
130 * | | |------/ \-------------| | | .. | | |-------------/ \------| , | | *
131 * `-------------/ \-------------/ .. \-------------/ \-------------/ *
135 RESET, KC_SLCK, KC_PAUS, KC_MUTE, KC_VOLD, KC_VOLU, KC_MUTE, KC_VOLD, KC_VOLU, KC_PSCR, KC_CALC, KC_NLCK, \
136 KC_TRNS, KC_TRNS, KC_TRNS, KC_MSTP, KC_MPRV, KC_MNXT, KC_MPLY, KC_MPLY, KC_MPRV, KC_MNXT, KC_MSTP, KC_TRNS, KC_PMNS, KC_TRNS, \
137 KC_TRNS, KC_TRNS, KC_TRNS, KC_WH_U, KC_TRNS, KC_BTN4, KC_BTN5, KC_BTN4, KC_BTN5, KC_KP_7, KC_KP_8, KC_KP_9, KC_PPLS, KC_TRNS, \
138 KC_TRNS, KC_TRNS, KC_TRNS, KC_WH_D, KC_BTN3, KC_BTN2, KC_BTN1, KC_BTN1, KC_BTN2, KC_KP_4, KC_KP_5, KC_KP_6, KC_PAST, KC_TRNS, \
139 KC_TRNS, M(M_UN), M(M_CUT),M(M_CP), M(M_PS), KC_BTN3, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN3, KC_KP_1, KC_KP_2, KC_KP_3, KC_PSLS, KC_TRNS, \
140 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_KP_0, KC_PDOT, BP_DOT, BP_COMM, KC_TRNS, \
142 KC_BTN3, M(M_RP), KC_TRNS, \
144 KC_BTN3, M(M_RP), KC_TRNS \
147 /* TRNS - skeleton for laters
148 * ,------. .. ,------. *
149 * ,------| |-------------. .. ,-------------| |------. *
150 * ,------| |------| | |------. .. ,------| | |------| |------. *
151 * | |------| |------|------| | .. | |------|------| |------| | *
152 * ,------+------| |------| | |------| .. |------| | |------| |------+------. *
153 * | | |------| |------|------| | .. | |------|------| |------| | | *
154 * |------+------| |------| | |------| .. |------| | |------| |------+------| *
155 * | | |------| |------|------| | .. | |------|------| |------| | | *
156 * |------+------| |------| | |------| .. |------| | |------| |------+------| *
157 * | | |------| |------|------| | .. | |------|------| |------| | | *
158 * |------+------| |------| | |------|-------------. .. .-------------|------| | |------| |------+------| *
159 * | | |------| |------|------| | | | .. | | | |------|------| |------| | | *
160 * |------+------| |------| | |------|------|------ .. ------|------|------| | |------| |------+------| *
161 * | | |------/ \-------------| | | .. | | |-------------/ \------| | | *
162 * `-------------/ \-------------/ .. \-------------/ \-------------/ *
167 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
168 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
169 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
170 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
171 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
172 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
174 KC_BTN3, M(M_RP), KC_TRNS, \
176 KC_BTN3, M(M_RP), KC_TRNS \
182 const uint16_t PROGMEM fn_actions[] = {
186 void hold_shift(void) {
187 shift_count = shift_count + 1;
188 register_code(KC_LSHIFT);
191 void release_shift(void) {
192 shift_count = shift_count - 1;
193 if(shift_count <= 0){
194 unregister_code(KC_LSHIFT);
199 void press_space(void) {
200 if(shift_count > 0) unregister_code (KC_LSHIFT);
201 register_code (KC_SPACE);
202 unregister_code (KC_SPACE);
203 if(shift_count > 0) register_code (KC_LSHIFT);
206 void press_enter(void) {
207 if(shift_count > 0) unregister_code (KC_LSHIFT);
208 register_code (KC_ENT);
209 unregister_code (KC_ENT);
210 if(shift_count > 0) register_code (KC_LSHIFT);
213 void press_underscore(void) {
214 if(shift_count > 0) unregister_code (KC_LSHIFT);
215 register_code ((unsigned char) BP_UNDS);
216 unregister_code ((unsigned char) BP_UNDS);
217 if(shift_count > 0) register_code (KC_LSHIFT);
220 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
223 case M_LP: //left pedal
224 if (record->event.pressed) {
226 register_code (KC_SLCK);
227 key_timer_left_pedal = timer_read(); // if the key is being pressed, we start the timer.
229 if (timer_elapsed(key_timer_left_pedal) < KEY_DELAY) {
230 mousekey_on (KC_BTN2);
232 mousekey_off (KC_BTN2);
235 unregister_code (KC_SLCK);
239 case M_RP: //right pedal
240 if (record->event.pressed) {
242 key_timer_right_pedal = timer_read(); // if the key is being pressed, we start the timer.
244 if (timer_elapsed(key_timer_right_pedal) < PEDAL_DELAY) {
245 mousekey_on (KC_BTN1);
247 mousekey_off (KC_BTN1);
253 case M_SF: // shift, using macro to keep track of shift state and avoid inserting nbsp by mistake
254 if (record->event.pressed) {
260 case M_SFS: // shift when held, space when tapped
261 if (record->event.pressed) {
263 key_timer_shift = timer_read(); // if the key is being pressed, we start the timer.
265 if (timer_elapsed(key_timer_shift) < KEY_DELAY) {
271 case M_SFU: // shift when held, _ when tapped
272 if (record->event.pressed) {
274 key_timer_shift = timer_read(); // if the key is being pressed, we start the timer.
276 if (timer_elapsed(key_timer_shift) < KEY_DELAY) {
282 case M_L1E: // L1 when held, space when tapped
283 if (record->event.pressed) {
285 key_timer_1 = timer_read(); // if the key is being pressed, we start the timer.
287 if (timer_elapsed(key_timer_1) < KEY_DELAY) {
293 case L2INS: //activate layer 2, if released before 100ms trigger INS. basicaly equivalent to LT(2, KC_INS) but without delay for activation of layer 2
294 if (record->event.pressed) {
296 key_timer_2 = timer_read(); // if the key is being pressed, we start the timer.
298 if (timer_elapsed(key_timer_2) < KEY_DELAY) {
299 register_code (KC_INS);
300 unregister_code (KC_INS);
306 case L2LOC: //lock L2
307 if (record->event.pressed) {
308 key_timer_2 = timer_read(); // if the key is being pressed, we start the timer.
311 if (timer_elapsed(key_timer_2) < KEY_DELAY && l2_locked == 0) {
321 if (record->event.pressed) {
322 register_code(KC_LCTL);
324 unregister_code(BP_Z);
325 unregister_code(KC_LCTL);
329 if (record->event.pressed) {
330 register_code(KC_LCTL);
332 unregister_code(BP_X);
333 unregister_code(KC_LCTL);
337 if (record->event.pressed) {
338 register_code(KC_LCTL);
340 unregister_code(BP_C);
341 unregister_code(KC_LCTL);
345 if (record->event.pressed) {
346 register_code(KC_LCTL);
348 unregister_code(BP_V);
349 unregister_code(KC_LCTL);
353 if (record->event.pressed) {
354 register_code(KC_LCTL);
356 unregister_code(BP_F);
357 unregister_code(KC_LCTL);
364 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
368 void matrix_init_user(void) {
371 // Bleah globals need to be initialized.
372 uint8_t old_layer=_BASE;
374 void matrix_scan_user(void) {
375 uint8_t layer = biton32(layer_state);
377 frenchdev_led_1_off();
378 frenchdev_led_2_off();
381 frenchdev_led_2_on();
384 frenchdev_led_1_on();
387 frenchdev_led_1_on();
388 frenchdev_led_2_on();
396 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
400 void led_set_user(uint8_t usb_led) {
401 if (usb_led & (1<<USB_LED_CAPS_LOCK)){
402 frenchdev_led_3_on();
404 frenchdev_led_3_off();