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.

keyboard.hpp 750B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "common.hpp"
  3. #include "midi.hpp"
  4. #include <map>
  5. namespace rack {
  6. namespace keyboard {
  7. struct InputDevice : midi::InputDevice {
  8. int octave = 5;
  9. std::map<int, int> pressedNotes;
  10. void onKeyPress(int key);
  11. void onKeyRelease(int key);
  12. };
  13. struct Driver : midi::Driver {
  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. midi::InputDevice *subscribeInputDevice(int deviceId, midi::Input *input) override;
  19. void unsubscribeInputDevice(int deviceId, midi::Input *input) override;
  20. };
  21. void init();
  22. void press(int key);
  23. void release(int key);
  24. } // namespace keyboard
  25. } // namespace rack