logo

qmk_firmware

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

keymap.c (2374B)


  1. /* Copyright 2020 Duckle
  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 "analog.h"
  18. #include "qmk_midi.h"
  19. // Defines names for use in layer keycodes and the keymap
  20. enum layer_names {
  21. _BASE,
  22. _FN,
  23. _MEDIA
  24. };
  25. // Defines the keycodes used by our macros in process_record_user
  26. enum custom_keycodes {
  27. QMKBEST = SAFE_RANGE,
  28. QMKURL
  29. };
  30. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  31. /* Base */
  32. [_BASE] = LAYOUT(
  33. TO(_FN),
  34. KC_1, KC_2, KC_3,
  35. KC_4, KC_5, KC_6, KC_0
  36. ),
  37. [_FN] = LAYOUT(
  38. TO(_MEDIA),
  39. UG_TOGG, UG_NEXT, UG_VALU,
  40. QMKURL, UG_PREV, UG_VALD, QMKBEST
  41. ),
  42. [_MEDIA] = LAYOUT(
  43. TO(_BASE),
  44. KC_VOLD, KC_VOLU, KC_F24,
  45. KC_MRWD, KC_MFFD, KC_F23, KC_MPLY
  46. )
  47. };
  48. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  49. switch (keycode) {
  50. case QMKBEST:
  51. if (record->event.pressed) {
  52. // when keycode QMKBEST is pressed
  53. SEND_STRING("QMK is the best thing ever!");
  54. } else {
  55. // when keycode QMKBEST is released
  56. }
  57. break;
  58. case QMKURL:
  59. if (record->event.pressed) {
  60. // when keycode QMKURL is pressed
  61. SEND_STRING("https://qmk.fm/\n");
  62. } else {
  63. // when keycode QMKURL is released
  64. }
  65. break;
  66. }
  67. return true;
  68. }
  69. uint8_t divisor = 0;
  70. void slider(void) {
  71. if (divisor++) { // only run the slider function 1/256 times it's called
  72. return;
  73. }
  74. midi_send_cc(&midi_device, 2, 0x3E, 0x7F - (analogReadPin(SLIDER_PIN) >> 3));
  75. }
  76. void matrix_scan_user(void) {
  77. slider();
  78. }