launchpad.cpp 750 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include "RtMidi.h"
  4. #include "MidiMessage.h"
  5. #include "Launchpad.h"
  6. // Platform-dependent sleep routines.
  7. #if defined(__WINDOWS_MM__)
  8. #include <windows.h>
  9. #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
  10. #else // Unix variants
  11. #include <unistd.h>
  12. #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
  13. #endif
  14. Launchpad l;
  15. void keyPressed(unsigned char x, unsigned char y, void* data)
  16. {
  17. std::cout << "(" << (int)x << ", " << (int)y << ")" << std::endl;
  18. l.setColor(x, y, LaunchpadColor(3, 3));
  19. }
  20. int main()
  21. {
  22. l.keyPressedCallback = keyPressed;
  23. l.setColorAll(LaunchpadColor(0, 1));
  24. while(true)
  25. {
  26. SLEEP(1);
  27. }
  28. return 0;
  29. }