logo

qmk_firmware

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

navpad_prefs.c (2536B)


  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 "navpad_prefs.h"
  17. #include "quantum.h"
  18. #include "action.h"
  19. #include "action_layer.h"
  20. #include "rgblight.h"
  21. #include "led.h"
  22. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  23. if (!process_record_user(keycode, record)) { return false; }
  24. switch (keycode) {
  25. case TAP_00:
  26. if (record->event.pressed){
  27. tap_code(KC_P0);
  28. tap_code(KC_P0);
  29. }
  30. break;
  31. default:
  32. break;
  33. }
  34. return true;
  35. }
  36. #ifdef ENCODER_ENABLE
  37. bool encoder_update_kb(uint8_t index, bool clockwise) {
  38. if (!encoder_update_user(index, clockwise)) { return false; }
  39. if (index == 0) { /* Navpad side encoder */
  40. switch (get_highest_layer(layer_state|default_layer_state)) {
  41. case _BASE:
  42. if (clockwise) {
  43. tap_code16(KC_VOLU);
  44. } else {
  45. tap_code16(KC_VOLD);
  46. }
  47. break;
  48. case _FN1:
  49. if (clockwise) {
  50. rgblight_increase_hue();
  51. } else {
  52. rgblight_decrease_hue();
  53. }
  54. break;
  55. case _FN2:
  56. if (clockwise) {
  57. rgblight_increase_sat();
  58. } else {
  59. rgblight_decrease_sat();
  60. }
  61. break;
  62. default:
  63. break;
  64. }
  65. }
  66. if (index == 1) { /* Helix side encoder */
  67. switch (get_highest_layer(layer_state|default_layer_state)) {
  68. case _BASE:
  69. if (clockwise) {
  70. tap_code(KC_RBRC);
  71. } else {
  72. tap_code(KC_LBRC);
  73. }
  74. break;
  75. case _FN1:
  76. if (clockwise) {
  77. tap_code16(KC_RPRN);
  78. } else {
  79. tap_code16(KC_LPRN);
  80. }
  81. break;
  82. case _FN2:
  83. if (clockwise) {
  84. tap_code16(KC_RCBR);
  85. } else {
  86. tap_code16(KC_LCBR);
  87. }
  88. break;
  89. default:
  90. break;
  91. }
  92. }
  93. return false;
  94. }
  95. #endif