keymap.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright 2020 yushakobo
  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. _FUNC1,
  21. _VIA1,
  22. _VIA2
  23. };
  24. // Defines the keycodes used by our macros in process_record_user
  25. enum custom_keycodes {
  26. YUSHAURL = SAFE_RANGE
  27. };
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. /* Base */
  30. [_BASE] = LAYOUT(
  31. KC_MUTE, MO(_FUNC1), RGB_MOD,
  32. S(KC_TAB), KC_UP, KC_TAB,
  33. KC_LEFT, KC_DOWN, KC_RGHT
  34. ),
  35. [_FUNC1] = LAYOUT(
  36. RESET, KC_TRNS, RGB_TOG,
  37. KC_HOME, KC_VOLU, KC_END,
  38. KC_MPRV, KC_VOLD, KC_MNXT
  39. ),
  40. [_VIA1] = LAYOUT(
  41. YUSHAURL,XXXXXXX, XXXXXXX,
  42. XXXXXXX, XXXXXXX, XXXXXXX,
  43. XXXXXXX, XXXXXXX, XXXXXXX
  44. ),
  45. [_VIA2] = LAYOUT(
  46. XXXXXXX, XXXXXXX, XXXXXXX,
  47. XXXXXXX, XXXXXXX, XXXXXXX,
  48. XXXXXXX, XXXXXXX, XXXXXXX
  49. )
  50. };
  51. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  52. switch (keycode) {
  53. case YUSHAURL:
  54. if (record->event.pressed) {
  55. // when keycode QMKURL is pressed
  56. SEND_STRING("https://yushakobo.jp/\n");
  57. } else {
  58. // when keycode QMKURL is released
  59. }
  60. break;
  61. }
  62. return true;
  63. }
  64. bool encoder_update_user(uint8_t index, bool clockwise) {
  65. if (index == 0) { // Left encoder
  66. if (clockwise) {
  67. tap_code(KC_VOLU);
  68. } else {
  69. tap_code(KC_VOLD);
  70. }
  71. }
  72. else if (index == 1) { // Right encoder
  73. if (clockwise) {
  74. rgblight_decrease_hue_noeeprom();
  75. } else {
  76. rgblight_increase_hue_noeeprom();
  77. }
  78. }
  79. return true;
  80. }