You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.1 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. /*
  2. Copyright 2015 Jack Humbert <jack.humb@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "keymap_common.h"
  15. #include "keymap_midi.h"
  16. #include <lufa.h>
  17. uint8_t starting_note = 0x0C;
  18. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
  19. {
  20. if (id != 0) {
  21. if (record->event.pressed) {
  22. midi_send_noteon(&midi_device, opt, (id & 0xFF), 127);
  23. } else {
  24. midi_send_noteoff(&midi_device, opt, (id & 0xFF), 127);
  25. }
  26. }
  27. if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
  28. starting_note++;
  29. midi_send_cc(&midi_device, 0, 0x7B, 0);
  30. midi_send_cc(&midi_device, 1, 0x7B, 0);
  31. midi_send_cc(&midi_device, 2, 0x7B, 0);
  32. midi_send_cc(&midi_device, 3, 0x7B, 0);
  33. midi_send_cc(&midi_device, 4, 0x7B, 0);
  34. }
  35. if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
  36. starting_note--;
  37. midi_send_cc(&midi_device, 0, 0x7B, 0);
  38. midi_send_cc(&midi_device, 1, 0x7B, 0);
  39. midi_send_cc(&midi_device, 2, 0x7B, 0);
  40. midi_send_cc(&midi_device, 3, 0x7B, 0);
  41. midi_send_cc(&midi_device, 4, 0x7B, 0);
  42. }
  43. if (record->event.pressed) {
  44. midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
  45. } else {
  46. midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
  47. }
  48. }