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.

36 lines
757B

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