keymap.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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_EDG_I, //LED Edge Brightness Increase
  6. L_EDG_D, //LED Edge Brightness Decrease
  7. L_EDG_M, //LED Edge lighting mode
  8. L_PTN, //LED Pattern Select Next //Working
  9. L_PTP, //LED Pattern Select Previous //Working
  10. L_PSI, //LED Pattern Speed Increase //Working
  11. L_PSD, //LED Pattern Speed Decrease //Working
  12. L_RATIOD,
  13. L_RATIOI,
  14. L_T_MD, //LED Toggle Mode //Working
  15. L_T_ONF, //LED Toggle On / Off //Broken
  16. L_ON, //LED On //Broken
  17. L_OFF, //LED Off //Broken
  18. L_T_BR, //LED Toggle Breath Effect //Working
  19. L_T_PTD, //LED Toggle Scrolling Pattern Direction //Working
  20. U_T_AGCR, //USB Toggle Automatic GCR control //Working
  21. DBG_TOG, //DEBUG Toggle On / Off //
  22. DBG_MTRX, //DEBUG Toggle Matrix Prints //
  23. DBG_KBD, //DEBUG Toggle Keyboard Prints //
  24. DBG_MOU, //DEBUG Toggle Mouse Prints //
  25. DBG_FAC, //DEBUG Factory light testing (All on white)
  26. MD_BOOT //Restart into bootloader after hold timeout //Working
  27. };
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. [0] = LAYOUT(
  30. 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,
  31. 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,
  32. 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,
  33. 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,
  34. KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_LEFT, KC_DOWN, KC_RGHT
  35. ),
  36. [1] = LAYOUT(
  37. 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,
  38. L_T_BR, L_PSD, L_BRI, L_PSI, L_EDG_I, _______, _______, _______, U_T_AGCR,_______, KC_PSCR, KC_SCRL, KC_PAUS, _______, KC_END,
  39. L_T_PTD, L_PTP, L_BRD, L_PTN, L_EDG_D, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU,
  40. _______, L_T_MD, L_T_ONF, _______, L_EDG_M, MD_BOOT, NK_TOGG, _______, _______, _______, _______, _______, KC_PGUP, KC_VOLD,
  41. _______, _______, _______, DBG_FAC, _______, _______, KC_HOME, KC_PGDN, KC_END
  42. ),
  43. /*
  44. [X] = LAYOUT(
  45. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  46. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  47. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  48. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  49. _______, _______, _______, _______, _______, _______, _______, _______, _______
  50. ),
  51. */
  52. };
  53. #define MODS_SHIFT (get_mods() & MOD_BIT(KC_LSFT) || get_mods() & MOD_BIT(KC_RSFT))
  54. #define MODS_CTRL (get_mods() & MOD_BIT(KC_LCTL) || get_mods() & MOD_BIT(KC_RCTL))
  55. #define MODS_ALT (get_mods() & MOD_BIT(KC_LALT) || get_mods() & MOD_BIT(KC_RALT))
  56. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  57. static uint32_t key_timer;
  58. static uint8_t scroll_effect = 0;
  59. switch (keycode) {
  60. case L_BRI:
  61. if (record->event.pressed) {
  62. if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX;
  63. else gcr_desired += LED_GCR_STEP;
  64. if (led_animation_breathing) gcr_breathe = gcr_desired;
  65. }
  66. return false;
  67. case L_BRD:
  68. if (record->event.pressed) {
  69. if (LED_GCR_STEP > gcr_desired) gcr_desired = 0;
  70. else gcr_desired -= LED_GCR_STEP;
  71. if (led_animation_breathing) gcr_breathe = gcr_desired;
  72. }
  73. return false;
  74. case L_EDG_M:
  75. if (record->event.pressed) {
  76. led_edge_mode++;
  77. if (led_edge_mode > LED_EDGE_MODE_MAX) {
  78. led_edge_mode = LED_EDGE_MODE_ALL;
  79. }
  80. }
  81. return false;
  82. case L_EDG_I:
  83. if (record->event.pressed) {
  84. led_edge_brightness += 0.1;
  85. if (led_edge_brightness > 1) { led_edge_brightness = 1; }
  86. }
  87. return false;
  88. case L_EDG_D:
  89. if (record->event.pressed) {
  90. led_edge_brightness -= 0.1;
  91. if (led_edge_brightness < 0) { led_edge_brightness = 0; }
  92. }
  93. return false;
  94. case L_RATIOI:
  95. if (record->event.pressed) {
  96. led_ratio_brightness += 0.2;
  97. if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
  98. }
  99. return false;
  100. case L_RATIOD:
  101. if (record->event.pressed) {
  102. led_ratio_brightness -= 0.2;
  103. if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
  104. }
  105. return false;
  106. case L_PTN:
  107. if (record->event.pressed) {
  108. if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
  109. else led_animation_id++;
  110. }
  111. return false;
  112. case L_PTP:
  113. if (record->event.pressed) {
  114. if (led_animation_id == 0) led_animation_id = led_setups_count - 1;
  115. else led_animation_id--;
  116. }
  117. return false;
  118. case L_PSI:
  119. if (record->event.pressed) {
  120. led_animation_speed += ANIMATION_SPEED_STEP;
  121. }
  122. return false;
  123. case L_PSD:
  124. if (record->event.pressed) {
  125. led_animation_speed -= ANIMATION_SPEED_STEP;
  126. if (led_animation_speed < 0) led_animation_speed = 0;
  127. }
  128. return false;
  129. case L_T_MD:
  130. if (record->event.pressed) {
  131. led_lighting_mode++;
  132. if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL;
  133. }
  134. return false;
  135. case L_T_ONF:
  136. if (record->event.pressed) {
  137. led_enabled = !led_enabled;
  138. I2C3733_Control_Set(led_enabled);
  139. }
  140. return false;
  141. case L_ON:
  142. if (record->event.pressed) {
  143. led_enabled = 1;
  144. I2C3733_Control_Set(led_enabled);
  145. }
  146. return false;
  147. case L_OFF:
  148. if (record->event.pressed) {
  149. led_enabled = 0;
  150. I2C3733_Control_Set(led_enabled);
  151. }
  152. return false;
  153. case L_T_BR:
  154. if (record->event.pressed) {
  155. led_animation_breathing = !led_animation_breathing;
  156. if (led_animation_breathing) {
  157. gcr_breathe = gcr_desired;
  158. led_animation_breathe_cur = BREATHE_MIN_STEP;
  159. breathe_dir = 1;
  160. }
  161. }
  162. return false;
  163. case L_T_PTD:
  164. if (record->event.pressed) {
  165. scroll_effect++;
  166. if (scroll_effect == 1) { //Patterns with scroll move horizontal (Right to left)
  167. led_animation_direction = 1;
  168. led_animation_orientation = 0;
  169. led_animation_circular = 0;
  170. } else if (scroll_effect == 2) { //Patterns with scroll move vertical (Top to bottom)
  171. led_animation_direction = 1;
  172. led_animation_orientation = 1;
  173. led_animation_circular = 0;
  174. } else if (scroll_effect == 3) { //Patterns with scroll move vertical (Bottom to top)
  175. led_animation_direction = 0;
  176. led_animation_orientation = 1;
  177. led_animation_circular = 0;
  178. } else if (scroll_effect == 4) { //Patterns with scroll explode from center
  179. led_animation_direction = 0;
  180. led_animation_orientation = 0;
  181. led_animation_circular = 1;
  182. } else if (scroll_effect == 5) { //Patterns with scroll implode on center
  183. led_animation_direction = 1;
  184. led_animation_orientation = 0;
  185. led_animation_circular = 1;
  186. } else { //Patterns with scroll move horizontal (Left to right)
  187. scroll_effect = 0;
  188. led_animation_direction = 0;
  189. led_animation_orientation = 0;
  190. led_animation_circular = 0;
  191. }
  192. }
  193. return false;
  194. case U_T_AGCR:
  195. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  196. TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
  197. }
  198. return false;
  199. case DBG_FAC:
  200. if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
  201. led_lighting_mode = LED_MODE_NORMAL;
  202. led_edge_brightness = 1;
  203. led_edge_mode = LED_EDGE_MODE_ALL;
  204. led_animation_breathing = 0;
  205. led_animation_id = 7; //led_programs.c led_setups leds_white index
  206. gcr_desired = LED_GCR_MAX;
  207. led_enabled = 1;
  208. I2C3733_Control_Set(led_enabled);
  209. }
  210. return false;
  211. case DBG_TOG:
  212. if (record->event.pressed) {
  213. TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
  214. }
  215. return false;
  216. case DBG_MTRX:
  217. if (record->event.pressed) {
  218. TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
  219. }
  220. return false;
  221. case DBG_KBD:
  222. if (record->event.pressed) {
  223. TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
  224. }
  225. return false;
  226. case DBG_MOU:
  227. if (record->event.pressed) {
  228. TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
  229. }
  230. return false;
  231. case MD_BOOT:
  232. if (record->event.pressed) {
  233. key_timer = timer_read32();
  234. } else {
  235. if (timer_elapsed32(key_timer) >= 500) {
  236. reset_keyboard();
  237. }
  238. }
  239. return false;
  240. default:
  241. return true; //Process all other keycodes normally
  242. }
  243. }
  244. led_instruction_t led_instructions[] = {
  245. //Please see ../default_md/keymap.c for examples
  246. //All LEDs use the user's selected pattern (this is the factory default)
  247. { .flags = LED_FLAG_USE_ROTATE_PATTERN },
  248. //end must be set to 1 to indicate end of instruction set
  249. { .end = 1 }
  250. };