keymap.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Copyright 2017 Wunder
  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. // Layer shorthand
  18. #define _QW 0
  19. #define _FN 1
  20. enum my_kc {
  21. A_BL_TG = SAFE_RANGE
  22. // , A_BL_Y
  23. // , A_BL_N
  24. };
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* QWERTY
  27. * .--------------------------------------------------------------------------------------------------------------------------------------.
  28. * | ESC | 1 | 2 | 3 | 4 | 5 | - | ` | = | 6 | 7 | 8 | 9 | 0 | BSPC |
  29. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
  30. * | TAB | Q | W | E | R | T | [ | ] | \ | Y | U | I | O | P | ' |
  31. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------|
  32. * | CAP LK | A | S | D | F | G | UP | DEL | DOWN | H | J | K | L | ; | ENTER |
  33. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------|
  34. * | LSHIFT | Z | X | C | V | B | HOME | PG UP | END | N | M | , | . | / | RSHIFT |
  35. * |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------|
  36. * | LCTRL | FN | LGUI | LALT | SPACE | SPACE | FN | PG DN | FN | BSPC | BSPC | RALT | RGUI | FN | RCTRL |
  37. * '--------------------------------------------------------------------------------------------------------------------------------------'
  38. */
  39. [_QW] = { /* QWERTY */
  40. { KC_ESC , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_MINS, KC_GRV , KC_EQL , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_BSPC },
  41. { KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_LBRC, KC_RBRC, KC_BSLS, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_QUOT },
  42. { KC_CAPS, KC_A , KC_S , KC_D , KC_F , KC_G , KC_UP , KC_DEL , KC_DOWN, KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_ENT },
  43. { KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_HOME, KC_PGUP, KC_END , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT },
  44. { KC_LCTL, TT(_FN), KC_LGUI, KC_LALT, KC_SPC , KC_SPC , TT(_FN), KC_PGDN, TT(_FN), KC_BSPC, KC_BSPC, KC_RALT, KC_RGUI, TT(_FN), KC_RCTL },
  45. },
  46. /* FUNCTION
  47. * .--------------------------------------------------------------------------------------------------------------------------------------.
  48. * | F1 | F2 | F3 | F4 | F5 | F6 | | | | F7 | F8 | F9 | F10 | F11 | F12 |
  49. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  50. * | MS W U | | MS 2 | MS UP | MS 1 | MS 3 | RGB HD | | RGB HI | [ | ] | UP | | = | \ |
  51. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  52. * | MS W D | | MS L | MS DN | MS R | | RGB SD | | RGB SI | - | LEFT | DOWN | RIGHT | | |
  53. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  54. * | | | | | | | RGB VD | BL TG | RGB VI | | | | | | |
  55. * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  56. * | | FN | RGB TG | | MS W L | MS W R | | RESET | | MS 1 | MS 2 | RGB RMD| RGB MD | FN | |
  57. * '--------------------------------------------------------------------------------------------------------------------------------------'
  58. */
  59. [_FN] = { /* FUNCTION */
  60. { KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, RGB_HUD, _______, RGB_HUI, KC_F7, KC_F8, KC_F9, KC_F10 , KC_F11 , KC_F12 },
  61. { KC_WH_U, _______, KC_BTN2, KC_MS_U, KC_BTN1, KC_BTN3, RGB_SAD, _______, RGB_SAI, KC_LBRC, KC_RBRC, KC_UP , _______ , KC_EQL , KC_BSLS },
  62. { KC_WH_D, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, RGB_VAD, _______, RGB_VAI, KC_MINS, KC_LEFT, KC_DOWN, KC_RIGHT, _______, _______ },
  63. { _______, _______, _______, _______, _______, _______, RGB_RMOD,A_BL_TG, RGB_MOD, _______, _______, _______, _______ , _______, _______ },
  64. { _______, TT(_FN), RGB_TOG, _______, KC_WH_L, KC_WH_R, TT(_FN), RESET , TT(_FN), KC_BTN1, KC_BTN2, _______, _______ , TT(_FN), _______ },
  65. }
  66. };
  67. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  68. switch (keycode) {
  69. case A_BL_TG:
  70. if (record->event.pressed) {
  71. // toggle keycaps leds (f5 pin)
  72. PORTF ^= (1 << 5);
  73. }
  74. return false;
  75. // case A_BL_Y:
  76. // if (record->event.pressed) {
  77. // keycaps_led_on();
  78. // }
  79. // return false;
  80. // case A_BL_N:
  81. // if (record->event.pressed) {
  82. // keycaps_led_off();
  83. // }
  84. // return false;
  85. default:
  86. return true;
  87. }
  88. }
  89. // Runs whenever there is a layer state change.
  90. uint32_t layer_state_set_user(uint32_t state) {
  91. uint8_t layer = biton32(state);
  92. gp100_led_off();
  93. gp103_led_off();
  94. // turns on gp100 (top left led) for odd layers
  95. if (layer & (1<<0)) gp100_led_on();
  96. // turns on gp103 (top mid led) for layers 2, 6, ...
  97. if (layer & (1<<1)) gp103_led_on();
  98. return state;
  99. }