logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (19313B)


  1. #include QMK_KEYBOARD_H
  2. #include "keymap_bepo.h"
  3. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  4. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  5. #define _BASE 0
  6. #define _SYMBOLS 1
  7. #define _MEDIA 2
  8. #define _TRNS 8
  9. #define PEDAL_DELAY 250
  10. #define KEY_DELAY 130
  11. enum custom_keycodes {
  12. M_LP = SAFE_RANGE, // left pedal
  13. M_RP, // right pedal
  14. M_SF, // shift
  15. M_SFS, // shift and space
  16. M_L1E, // L1 and space
  17. L2INS, // L2 and insert
  18. L2LOC, // Lock L2
  19. M_UN, // undo
  20. M_CUT, // cut
  21. M_CP, // copy
  22. M_PS, // paste
  23. M_SE, // search
  24. M_SFU, // shift and underscore
  25. };
  26. static uint16_t key_timer_left_pedal;
  27. static uint16_t key_timer_right_pedal;
  28. static uint16_t key_timer_shift;
  29. static uint16_t key_timer_1;
  30. static uint16_t key_timer_2;
  31. static uint16_t shift_count = 0; //this is used to keep track of shift state and avoid inserting non breakable space
  32. static uint16_t l2_locked = 0; //this indicate wether L2 is locked
  33. #define BP_CBSP CTL_T(KC_BSPC)
  34. #define BP_CDEL CTL_T(KC_DEL)
  35. //layout : http://www.keyboard-layout-editor.com/#/gists/4480e3ab8026eb7c710a7e22203ef4aa
  36. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  37. /* base
  38. * left foot clicked is right click
  39. * left foot pressed is layer 2
  40. * right foot clicked is left click
  41. * right foot pressed is layer 1 + scroll lock (used with autohotkey for easier scrolling with trackballs)
  42. * ,------. .. ,------. *
  43. * ,------| F3 |-------------. .. ,-------------| F10 |------. *
  44. * ,------| F2 |------| F4 | F5 |------. .. ,------| F8 | F9 |------| F11 |------. *
  45. * | F1 |------| »/3 |------|------| F6 | .. | F7 |------|------| -/8 |------| F12 | *
  46. * ,------+------| «/2 |------| (/4 | )/5 |------| .. |------| @/6 | +/7 |------| //9 |------+------. *
  47. * | ESC | "/1 |------| O |------|------| ¨ | .. | ^ |------|------| D |------| * /0 |BCKSP | *
  48. * |------+------| É |------| P | È |------| .. |------| K | V |------| L |------+------| *
  49. * | TAB | B |------| E |------|------| _ | .. | =/° |------|------| S |------| J |ENTER | *
  50. * |------+------| U |------| I | F |------| .. |------| C | T |------| R |------+------| *
  51. * | ` | A |------| Y |------|------| ; | .. | ! |------|------| UP |------| N | '/? | *
  52. * |------+------| À |------| X | W |------|-------------. .. .-------------|------| M | G |------| H |------+------| *
  53. * | SHIFT| Z |------| . |------|------|sp/sh |bsp/ct|L2/ins| .. |L2lock|del/CT|sp/sh |------|------| DOWN |------| Q |SHIFT | *
  54. * |------+------| / |------| , | space|------|------|------ .. ------|------|------| L1/sp| LEFT |------| UP |------+------| *
  55. * | CTRL | win |------/ \-------------| L1 | alt | .. | CAPS | L1 |-------------/ \------| : | CTRL | *
  56. * `-------------/ \-------------/ .. \-------------/ \-------------/ *
  57. */
  58. [_BASE] = LAYOUT(
  59. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
  60. KC_ESC, BP_DQUO, BP_LDAQ, BP_RDAQ, BP_LPRN, BP_RPRN, BP_DIAE, BP_DCIR, BP_AT, BP_PLUS, BP_MINS, BP_SLSH, BP_ASTR, KC_BSPC,
  61. KC_TAB, BP_B, BP_EACU, BP_O, BP_P, BP_EGRV, BP_UNDS, BP_EQL, BP_K, BP_V, BP_D, BP_L, BP_J, KC_ENT,
  62. 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_QUOT,
  63. M_SF, BP_Z, BP_AGRV, BP_Y, BP_X, KC_RBRC, M_SFS, BP_CBSP, L2INS, L2LOC, BP_CDEL, M_SFS, BP_M, BP_G, KC_UP, BP_H, BP_Q, M_SF,
  64. KC_LCTL, KC_LGUI, KC_PSLS, BP_DOT, BP_COMM, KC_SPACE,M_L1E, KC_LALT, KC_CAPS, M_L1E, KC_SPACE, KC_LEFT, KC_DOWN, KC_RIGHT,BP_COLN, KC_RCTL,
  65. //left pedals
  66. M_LP, M_RP, KC_TRNS,
  67. //right pedals
  68. M_LP, M_RP, KC_TRNS
  69. ),
  70. /* Larer 1 for symbols.
  71. * left foot is middle click
  72. * ,------. .. ,------. *
  73. * ,------| |-------------. .. ,-------------| |------. *
  74. * ,------| |------| | |------. .. ,------| | |------| |------. *
  75. * | |------| § |------|------| | .. | |------|------| ± |------| | *
  76. * ,------+------| ¶ |------| µ | |------| .. |------| ≤ | ≥ |------| ÷ |------+------. *
  77. * | | ¤ |------| { |------|------| ~ | .. | ˇ |------|------| ] |------| × | | *
  78. * |------+------| * |------| } | ` |------| .. |------| # | [ |------| % |------+------| *
  79. * | | \ |------| ( |------|------| | .. | ≠ |------|------| > |------| ‰ | | *
  80. * |------+------| Ù |------| ) | + |------| .. |------| Ç | < |------| & |------+------| *
  81. * | | = |------| copy |------|------| : | .. | ? |------|------| PGUP |------| _ | | *
  82. * |------+------| cut |------| paste|search|------|-------------. .. .-------------|------| $ | = |------| | |------+------| *
  83. * | | undo |------| \ |------|------| | | | .. | | | |------|------| PGDN |------| / | | *
  84. * |------+------| |------| | |------|------|------ .. ------|------|------| | HOME |------| PGDN |------+------| *
  85. * | | |------/ \-------------| | | .. | | |-------------/ \------| | | *
  86. * `-------------/ \-------------/ .. \-------------/ \-------------/ *
  87. *
  88. */
  89. [_SYMBOLS] = LAYOUT(
  90. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  91. KC_TRNS, BP_CURR, BP_PARA, BP_SECT, BP_DGRK, KC_TRNS, BP_TILD, BP_CARN, BP_LEQL, BP_GEQL, BP_PLMN, BP_DIV, BP_MUL, KC_TRNS,
  92. KC_TRNS, BP_BSLS, BP_ASTR, BP_LCBR, BP_RCBR, BP_GRV, KC_TRNS, BP_NEQL, BP_HASH, BP_LBRC, BP_RBRC, BP_PERC, BP_PERM, KC_TRNS,
  93. KC_TRNS, BP_EQL, BP_UGRV, BP_LPRN, BP_RPRN, BP_PLUS, BP_COLN, BP_QUES, BP_CCED, BP_LABK, BP_RABK, BP_AMPR, BP_UNDS, KC_TRNS,
  94. KC_TRNS, M_UN, M_CUT, M_CP, M_PS, 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,
  95. 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,
  96. //left pedals
  97. KC_TRNS, KC_BTN1, KC_TRNS,
  98. //right pedals
  99. KC_TRNS, KC_BTN1, KC_TRNS
  100. ),
  101. /* MEDIA, mouse and numpad.
  102. * right pedal is left clic
  103. * ,------. .. ,------. *
  104. * ,------|PAUSE |-------------. .. ,-------------| PRINT|------. *
  105. * ,------|SCROLL|------|MUTE |VOLUD |------. .. ,------| pre | next |------| calc |------. *
  106. * |QK_BOOT |------| stop |------|------|VOLDU | .. | play |------|------| stop |------| num | *
  107. * ,------+------| |------| pre | next |------| .. |------| pre | next |------| |------+------. *
  108. * | | |------|scrolu|------|------| play | .. | play |------|------| 8 |------| - | | *
  109. * |------+------| |------| | bt4 |------| .. |------| next | 7 |------| 9 |------+------| *
  110. * | | |------|scrold|------|------| bt5 | .. | pre |------|------| 5 |------| + | | *
  111. * |------+------| |------|mclic | rclic|------| .. |------| rclic| 4 |------| 6 |------+------| *
  112. * | | |------| |------|------| lclic| .. | lclic|------|------| 2 |------| * | | *
  113. * |------+------| |------| | mclck|------|-------------. .. .-------------|------| mclic| 1 |------| 3 |------+------| *
  114. * | | |------| |------|------| | | | .. | | | |------|------| num. |------| / | | *
  115. * |------+------| |------| | |------|------|------ .. ------|------|------| | 0 |------| . |------+------| *
  116. * | | |------/ \-------------| | | .. | | |-------------/ \------| , | | *
  117. * `-------------/ \-------------/ .. \-------------/ \-------------/ *
  118. *
  119. */
  120. [_MEDIA] = LAYOUT(
  121. QK_BOOT, KC_SCRL, KC_PAUS, KC_MUTE, KC_VOLD, KC_VOLU, KC_MUTE, KC_VOLD, KC_VOLU, KC_PSCR, KC_CALC, KC_NUM,
  122. 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,
  123. 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,
  124. 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,
  125. KC_TRNS, M_UN, M_CUT, M_CP, 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,
  126. 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,
  127. //left pedals
  128. KC_BTN3, M_RP, KC_TRNS,
  129. //right pedals
  130. KC_BTN3, M_RP, KC_TRNS
  131. ),
  132. /* TRNS - skeleton for laters
  133. * ,------. .. ,------. *
  134. * ,------| |-------------. .. ,-------------| |------. *
  135. * ,------| |------| | |------. .. ,------| | |------| |------. *
  136. * | |------| |------|------| | .. | |------|------| |------| | *
  137. * ,------+------| |------| | |------| .. |------| | |------| |------+------. *
  138. * | | |------| |------|------| | .. | |------|------| |------| | | *
  139. * |------+------| |------| | |------| .. |------| | |------| |------+------| *
  140. * | | |------| |------|------| | .. | |------|------| |------| | | *
  141. * |------+------| |------| | |------| .. |------| | |------| |------+------| *
  142. * | | |------| |------|------| | .. | |------|------| |------| | | *
  143. * |------+------| |------| | |------|-------------. .. .-------------|------| | |------| |------+------| *
  144. * | | |------| |------|------| | | | .. | | | |------|------| |------| | | *
  145. * |------+------| |------| | |------|------|------ .. ------|------|------| | |------| |------+------| *
  146. * | | |------/ \-------------| | | .. | | |-------------/ \------| | | *
  147. * `-------------/ \-------------/ .. \-------------/ \-------------/ *
  148. *
  149. */
  150. [_TRNS] = LAYOUT(
  151. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  152. 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,
  153. 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,
  154. 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,
  155. 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,
  156. 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,
  157. //left pedals
  158. KC_BTN3, M_RP, KC_TRNS,
  159. //right pedals
  160. KC_BTN3, M_RP, KC_TRNS
  161. ),
  162. };
  163. void hold_shift(void) {
  164. shift_count = shift_count + 1;
  165. register_code(KC_LSFT);
  166. }
  167. void release_shift(void) {
  168. shift_count = shift_count - 1;
  169. if(shift_count <= 0){
  170. unregister_code(KC_LSFT);
  171. shift_count = 0;
  172. }
  173. }
  174. void press_space(void) {
  175. if(shift_count > 0) unregister_code (KC_LSFT);
  176. tap_code(KC_SPACE);
  177. if(shift_count > 0) register_code (KC_LSFT);
  178. }
  179. void press_enter(void) {
  180. if(shift_count > 0) unregister_code (KC_LSFT);
  181. tap_code (KC_ENT);
  182. if(shift_count > 0) register_code (KC_LSFT);
  183. }
  184. void press_underscore(void) {
  185. if(shift_count > 0) unregister_code (KC_LSFT);
  186. tap_code ((unsigned char) BP_UNDS);
  187. if(shift_count > 0) register_code (KC_LSFT);
  188. }
  189. // Bleah globals need to be initialized.
  190. uint8_t old_layer=_BASE;
  191. void matrix_scan_user(void) {
  192. uint8_t layer = get_highest_layer(layer_state);
  193. frenchdev_led_1_off();
  194. frenchdev_led_2_off();
  195. switch (layer) {
  196. case _BASE:
  197. frenchdev_led_2_on();
  198. break;
  199. case _SYMBOLS:
  200. frenchdev_led_1_on();
  201. break;
  202. case _MEDIA:
  203. frenchdev_led_1_on();
  204. frenchdev_led_2_on();
  205. default:
  206. // none
  207. break;
  208. }
  209. }
  210. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  211. switch(keycode) {
  212. case M_LP: //left pedal
  213. if (record->event.pressed) {
  214. layer_on(1);
  215. register_code (KC_SCRL);
  216. key_timer_left_pedal = timer_read(); // if the key is being pressed, we start the timer.
  217. } else {
  218. if (timer_elapsed(key_timer_left_pedal) < KEY_DELAY) {
  219. tap_code (KC_BTN2);
  220. }
  221. unregister_code (KC_SCRL);
  222. layer_off(1);
  223. }
  224. break;
  225. case M_RP: //right pedal
  226. if (record->event.pressed) {
  227. layer_on(2);
  228. key_timer_right_pedal = timer_read(); // if the key is being pressed, we start the timer.
  229. } else {
  230. if (timer_elapsed(key_timer_right_pedal) < PEDAL_DELAY) {
  231. tap_code (KC_BTN1);
  232. }
  233. layer_off(2);
  234. }
  235. break;
  236. case M_SF: // shift, using macro to keep track of shift state and avoid inserting nbsp by mistake
  237. if (record->event.pressed) {
  238. hold_shift();
  239. } else {
  240. release_shift();
  241. }
  242. break;
  243. case M_SFS: // shift when held, space when tapped
  244. if (record->event.pressed) {
  245. hold_shift();
  246. key_timer_shift = timer_read(); // if the key is being pressed, we start the timer.
  247. } else {
  248. if (timer_elapsed(key_timer_shift) < KEY_DELAY) {
  249. press_space();
  250. }
  251. release_shift();
  252. }
  253. break;
  254. case M_SFU: // shift when held, _ when tapped
  255. if (record->event.pressed) {
  256. hold_shift();
  257. key_timer_shift = timer_read(); // if the key is being pressed, we start the timer.
  258. } else {
  259. if (timer_elapsed(key_timer_shift) < KEY_DELAY) {
  260. press_space();
  261. }
  262. release_shift();
  263. }
  264. break;
  265. case M_L1E: // L1 when held, space when tapped
  266. if (record->event.pressed) {
  267. layer_on(1);
  268. key_timer_1 = timer_read(); // if the key is being pressed, we start the timer.
  269. } else {
  270. if (timer_elapsed(key_timer_1) < KEY_DELAY) {
  271. press_enter();
  272. }
  273. layer_off(1);
  274. }
  275. break;
  276. 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
  277. if (record->event.pressed) {
  278. layer_on(2);
  279. key_timer_2 = timer_read(); // if the key is being pressed, we start the timer.
  280. } else {
  281. if (timer_elapsed(key_timer_2) < KEY_DELAY) {
  282. tap_code (KC_INS);
  283. }
  284. l2_locked = 0;
  285. layer_off(2);
  286. }
  287. break;
  288. case L2LOC: //lock L2
  289. if (record->event.pressed) {
  290. key_timer_2 = timer_read(); // if the key is being pressed, we start the timer.
  291. layer_on(2);
  292. } else {
  293. if (timer_elapsed(key_timer_2) < KEY_DELAY && l2_locked == 0) {
  294. l2_locked = 1;
  295. layer_on(2);
  296. } else {
  297. l2_locked = 0;
  298. layer_off(2);
  299. }
  300. }
  301. break;
  302. case M_UN: // undo
  303. if (record->event.pressed) {
  304. tap_code16(C(BP_Z));
  305. }
  306. break;
  307. case M_CUT: // cut
  308. if (record->event.pressed) {
  309. tap_code16(C(BP_X));
  310. }
  311. break;
  312. case M_CP: // copy
  313. if (record->event.pressed) {
  314. tap_code16(C(BP_C));
  315. }
  316. break;
  317. case M_PS: // paste
  318. if (record->event.pressed) {
  319. tap_code16(C(BP_V));
  320. }
  321. break;
  322. case M_SE: // search
  323. if (record->event.pressed) {
  324. tap_code16(C(BP_F));
  325. }
  326. break;
  327. }
  328. return true;
  329. }
  330. bool led_update_user(led_t led_state) {
  331. if (led_state.caps_lock){
  332. frenchdev_led_3_on();
  333. } else {
  334. frenchdev_led_3_off();
  335. }
  336. return false;
  337. }