| 
					
				 | 
			
			
				@@ -18,6 +18,11 @@ bool LaunchpadColor::operator==(const LaunchpadColor& color) const 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return red == color.red && green == color.green; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+bool LaunchpadColor::operator!=(const LaunchpadColor& color) const 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return !operator==(color); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 Launchpad::Launchpad() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	: midiin(), midiout(), keyPressedCallback(0), keyReleasedCallback(0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -165,7 +170,7 @@ void Launchpad::keyPressed(unsigned char x, unsigned char y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if(keyPressedCallback) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		keyPressedCallback(x, y); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		keyPressedCallback(x, y, keyEventCallbackData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -173,6 +178,103 @@ void Launchpad::keyReleased(unsigned char x, unsigned char y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if(keyReleasedCallback) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		keyReleasedCallback(x, y); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		keyReleasedCallback(x, y, keyEventCallbackData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::keyPressed(unsigned char x, unsigned char y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::keyReleased(unsigned char x, unsigned char y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::setColor(unsigned char x, unsigned char y, const LaunchpadColor& color) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(active && (!launchpad->issetColor(x, y) || launchpad->getColor(x, y) != color)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        launchpad->setColor(x, y, color); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    colors[x][y] = color; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::setColorAll(const LaunchpadColor& color) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for(unsigned char x = 0; x < Launchpad::width; x++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for(unsigned char y = 0; y < Launchpad::height; y++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(x != 8 || y != 8) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				setColor(x, y, color); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::sync() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for(unsigned char x = 0; x < Launchpad::width; x++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for(unsigned char y = 0; y < Launchpad::height; y++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if((x != 8 || y != 8) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			    && (!launchpad->issetColor(x, y) || launchpad->getColor(x, y) != colors[x][y])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                launchpad->setColor(x, y, colors[x][y]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+LaunchpadScreen::LaunchpadScreen() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    : launchpad(0), active(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::enable() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(!launchpad) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        throw RtMidiError( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "no launchpad set", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            RtMidiError::INVALID_USE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyEventCallbackData = (void*)this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyPressedCallback = keyPressedCallback; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyReleasedCallback = keyReleasedCallback; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sync(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    active = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::disable() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyPressedCallback = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyReleasedCallback = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    launchpad->keyEventCallbackData = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    active = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+bool LaunchpadScreen::enabled() const 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return active; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::setLaunchpad(Launchpad& l) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(enabled()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        disable(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        launchpad = &l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        enable(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        launchpad = &l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::keyPressedCallback(unsigned char x, unsigned char y, void* screen) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ((LaunchpadScreen*)screen)->keyPressed(x, y); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void LaunchpadScreen::keyReleasedCallback(unsigned char x, unsigned char y, void* screen) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ((LaunchpadScreen*)screen)->keyReleased(x, y); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |