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.

37 lines
748B

  1. #pragma once
  2. #include <map>
  3. #include "common.hpp"
  4. #include "midi.hpp"
  5. namespace rack {
  6. namespace keyboard {
  7. struct InputDevice : MidiInputDevice {
  8. int octave = 5;
  9. std::map<int, int> pressedNotes;
  10. void onKeyPress(int key);
  11. void onKeyRelease(int key);
  12. };
  13. struct Driver : MidiDriver {
  14. InputDevice device;
  15. std::string getName() override {return "Computer keyboard";}
  16. std::vector<int> getInputDeviceIds() override;
  17. std::string getInputDeviceName(int deviceId) override;
  18. MidiInputDevice *subscribeInputDevice(int deviceId, MidiInput *midiInput) override;
  19. void unsubscribeInputDevice(int deviceId, MidiInput *midiInput) override;
  20. };
  21. void init();
  22. void press(int key);
  23. void release(int key);
  24. } // namespace keyboard
  25. } // namespace rack