You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

402 lines
20 KiB

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