keymap.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #include QMK_KEYBOARD_H
  2. #include "arsenik.h"
  3. enum arsenik_layers {
  4. _base,
  5. _lafayette,
  6. _num_row,
  7. _vim_nav,
  8. _num_nav,
  9. _num_pad,
  10. _fun_pad,
  11. };
  12. enum custom_keycodes {
  13. ODK_1 = SAFE_RANGE, // „
  14. ODK_2, // “
  15. ODK_3, // ”
  16. ODK_4, // ¢
  17. ODK_5, // ‰
  18. };
  19. // The ARSENIK_LAYOUT macro allows us to declare a config for a 4x6+3 keyboard, then truncate it
  20. // (or fill it with noops) depending on the size of your keyboard. Your keyboard may have extra
  21. // definitions for this macro or none at all (preventing you from compiling the keymap). Check
  22. // the `README.md` file for more information.
  23. //
  24. // A comprehensive list of QMK keycodes is available here: https://docs.qmk.fm/keycodes
  25. // However, we used a many aliases to automatically adapt the keymap depending on the options you
  26. // enabled in the `config.h` file (or just to have some syntaxic sugar). You can find all of them
  27. // in the `arsenik.h` file. Feel free to remove those aliases and replace them with their actual
  28. // value if you need something Arsenik doesn’t provide.
  29. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  30. [_base] = ARSENIK_LAYOUT(
  31. KC_CAPS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  32. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  33. KC_ESC, KC_A, KC_SS, KC_DD, KC_FF, KC_G, KC_H, KC_JJ, KC_KK, KC_LL, KC_SCLN, KC_ENTER,
  34. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_DOT, KC_COMM, KC_SLSH, KC_RSFT,
  35. AS_TL_TUCK, AS_TL_HOME, AS_TL_REACH, AS_TR_REACH, AS_TR_HOME, AS_TR_TUCK
  36. ),
  37. [_lafayette] = ARSENIK_LAYOUT(
  38. __, AG(KC_1), AG(KC_2), AG(KC_3), AG(KC_4), AG(KC_5), AG(KC_6), AG(KC_7), AG(KC_8), AG(KC_9), AG(KC_0), __,
  39. __, AS(CIRC), AS(LT), AS(GT), AS(DLR), AS(PERC), AS(AT), AS(AMPR), AS(ASTR), AS(QUOT), AS(GRV), __,
  40. __, AS(LCBR), AS(LPRN), AS(LPRN), AS(RCBR), AS(EQL), AS(BSLS), AS(PLUS), AS(MINS), AS(SLSH), AS(DQUO), __,
  41. __, AS(TILD), AS(LBRC), AS(RBRC), AS(UNDS), AS(HASH), AS(PIPE), AS(EXLM), AS(SCLN), AS(COLN), AS(QUES), __,
  42. MO(_num_row), KC_SPC, XX, XX, KC_SPC, MO(_num_row)
  43. ),
  44. // Not fully implemented yet
  45. [_num_row] = ARSENIK_LAYOUT(
  46. __, __, __, __, __, __, __, __, __, __, __, __,
  47. __, AS_S1, AS_S2, AS_S3, AS_S4, AS_S5, AS_S6, AS_S7, AS_S8, AS_S9, AS_S0, __,
  48. __, AS(1), AS(2), AS(3), AS(4), AS(5), AS(6), AS(7), AS(8), AS(9), AS(0), __,
  49. __, ODK_1, ODK_2, ODK_3, ODK_4, ODK_5, XX, AS(MINS), AS(COMM), AS(DOT), AS(SLSH), __,
  50. LAFAYETTE, KC_SPC, XX, XX, KC_SPC, LAFAYETTE
  51. ),
  52. [_vim_nav] = ARSENIK_LAYOUT(
  53. __, G(KC_1), G(KC_2), G(KC_3), G(KC_4), G(KC_5), G(KC_6), G(KC_7), G(KC_8), G(KC_9), G(KC_0), __,
  54. __, MO(_num_nav), C(AS(T)), KC_WBAK, KC_WFWD, XX, KC_HOME, KC_PGDN, KC_PGUP, KC_END, G(AS(P)), __,
  55. __, C(AS(A)), C(AS(S)), S(KC_TAB), KC_TAB, XX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, MO(_fun_pad), __,
  56. __, C(AS(Z)), C(AS(X)), C(AS(C)), C(AS(V)), XX, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, XX, __,
  57. KC_DEL, __, XX, XX, __, KC_ESC
  58. ),
  59. [_num_nav] = ARSENIK_LAYOUT(
  60. __, G(KC_1), G(KC_2), G(KC_3), G(KC_4), G(KC_5), G(KC_6), G(KC_7), G(KC_8), G(KC_9), G(KC_0), __,
  61. __, KC_TAB, KC_HOME, KC_UP, KC_END, KC_PGUP, AS(SLSH), AS(7), AS(8), AS(9), G(AS(P)), __,
  62. __, C(AS(A)), KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, AS(MINS), AS(4), AS(5), AS(6), AS(0), __,
  63. __, C(AS(Z)), C(AS(X)), C(AS(C)), C(AS(V)), S(KC_TAB), AS(COMM), AS(1), AS(2), AS(3), AS(DOT), __,
  64. KC_DEL, __, XX, XX, __, KC_ESC
  65. ),
  66. [_fun_pad] = ARSENIK_LAYOUT(
  67. __, __, __, __, __, __, __, __, __, __, __, __,
  68. __, KC_F1, KC_F2, KC_F3, KC_F4, XX, XX, XX, XX, XX, XX, __,
  69. __, KC_F5, KC_F6, KC_F7, KC_F8, XX, XX, KC_LCTL, KC_LALT, KC_LGUI, __, __,
  70. __, KC_F9, KC_F10, KC_F11, KC_F12, XX, XX, XX, XX, XX, XX, __,
  71. LAFAYETTE, KC_SPC, XX, XX, KC_SPC, LAFAYETTE
  72. ),
  73. };
  74. // This is where you’ll write most of your custom code for your keyborad.
  75. // This callback is called right before the keycode is sent to the OS.
  76. //
  77. // returning false cancels any furnther processing.
  78. // for instance, calling `tap_code(KC_B)` if KC_A is pressed but true is
  79. // returned, "ba" is sent, but if `false` is returned, it’s just "b"
  80. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  81. # ifdef SELENIUM_RESTORE_SPACE
  82. static bool thumb_mod_same_hand_as_space_held = false;
  83. if ((keycode & 0xff) == KC_SPC && record->tap.count == 0)
  84. thumb_mod_same_hand_as_space_held = record->event.pressed;
  85. # endif
  86. // Let QMK do its thing on key releases.
  87. if (!record->event.pressed) return true;
  88. # ifdef SELENIUM_RESTORE_SPACE
  89. if ((keycode & 0xff) == KC_BSPC &&
  90. !thumb_mod_same_hand_as_space_held &&
  91. record->tap.count > 0
  92. ) {
  93. tap_code(KC_SPC);
  94. return false;
  95. }
  96. # endif
  97. switch (keycode) {
  98. // ----------------------------------------
  99. // Code for your custom keycodes goes here.
  100. // ----------------------------------------
  101. case ODK_1: ODK1_SEQUENCE; return false;
  102. case ODK_2: ODK2_SEQUENCE; return false;
  103. case ODK_3: ODK3_SEQUENCE; return false;
  104. case ODK_4: ODK4_SEQUENCE; return false;
  105. case ODK_5: ODK5_SEQUENCE; return false;
  106. }
  107. return true;
  108. }
  109. static inline bool tap_keycode_used_in_text(uint16_t keycode) {
  110. // We can’t make assumptions on curstom keycodes
  111. if (keycode >= SAFE_RANGE) return false;
  112. // Remove "quantum" part of the keycode to get the action on tap.
  113. const uint16_t tap_keycode = keycode & 0xff;
  114. // `tap_keycode <= KC_0` includes all letters and numbers, but also
  115. // `KC_NO` which is safer to include, since it is commonly used in the
  116. // keymap as a placeholder for complex actions on tap.
  117. return (tap_keycode <= KC_0) || (tap_keycode == KC_SPACE);
  118. }
  119. uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
  120. return tap_keycode_used_in_text(keycode) ? ARSENIK_HRM_TAPPING_TERM : TAPPING_TERM;
  121. }
  122. bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
  123. return !tap_keycode_used_in_text(keycode);
  124. }