keymap.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* -*- eval: (turn-on-orgtbl); -*-
  2. * default HHKB Layout
  3. */
  4. #include QMK_KEYBOARD_H
  5. #define BASE 0
  6. #define HHKB 1
  7. #define FUNK 2
  8. #define DYN 3
  9. #define CTL_ESC CTL_T(KC_ESC)
  10. #define MACSLEEP LCTL(LSFT(KC_POWER))
  11. enum hhkb_keycodes
  12. {
  13. QWERTY = SAFE_RANGE,
  14. DYNKEY,
  15. DYNAMIC_MACRO_RANGE,
  16. };
  17. #include "dynamic_macro.h"
  18. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  19. /* BASE Level: Default Layer
  20. |-------+---+---+---+---+---+---+---+---+---+---+-------+-----+-------+---|
  21. | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` |
  22. |-------+---+---+---+---+---+---+---+---+---+---+-------+-----+-------+---|
  23. | Tab | Q | W | E | R | T | Y | U | I | O | P | [ | ] | Backs | |
  24. |-------+---+---+---+---+---+---+---+---+---+---+-------+-----+-------+---|
  25. | Cont | A | S | D | F | G | H | J | K | L | ; | ' | Ent | | |
  26. |-------+---+---+---+---+---+---+---+---+---+---+-------+-----+-------+---|
  27. | Shift | Z | X | C | V | B | N | M | , | . | / | Shift | Fn0 | | |
  28. |-------+---+---+---+---+---+---+---+---+---+---+-------+-----+-------+---|
  29. |------+------+-----------------------+------+------|
  30. | LAlt | LGUI | ******* Space ******* | RGUI | RAlt |
  31. |------+------+-----------------------+------+------|
  32. */
  33. [BASE] = LAYOUT( // default layer
  34. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_DEL,
  35. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC,
  36. CTL_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
  37. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT), TT(FUNK),
  38. KC_LALT, KC_LGUI, /* */ KC_SPC, MO(DYN), KC_RALT),
  39. /* Layer HHKB: HHKB mode (HHKB Fn)
  40. |------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
  41. | Pwr | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | Ins | Del |
  42. |------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
  43. | Caps | | | | | | | | Psc | Slk | Pus | Up | | Backs | |
  44. |------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
  45. | | VoD | VoU | Mut | | | * | / | Hom | PgU | Lef | Rig | Enter | | |
  46. |------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
  47. | | | | | | | + | - | End | PgD | Dow | | | | |
  48. |------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
  49. |------+------+----------------------+------+------+
  50. | **** | **** | ******************** | **** | **** |
  51. |------+------+----------------------+------+------+
  52. [HHKB] = LAYOUT(
  53. KC_PWR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
  54. KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \
  55. KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \
  56. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \
  57. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
  58. */
  59. [FUNK] = LAYOUT(
  60. KC_PWR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL,
  61. KC_CAPS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC,
  62. KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT,
  63. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS,
  64. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
  65. [DYN] = LAYOUT(
  66. KC_TRNS, DYN_REC_START1, DYN_REC_START2, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, DYN_MACRO_PLAY1, DYN_MACRO_PLAY2,
  67. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, KC_TRNS,
  68. KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MACSLEEP, KC_HOME, KC_END, KC_TRNS,
  69. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGDN, KC_TRNS, KC_TRNS,
  70. KC_TRNS, KC_TRNS, DYN_REC_STOP, KC_TRNS, KC_TRNS)};
  71. const uint16_t PROGMEM fn_actions[] = {
  72. };
  73. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  74. {
  75. // MACRODOWN only works in this function
  76. switch (id)
  77. {
  78. case 0:
  79. if (record->event.pressed)
  80. {
  81. register_code(KC_RSFT);
  82. }
  83. else
  84. {
  85. unregister_code(KC_RSFT);
  86. }
  87. break;
  88. }
  89. return MACRO_NONE;
  90. };
  91. bool process_record_user(uint16_t keycode, keyrecord_t *record)
  92. {
  93. uint16_t macro_kc = (keycode == MO(DYN) ? DYN_REC_STOP : keycode);
  94. if (!process_record_dynamic_macro(macro_kc, record))
  95. {
  96. return false;
  97. }
  98. return true;
  99. }