logo

qmk_firmware

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

keymap.c (1907B)


  1. /* Copyright 2020 swiftrax
  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. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. [0] = LAYOUT(
  19. TO(1), //windows
  20. KC_MSTP, KC_MPLY,
  21. KC_MPRV, KC_MNXT),
  22. [1] = LAYOUT( //macOS
  23. TO(2),
  24. KC_MSTP, KC_MPLY,
  25. KC_MRWD, KC_MFFD),
  26. [2] = LAYOUT(
  27. TO(0),
  28. KC_HOME, KC_PGUP,
  29. KC_END, KC_PGDN),
  30. };
  31. bool encoder_update_user(uint8_t index, bool clockwise) {
  32. if(IS_LAYER_ON(2)){
  33. if (clockwise)
  34. tap_code(KC_LEFT);
  35. else
  36. tap_code(KC_RGHT);
  37. }
  38. else{
  39. if(clockwise)
  40. tap_code(KC_VOLU);
  41. else
  42. tap_code(KC_VOLD);
  43. }
  44. return true;
  45. }
  46. void matrix_init_user(void) {
  47. // set top LED to output and off (active low)
  48. gpio_set_pin_output(D5);
  49. gpio_write_pin_high(D5);
  50. // set middle LED to output and off (active low)
  51. gpio_set_pin_output(D4);
  52. gpio_write_pin_high(D4);
  53. // set bottom LED to output and off (active low)
  54. gpio_set_pin_output(D3);
  55. gpio_write_pin_high(D3);
  56. }
  57. // write to above indicators in a binary fashion based on current layer
  58. layer_state_t layer_state_set_user(layer_state_t state) {
  59. gpio_write_pin(D5, get_highest_layer(state));
  60. gpio_write_pin(D4, !layer_state_cmp(state, 1));
  61. gpio_write_pin(D3, !layer_state_cmp(state, 2));
  62. return state;
  63. }