keymap.c 3.0 KB

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