logo

qmk_firmware

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

keymap.c (3043B)


  1. /* Copyright 2020 gregorio
  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. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  19. /* Base */
  20. [0] = LAYOUT(
  21. ENC_PRESS,
  22. KC_NUM , KC_PSLS, KC_PAST, KC_PMNS,
  23. KC_P7 , KC_P8 , KC_P9 , KC_PPLS,
  24. KC_P4 , KC_P5 , KC_P6 ,
  25. KC_P1 , KC_P2 , KC_P3 , KC_PENT,
  26. KC_P0 , LT(2, KC_PDOT)
  27. ),
  28. [1] = LAYOUT(
  29. KC_TRNS,
  30. KC_C , KC_SLSH, CL_STAR, KC_MINS,
  31. KC_7 , KC_8 , KC_9 , CL_PLUS,
  32. KC_4 , KC_5 , KC_6 ,
  33. KC_1 , KC_2 , KC_3 , KC_EQL,
  34. KC_0 , KC_DOT
  35. ),
  36. [2] = LAYOUT(
  37. KC_TRNS,
  38. KC_TRNS, KC_N , KC_S , KC_R ,
  39. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  40. KC_TRNS, KC_TRNS, KC_TRNS,
  41. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  42. KC_TRNS, KC_TRNS
  43. ),
  44. [3] = LAYOUT(
  45. KC_TRNS,
  46. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  47. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  48. KC_TRNS, QK_BOOT , KC_TRNS,
  49. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  50. KC_TRNS, KC_TRNS
  51. ),
  52. };
  53. bool encoder_update_user(uint8_t index, bool clockwise) {
  54. if (index == 0) {
  55. if (get_highest_layer(layer_state) == 0) {
  56. uint16_t mapped_code = 0;
  57. if (clockwise) {
  58. mapped_code = handle_encoder_cw();
  59. } else {
  60. mapped_code = handle_encoder_ccw();
  61. }
  62. if (mapped_code != 0) {
  63. tap_code16(mapped_code);
  64. }
  65. } else {
  66. if (clockwise) {
  67. if (oled_mode == OLED_MODE_CALC) {
  68. handle_encoder_cw();
  69. } else if (oled_mode == OLED_MODE_DEFAULT) {
  70. change_encoder_mode(false);
  71. }
  72. } else {
  73. if (oled_mode == OLED_MODE_CALC) {
  74. handle_encoder_ccw();
  75. } else if (oled_mode == OLED_MODE_DEFAULT) {
  76. change_encoder_mode(true);
  77. }
  78. }
  79. }
  80. }
  81. return true;
  82. }