launchpad.cpp 774 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include "Launchpad.h"
  4. using namespace std;
  5. using namespace midi;
  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. cout << "Press a button to stop... " << endl;
  25. cin.ignore();
  26. return 0;
  27. }