keymap.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #include "jd40.h"
  2. #include "action_layer.h"
  3. #define _BL 0
  4. #define _AL 1
  5. #define _FL 2
  6. #define _UL 3
  7. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  8. [_BL] = KEYMAP(
  9. F12, Q, W, E, R, T, Y, U, I, O, P, BSPC,
  10. TAB, A, S, D, F, G, H, J, K, L, ENT,
  11. LSFT, Z, X, C, V, B, N, M, COMM, UP, DOT,
  12. LCTL, LGUI, LALT, FN0, SPC, SPC, FN0, LEFT, DOWN, RIGHT ),
  13. [_AL] = KEYMAP(
  14. GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, DEL,
  15. CAPS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
  16. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, SCLN, PGUP, QUOT,
  17. TRNS, TRNS, TRNS, TRNS, FN3, FN3, TRNS, HOME, PGDN, END ),
  18. [_FL] = KEYMAP(
  19. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  20. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  21. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  22. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
  23. [_UL] = KEYMAP(
  24. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  25. TRNS, FN4, FN5, FN11, FN10, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  26. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
  27. TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
  28. };
  29. enum function_id {
  30. RGBLED_TOGGLE,
  31. RGBLED_STEP_MODE,
  32. RGBLED_INCREASE_HUE,
  33. RGBLED_DECREASE_HUE,
  34. RGBLED_INCREASE_SAT,
  35. RGBLED_DECREASE_SAT,
  36. RGBLED_INCREASE_VAL,
  37. RGBLED_DECREASE_VAL,
  38. SHIFT_ESC,
  39. };
  40. const uint16_t PROGMEM fn_actions[] = {
  41. [0] = ACTION_LAYER_MOMENTARY(1), // Momentary Fn overlay
  42. [1] = ACTION_LAYER_TOGGLE(2), // Toggle Arrow Layer overlay
  43. [2] = ACTION_LAYER_TAP_KEY(2, KC_CAPS), // Tap to toggle caps lock and hold to activate function layer
  44. [3] = ACTION_LAYER_TOGGLE(3), // Toggle Underglow Layer overlay
  45. [4] = ACTION_FUNCTION(RGBLED_TOGGLE), //Turn on/off underglow
  46. [5] = ACTION_FUNCTION(RGBLED_STEP_MODE), // Change underglow mode
  47. [6] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
  48. [7] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
  49. [8] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
  50. [9] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
  51. [10] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
  52. [11] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
  53. [12] = ACTION_FUNCTION(SHIFT_ESC),
  54. };
  55. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  56. {
  57. // MACRODOWN only works in this function
  58. switch(id) {
  59. case 0:
  60. if (record->event.pressed) {
  61. register_code(KC_RSFT);
  62. } else {
  63. unregister_code(KC_RSFT);
  64. }
  65. break;
  66. }
  67. return MACRO_NONE;
  68. };
  69. void matrix_scan_user(void) {
  70. // Layer LED indicators
  71. // ESC led on when in function layer, WASD cluster leds enabled when on arrow cluster
  72. uint32_t layer = layer_state;
  73. if (layer & (1<<1)) {
  74. //gh60_wasd_leds_on();
  75. } else {
  76. //gh60_wasd_leds_off();
  77. }
  78. if (layer & (1<<2)) {
  79. //gh60_esc_led_on();
  80. } else {
  81. //gh60_esc_led_off();
  82. }
  83. };
  84. #define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
  85. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  86. switch (id) {
  87. case RGBLED_TOGGLE:
  88. //led operations
  89. if (record->event.pressed) {
  90. rgblight_toggle();
  91. }
  92. break;
  93. case RGBLED_INCREASE_HUE:
  94. if (record->event.pressed) {
  95. rgblight_increase_hue();
  96. }
  97. break;
  98. case RGBLED_DECREASE_HUE:
  99. if (record->event.pressed) {
  100. rgblight_decrease_hue();
  101. }
  102. break;
  103. case RGBLED_INCREASE_SAT:
  104. if (record->event.pressed) {
  105. rgblight_increase_sat();
  106. }
  107. break;
  108. case RGBLED_DECREASE_SAT:
  109. if (record->event.pressed) {
  110. rgblight_decrease_sat();
  111. }
  112. break;
  113. case RGBLED_INCREASE_VAL:
  114. if (record->event.pressed) {
  115. rgblight_increase_val();
  116. }
  117. break;
  118. case RGBLED_DECREASE_VAL:
  119. if (record->event.pressed) {
  120. rgblight_decrease_val();
  121. }
  122. break;
  123. case RGBLED_STEP_MODE:
  124. if (record->event.pressed) {
  125. rgblight_step();
  126. }
  127. break;
  128. static uint8_t shift_esc_shift_mask;
  129. // Shift + ESC = ~
  130. case SHIFT_ESC:
  131. shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
  132. if (record->event.pressed) {
  133. if (shift_esc_shift_mask) {
  134. add_key(KC_GRV);
  135. send_keyboard_report();
  136. } else {
  137. add_key(KC_ESC);
  138. send_keyboard_report();
  139. }
  140. } else {
  141. if (shift_esc_shift_mask) {
  142. del_key(KC_GRV);
  143. send_keyboard_report();
  144. } else {
  145. del_key(KC_ESC);
  146. send_keyboard_report();
  147. }
  148. }
  149. break;
  150. }
  151. };