logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (3809B)


  1. /* Copyright 2020 sotoba
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. // Defines names for use in layer keycodes and the keymap
  18. enum layer_names {
  19. _BASE,
  20. _UNRULY,
  21. _FUNCTION
  22. };
  23. // Defines the keycodes used by our macros in process_record_user
  24. enum custom_keycodes {
  25. DOUBLE_ZERO = SAFE_RANGE
  26. };
  27. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  28. /* Base */
  29. [_BASE] = LAYOUT(
  30. KC_ESCAPE, KC_LSFT, KC_TAB, KC_BSPC,
  31. KC_NUM, KC_KP_SLASH, KC_KP_ASTERISK, KC_EQUAL,
  32. KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_MINUS,
  33. MO(_FUNCTION), KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS,
  34. UG_TOGG, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_ENTER,
  35. TG(_UNRULY), KC_KP_0, DOUBLE_ZERO, KC_KP_DOT
  36. ),
  37. /* Lightning */
  38. [_UNRULY] = LAYOUT(
  39. KC_ESCAPE, KC_LSFT, KC_TAB, KC_BSPC,
  40. KC_NUM, KC_KP_SLASH, KC_KP_ASTERISK, KC_EQUAL,
  41. KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_MINUS,
  42. KC_TRNS, KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_PLUS,
  43. KC_TRNS, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_ENTER,
  44. KC_TRNS, KC_KP_0, DOUBLE_ZERO, KC_KP_DOT
  45. ),
  46. /* Function */
  47. [_FUNCTION] = LAYOUT(
  48. QK_BOOT, KC_NO, KC_NO, KC_NO,
  49. KC_NO, KC_NO, KC_NO, KC_NO,
  50. KC_NO, KC_NO, KC_NO, KC_NO,
  51. KC_TRNS, UG_PREV, UG_NEXT, KC_NO, KC_NO,
  52. KC_TRNS, UG_HUEU, UG_SATU, UG_VALU, KC_NO,
  53. KC_TRNS, UG_HUED, UG_SATD, UG_VALD
  54. )
  55. };
  56. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  57. switch (keycode) {
  58. case DOUBLE_ZERO:
  59. if (record->event.pressed) {
  60. // when keycode DOUBLE_ZERO is pressed
  61. SEND_STRING("00");
  62. }
  63. break;
  64. }
  65. return true;
  66. }
  67. #ifdef RGBLIGHT_LAYERS
  68. const rgblight_segment_t PROGMEM num_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  69. {26, 7, HSV_SPRINGGREEN}
  70. );
  71. const rgblight_segment_t PROGMEM unruly_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  72. {0, 4, HSV_OFF},
  73. {4, 2, HSV_WHITE},
  74. {6, 2, HSV_PURPLE},
  75. {8, 2, HSV_RED},
  76. {10, 2, HSV_BLUE},
  77. {12, 2, HSV_YELLOW},
  78. {14, 2, HSV_GREEN},
  79. {16, 3, HSV_ORANGE},
  80. {19, 1, HSV_OFF},
  81. {20, 3, HSV_PINK},
  82. {23, 10, HSV_GREEN}
  83. );
  84. const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  85. num_layer,
  86. unruly_layer
  87. );
  88. void keyboard_post_init_user(void) {
  89. // Enable the LED layers
  90. rgblight_layers = rgb_layers;
  91. }
  92. layer_state_t layer_state_set_user(layer_state_t state) {
  93. rgblight_set_layer_state(1, layer_state_cmp(state, _UNRULY));
  94. return state;
  95. }
  96. bool led_update_user(led_t led_state) {
  97. rgblight_set_layer_state(0, led_state.num_lock);
  98. return true;
  99. }
  100. #endif