keymap.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. Base Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
  3. Modified 2017 Andrew Novak <ndrw.nvk@gmail.com>
  4. Modified 2018 Wayne Jones (WarmCatUK) <waynekjones@gmail.com>
  5. Modified 2019 AbstractKB
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public LicensezZZ
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include QMK_KEYBOARD_H
  18. enum layers {
  19. _DEFLT,
  20. _RAISE,
  21. _LOWER,
  22. _FN
  23. };
  24. enum custom_keycodes {
  25. MYRGB_TG = SAFE_RANGE
  26. };
  27. bool rgbinit = true;
  28. bool rgbon = true;
  29. const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {1,5,5}; //only using the first one
  30. void keyboard_post_init_user(void) {
  31. rgblight_enable_noeeprom();
  32. led_set_user(host_keyboard_leds());
  33. }
  34. uint32_t layer_state_set_user(uint32_t state) {
  35. switch (biton32(state)) {
  36. case _RAISE:
  37. rgblight_sethsv_noeeprom(240,255,255);
  38. rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
  39. break;
  40. case _LOWER:
  41. rgblight_sethsv_noeeprom(0,255,255);
  42. rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
  43. break;
  44. case _FN:
  45. rgblight_sethsv_noeeprom(0,255,255);
  46. rgblight_mode_noeeprom(RGBLIGHT_MODE_RAINBOW_SWIRL);
  47. break;
  48. default: //_DEFLT
  49. rgblight_sethsv_noeeprom(0,0,255);
  50. rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
  51. break;
  52. }
  53. return state;
  54. }
  55. void led_set_user(uint8_t usb_led) {
  56. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  57. rgblight_mode_noeeprom(RGBLIGHT_MODE_ALTERNATING);
  58. } else {
  59. layer_state_set_user(layer_state);
  60. }
  61. }
  62. void myrgb_toggle(void) {
  63. if (rgbon) {
  64. rgblight_disable_noeeprom();
  65. rgbon = false;
  66. } else {
  67. rgblight_enable_noeeprom();
  68. layer_state_set_user(layer_state);
  69. led_set_user(host_keyboard_leds());
  70. rgbon = true;
  71. }
  72. }
  73. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  74. switch(keycode) {
  75. case MYRGB_TG:
  76. if (record->event.pressed) {
  77. myrgb_toggle();
  78. }
  79. return false;
  80. default:
  81. return true;
  82. }
  83. }
  84. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  85. [_DEFLT] = LAYOUT( \
  86. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  87. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_ENT, \
  88. KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  89. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, \
  90. MO(_FN), KC_LCTL, KC_LGUI, KC_LALT, MO(_LOWER),KC_SPC,KC_SPC,MO(_RAISE),KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  91. ),
  92. [_RAISE] = LAYOUT( \
  93. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  94. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  95. _______, _______, _______, _______, _______, _______, _______, _______, LCTL(LGUI(KC_LEFT)), LGUI(KC_L), LCTL(LGUI(KC_RGHT)), _______, \
  96. _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, KC_CAPS, _______, \
  97. _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY \
  98. ),
  99. [_LOWER] = LAYOUT( \
  100. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  101. _______, KC_GRV, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_BSLS, _______, \
  102. _______, _______, _______, KC_LBRC, KC_RBRC, S(KC_9),S(KC_0),S(KC_LBRC),S(KC_RBRC),_______,_______,_______, \
  103. _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \
  104. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  105. ),
  106. [_FN] = LAYOUT( \
  107. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, \
  108. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  109. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  110. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  111. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, MYRGB_TG \
  112. )
  113. };