Fabian Peter Hammerle 10 years ago
parent
commit
c18aea0a26
5 changed files with 50 additions and 5 deletions
  1. 2 2
      Launchpad.cpp
  2. 7 1
      Makefile.am
  3. 1 1
      MidiMessage.h
  4. 4 1
      tests/Makefile.in
  5. 36 0
      tests/launchpad.cpp

+ 2 - 2
Launchpad.cpp

@@ -24,7 +24,7 @@ Launchpad::Launchpad()
     // define callback before opening port to keep the message queue empty.
 	midiin.setCallback(midiMessageCallback, (void*) this);
 
-    for(int i=0; i<midiout.getPortCount(); i++)
+    for(unsigned int i=0; i<midiout.getPortCount(); i++)
     {
         if(midiout.getPortName(i).find("Launchpad") != std::string::npos)
         {
@@ -40,7 +40,7 @@ Launchpad::Launchpad()
 			);
 	}
 
-    for(int i=0; i<midiin.getPortCount(); i++)
+    for(unsigned int i=0; i<midiin.getPortCount(); i++)
     {
         if(midiin.getPortName(i).find("Launchpad") != std::string::npos)
         {

+ 7 - 1
Makefile.am

@@ -1,5 +1,11 @@
 lib_LTLIBRARIES = %D%/librtmidi.la
 %C%_librtmidi_la_LDFLAGS = -no-undefined
 %C%_librtmidi_la_SOURCES = \
+  %D%/MidiMessage.cpp \
   %D%/RtMidi.cpp \
-  %D%/RtMidi.h
+  %D%/Midi.cpp \
+  %D%/Launchpad.cpp \
+  %D%/MidiMessage.h \
+  %D%/RtMidi.h \
+  %D%/Midi.h \
+  %D%/Launchpad.h 

+ 1 - 1
MidiMessage.h

@@ -1,5 +1,5 @@
 #pragma once
-#include <cstdint>
+#include <stdint.h>
 #include <vector>
 
 class MidiMessage

+ 4 - 1
tests/Makefile.in

@@ -1,7 +1,7 @@
 ### Do not edit -- Generated by 'configure --with-whatever' from Makefile.in
 ### RtMidi tests Makefile - for various flavors of unix
 
-PROGRAMS = midiprobe midiout qmidiin cmidiin sysextest
+PROGRAMS = midiprobe midiout qmidiin cmidiin sysextest launchpad
 RM = /bin/rm
 SRC_PATH = ..
 INCLUDE = @top_srcdir@
@@ -36,6 +36,9 @@ cmidiin : @srcdir@/cmidiin.cpp $(OBJECTS)
 sysextest : @srcdir@/sysextest.cpp $(OBJECTS)
 	$(CC) $(CFLAGS) $(DEFS) -o sysextest $^ $(LIBRARY)
 
+launchpad : @srcdir@/launchpad.cpp $(OBJECTS)
+	$(CC) $(CFLAGS) $(DEFS) -o launchpad $^ $(LIBRARY) ../MidiMessage.o ../Midi.o ../Launchpad.o
+
 clean : 
 	$(RM) -f $(OBJECT_PATH)/*.o
 	$(RM) -f $(PROGRAMS) *.exe

+ 36 - 0
tests/launchpad.cpp

@@ -0,0 +1,36 @@
+#include <iostream>
+#include <cstdlib>
+#include "RtMidi.h"
+#include "MidiMessage.h"
+#include "Launchpad.h"
+
+// Platform-dependent sleep routines.
+#if defined(__WINDOWS_MM__)
+  #include <windows.h>
+  #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) 
+#else // Unix variants
+  #include <unistd.h>
+  #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
+#endif
+
+Launchpad l;
+
+void keyPressed(unsigned char x, unsigned char y)
+{
+    std::cout << "(" << (int)x << ", " << (int)y << ")" << std::endl;
+
+    l.setColor(x, y, LaunchpadColor(3, 3));
+}
+
+int main()
+{
+    l.keyPressedCallback = keyPressed;
+
+    l.setColorAll(LaunchpadColor(0, 1));
+
+    while(true) 
+    {
+    }
+
+    return 0;
+}