keymap.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #include QMK_KEYBOARD_H
  2. enum alt_keycodes {
  3. L_BRI = SAFE_RANGE, //LED Brightness Increase //Working
  4. L_BRD, //LED Brightness Decrease //Working
  5. L_PTN, //LED Pattern Select Next //Working
  6. L_PTP, //LED Pattern Select Previous //Working
  7. L_PSI, //LED Pattern Speed Increase //Working
  8. L_PSD, //LED Pattern Speed Decrease //Working
  9. L_T_MD, //LED Toggle Mode //Working
  10. L_T_ONF, //LED Toggle On / Off //Broken
  11. L_ON, //LED On //Broken
  12. L_OFF, //LED Off //Broken
  13. L_T_BR, //LED Toggle Breath Effect //Working
  14. L_T_PTD, //LED Toggle Scrolling Pattern Direction //Working
  15. U_T_AGCR, //USB Toggle Automatic GCR control //Working
  16. DBG_TOG, //DEBUG Toggle On / Off //
  17. DBG_MTRX, //DEBUG Toggle Matrix Prints //
  18. DBG_KBD, //DEBUG Toggle Keyboard Prints //
  19. DBG_MOU, //DEBUG Toggle Mouse Prints //
  20. MD_BOOT //Restart into bootloader after hold timeout //Working
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. [0] = LAYOUT(
  24. KC_ESC, 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_BSPC, KC_DEL, \
  25. 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_BSLS, KC_HOME, \
  26. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \
  27. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, \
  28. KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_LEFT, KC_DOWN, KC_RGHT \
  29. ),
  30. [1] = LAYOUT(
  31. KC_GRV, 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_MUTE, \
  32. L_T_BR, L_PSD, L_BRI, L_PSI, _______, _______, _______, _______, U_T_AGCR,_______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_END, \
  33. L_T_PTD, L_PTP, L_BRD, L_PTN, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, \
  34. _______, L_T_MD, L_T_ONF, _______, _______, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, KC_PGUP, KC_VOLD, \
  35. _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_END \
  36. ),
  37. /*
  38. [X] = LAYOUT(
  39. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  40. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  41. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  42. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  43. _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  44. ),
  45. */
  46. };
  47. #define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSHIFT) || get_mods() & MOD_BIT(KC_RSHIFT))
  48. #define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTRL))
  49. #define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
  50. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  51. static uint32_t key_timer;
  52. switch (keycode) {
  53. case L_BRI:
  54. if (record->event.pressed) {
  55. if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX;
  56. else gcr_desired += LED_GCR_STEP;
  57. if (led_animation_breathing) gcr_breathe = gcr_desired;
  58. }
  59. return false;
  60. case L_BRD:
  61. if (record->event.pressed) {
  62. if (LED_GCR_STEP > gcr_desired) gcr_desired = 0;
  63. else gcr_desired -= LED_GCR_STEP;
  64. if (led_animation_breathing) gcr_breathe = gcr_desired;
  65. }
  66. return false;
  67. case L_PTN:
  68. if (record->event.pressed) {
  69. if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
  70. else led_animation_id++;
  71. }
  72. return false;
  73. case L_PTP:
  74. if (record->event.pressed) {
  75. if (led_animation_id == 0) led_animation_id = led_setups_count - 1;
  76. else led_animation_id--;
  77. }
  78. return false;
  79. case L_PSI:
  80. if (record->event.pressed) {
  81. led_animation_speed += ANIMATION_SPEED_STEP;
  82. }
  83. return false;
  84. case L_PSD:
  85. if (record->event.pressed) {
  86. led_animation_speed -= ANIMATION_SPEED_STEP;
  87. if (led_animation_speed < 0) led_animation_speed = 0;
  88. }
  89. return false;
  90. case L_T_MD:
  91. if (record->event.pressed) {
  92. led_lighting_mode++;
  93. if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL;
  94. }
  95. return false;
  96. case L_T_ONF:
  97. if (record->event.pressed) {
  98. led_enabled = !led_enabled;
  99. I2C3733_Control_Set(led_enabled);
  100. }
  101. return false;
  102. case L_ON:
  103. if (record->event.pressed) {
  104. led_enabled = 1;
  105. I2C3733_Control_Set(led_enabled);
  106. }
  107. return false;
  108. case L_OFF:
  109. if (record->event.pressed) {
  110. led_enabled = 0;
  111. I2C3733_Control_Set(led_enabled);
  112. }
  113. return false;
  114. case L_T_BR:
  115. if (record->event.pressed) {
  116. led_animation_breathing = !led_animation_breathing;
  117. if (led_animation_breathing) {
  118. gcr_breathe = gcr_desired;
  119. led_animation_breathe_cur = BREATHE_MIN_STEP;
  120. breathe_dir = 1;
  121. }
  122. }
  123. return false;
  124. case L_T_PTD:
  125. if (record->event.pressed) {
  126. led_animation_direction = !led_animation_direction;
  127. }
  128. return false;
  129. case U_T_AGCR:
  130. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  131. TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
  132. }
  133. return false;
  134. case DBG_TOG:
  135. if (record->event.pressed) {
  136. TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
  137. }
  138. return false;
  139. case DBG_MTRX:
  140. if (record->event.pressed) {
  141. TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
  142. }
  143. return false;
  144. case DBG_KBD:
  145. if (record->event.pressed) {
  146. TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
  147. }
  148. return false;
  149. case DBG_MOU:
  150. if (record->event.pressed) {
  151. TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
  152. }
  153. return false;
  154. case MD_BOOT:
  155. if (record->event.pressed) {
  156. key_timer = timer_read32();
  157. } else {
  158. if (timer_elapsed32(key_timer) >= 500) {
  159. reset_keyboard();
  160. }
  161. }
  162. return false;
  163. default:
  164. return true; //Process all other keycodes normally
  165. }
  166. }
  167. led_instruction_t led_instructions[] = {
  168. //Please see ../default_md/keymap.c for examples
  169. //All LEDs use the user's selected pattern (this is the factory default)
  170. { .flags = LED_FLAG_USE_ROTATE_PATTERN },
  171. //end must be set to 1 to indicate end of instruction set
  172. { .end = 1 }
  173. };