logo

qmk_firmware

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

keymap.c (3624B)


  1. /* Copyright 2021 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. #include "quick17_prefs.h"
  18. // Defines the keycodes used by our macros in process_record_user
  19. enum custom_keycodes {
  20. KC_LANG
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. [_CONTROL] = LAYOUT(
  24. KC_TAB, KC_PGUP,KC_UP, KC_PGDN,KC_HOME,KC_INS,
  25. KC_LCTL,KC_LEFT,KC_DOWN,KC_RGHT,KC_END, KC_DEL,
  26. KC_LSFT,KC_LGUI,KC_ESC, KC_LALT,LT(3,KC_SPC),TO(1)
  27. ),
  28. [_EDIT1] = LAYOUT(
  29. KC_ESC, KC_W, KC_E, KC_R, KC_Y, KC_BSPC,
  30. KC_LCTL,KC_A, KC_D, KC_F, KC_H, LCTL(KC_Z),
  31. KC_LSFT,KC_X, KC_V, KC_B, LT(2,KC_SPC),LCTL(KC_S)
  32. ),
  33. [_EDIT2] = LAYOUT(
  34. KC_ESC, KC_Q, KC_BTN3,KC_INS, KC_ENT, KC_DEL,
  35. KC_LCTL,KC_LBRC,KC_RBRC,KC_PGDN,KC_PGUP,LCTL(KC_Y),
  36. KC_LSFT,TO(3), RM_TOGG,TO(0), _______,KC_NO
  37. ),
  38. [_FN] = LAYOUT(
  39. KC_ESC, KC_LANG,KC_NO, RM_TOGG,KC_MNXT,KC_VOLU,
  40. KC_CAPS,KC_NUM, KC_NO, RM_NEXT,KC_MPRV,KC_VOLD,
  41. CG_NORM,CG_LSWP,EE_CLR, QK_BOOT,TO(0), KC_MUTE
  42. )
  43. };
  44. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  45. switch (keycode) {
  46. case KC_LANG:
  47. if (record->event.pressed){
  48. if (keymap_config.swap_lctl_lgui == false){
  49. tap_code16(LALT(KC_GRV));
  50. } else {
  51. if(input_mode()){
  52. register_code(KC_LNG2);
  53. set_input_mode(false);
  54. } else {
  55. register_code(KC_LNG1);
  56. set_input_mode(true);
  57. }
  58. }
  59. } else {
  60. unregister_code(KC_LNG1);
  61. unregister_code(KC_LNG2);
  62. }
  63. break;
  64. default:
  65. break;
  66. }
  67. return true;
  68. }
  69. bool encoder_update_user(uint8_t index, bool clockwise){
  70. if (index == 0) {
  71. if (IS_LAYER_ON(_EDIT2)){
  72. if (clockwise) {
  73. tap_code(KC_LBRC);
  74. } else {
  75. tap_code(KC_RBRC);
  76. }
  77. } else if (IS_LAYER_ON(_EDIT1)){
  78. if (clockwise) {
  79. tap_code(KC_VOLU);
  80. } else {
  81. tap_code(KC_VOLD);
  82. }
  83. } else if (IS_LAYER_ON(_FN)){
  84. if (clockwise) {
  85. tap_code(KC_MNXT);
  86. } else {
  87. tap_code(KC_MPRV);
  88. }
  89. } else { // IS_LAYER_ON(_CONTROL)
  90. if (clockwise) {
  91. tap_code(KC_WH_U);
  92. } else {
  93. tap_code(KC_WH_D);
  94. }
  95. }
  96. }
  97. return false;
  98. }
  99. #ifdef RGB_MATRIX_ENABLE
  100. void keyboard_post_init_user(void){
  101. rgb_matrix_mode(RGB_MATRIX_CUSTOM_quick17_rgbm_effect);
  102. set_input_mode(false);
  103. }
  104. #else
  105. void keyboard_post_init_user(void){
  106. rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
  107. set_input_mode(false);
  108. }
  109. #endif