keymap.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright 2020 Jay Greco
  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. #define _MA 0
  18. #define _FN 1
  19. enum custom_keycodes {
  20. KC_CUST = SAFE_RANGE,
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. [_MA] = LAYOUT_ansi(
  24. 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_TILD,
  25. KC_F13, 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_DEL,
  26. KC_F14, 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,
  27. KC_F15, 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,
  28. KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
  29. ),
  30. [_FN] = LAYOUT_ansi(
  31. RESET, 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_HOME, KC_INS,
  32. RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  33. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  34. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  35. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  36. ),
  37. };
  38. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  39. // Send keystrokes to host keyboard, if connected (see readme)
  40. process_record_remote_kb(keycode, record);
  41. switch(keycode) {
  42. case KC_CUST: //custom macro
  43. if (record->event.pressed) {
  44. }
  45. break;
  46. case RM_1: //remote macro 1
  47. if (record->event.pressed) {
  48. }
  49. break;
  50. case RM_2: //remote macro 2
  51. if (record->event.pressed) {
  52. }
  53. break;
  54. case RM_3: //remote macro 3
  55. if (record->event.pressed) {
  56. }
  57. break;
  58. case RM_4: //remote macro 4
  59. if (record->event.pressed) {
  60. }
  61. break;
  62. }
  63. return true;
  64. }
  65. // RGB config, for changing RGB settings on non-VIA firmwares
  66. void change_RGB(bool clockwise) {
  67. bool shift = get_mods() & MOD_MASK_SHIFT;
  68. bool alt = get_mods() & MOD_MASK_ALT;
  69. bool ctrl = get_mods() & MOD_MASK_CTRL;
  70. if (clockwise) {
  71. if (alt) {
  72. rgblight_increase_hue();
  73. } else if (ctrl) {
  74. rgblight_increase_val();
  75. } else if (shift) {
  76. rgblight_increase_sat();
  77. } else {
  78. rgblight_step();
  79. }
  80. } else {
  81. if (alt) {
  82. rgblight_decrease_hue();
  83. } else if (ctrl) {
  84. rgblight_decrease_val();
  85. } else if (shift) {
  86. rgblight_decrease_sat();
  87. } else {
  88. rgblight_step_reverse();
  89. }
  90. }
  91. }
  92. void encoder_update_kb(uint8_t index, bool clockwise) {
  93. if (layer_state_is(1)) {
  94. //change RGB settings
  95. change_RGB(clockwise);
  96. }
  97. else {
  98. if (clockwise) {
  99. tap_code(KC_VOLU);
  100. } else {
  101. tap_code(KC_VOLD);
  102. }
  103. }
  104. }
  105. void matrix_init_user(void) {
  106. // Initialize remote keyboard, if connected (see readme)
  107. matrix_init_remote_kb();
  108. }
  109. void matrix_scan_user(void) {
  110. // Scan and parse keystrokes from remote keyboard, if connected (see readme)
  111. matrix_scan_remote_kb();
  112. }