Skip to content
Permalink
Browse files

check net connection, leap connection

  • Loading branch information
n1ckfg committed Oct 9, 2013
1 parent d883e20 commit 2f175d2585d4d34551d9dfe2e146583a6505d681
Showing with 1,365 additions and 5 deletions.
  1. +2 −0 LeapMotionListener.pde
  2. +52 −3 ManosOsc.pde
  3. +1 −0 Settings.pde
  4. +1 −1 data/README.txt
  5. +596 −0 data/examples-osx/Jitter example.maxpat
  6. +75 −0 data/examples-osx/Processing example/ReceiveExample.app/Contents/Info.plist
  7. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/MacOS/JavaApplicationStub
  8. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/MacOS/JavaApplicationStub64
  9. +1 −0 data/examples-osx/Processing example/ReceiveExample.app/Contents/PkgInfo
  10. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/ReceiveExample.jar
  11. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/core.jar
  12. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/gluegen-rt.jar
  13. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/jogl.jar
  14. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/libgluegen-rt.jnilib
  15. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/libjogl.jnilib
  16. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/libjogl_awt.jnilib
  17. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/libjogl_cg.jnilib
  18. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/opengl.jar
  19. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/Java/oscP5.jar
  20. BIN data/examples-osx/Processing example/ReceiveExample.app/Contents/Resources/sketch.icns
  21. +17 −0 data/examples-osx/Processing example/settings.txt
  22. +596 −0 data/examples-win/Jitter example.maxpat
  23. BIN data/examples-win/Processing example/ReceiveExample.exe
  24. BIN data/examples-win/Processing example/gluegen-rt.dll
  25. BIN data/examples-win/Processing example/jogl.dll
  26. BIN data/examples-win/Processing example/jogl_awt.dll
  27. BIN data/examples-win/Processing example/jogl_cg.dll
  28. BIN data/examples-win/Processing example/lib/ReceiveExample.jar
  29. +3 −0 data/examples-win/Processing example/lib/args.txt
  30. BIN data/examples-win/Processing example/lib/core.jar
  31. BIN data/examples-win/Processing example/lib/gluegen-rt.jar
  32. BIN data/examples-win/Processing example/lib/jogl.jar
  33. BIN data/examples-win/Processing example/lib/opengl.jar
  34. BIN data/examples-win/Processing example/lib/oscP5.jar
  35. +17 −0 data/examples-win/Processing example/settings.txt
  36. +4 −1 data/settings.txt
2 LeapMotionListener.pde 100755 → 100644
@@ -81,10 +81,12 @@ class LeapMotionListener extends Listener {
}

public void onConnect(Controller controller) {
leapConnection = true;
System.out.println("Leap Motion Connected");
}

public void onDisconnect(Controller controller) {
leapConnection=false;
System.out.println("Leap Motion Disconnected");
}

@@ -5,6 +5,7 @@ import processing.opengl.*;
import com.onformative.leap.LeapMotionP5;
import com.leapmotion.leap.*;
import java.awt.Desktop;
import java.net.InetAddress;

LeapMotionP5 leap;

@@ -28,6 +29,10 @@ String fontFace = "assets/DroidSans-Bold-48.vlw";
int fontSize = 16;
color fontColor = color(255);
boolean centerMode = false;
boolean leapConnection = false;
boolean netConnection = false;
boolean doNetConnection = false;
int netCheckTime = 2000;

String scriptsFilePath = "data";
boolean record = false;
@@ -78,6 +83,10 @@ void setup() {
}

void draw() {
if(millis()>netCheckTime){
if(doNetConnection) netConnection = checkNetConnection(1);
netCheckTime += millis();
}
if (showSplashScreen & millis()<splashScreenTime*1000) {
imageMode(CORNER);
try {
@@ -152,9 +161,18 @@ void draw() {
" | (T)races: " + setOnOff(showTraces) +
" | (O)sc: " + setOnOff(sendOsc) +
" | (F)older "; //"(SPACE) to record" +
sayText[1] = "fps: " + int(frameRate) +
" ip: " + ipNumber +
" port: " + sendPort;
if(doNetConnection){
sayText[1] = "fps: " + int(frameRate) +
" ip: " + ipNumber +
" port: " + sendPort +
" net: " + setYesNo(netConnection) +
" leap: " + setYesNo(leapConnection);
}else{
sayText[1] = "fps: " + int(frameRate) +
" ip: " + ipNumber +
" port: " + sendPort +
" leap: " + setYesNo(leapConnection);
}
//~~
sayText[2] = "channel /hand0 [ (s) " + handPoints[0].pointType + ", (i) " + handPoints[0].idHand + convertVals(handPoints[0].p, "hand");
sayText[3] = "channel /finger0-0 [ (s) " + handPoints[0].fingerPoints[0].pointType + ", (i) " + handPoints[0].idHand + ", (i) " + handPoints[0].fingerPoints[0].idPointable + convertVals(handPoints[0].fingerPoints[0].p, "finger");
@@ -202,6 +220,17 @@ String setOnOff(boolean _b) {
return s;
}

String setYesNo(boolean _b) {
String s;
if (_b) {
s = "YES";
}
else {
s = "NO";
}
return s;
}

public void stop() {
leap.stop();
}
@@ -330,3 +359,23 @@ float rounder(float _val, float _places){
return _val;
}

boolean checkNetConnection(int _t){
boolean answer = false;
try{
int timeout = _t; //duration over which to retry
InetAddress[] addresses = InetAddress.getAllByName("google.com");
for (InetAddress address : addresses) {
if (address.isReachable(timeout)){
answer = true;
//println("Internet connection, and " + address + " is reachable.");
}else{
answer = true;
//println("Internet connection, but " + address + " is not reachable.");
}
}
}catch (Exception e) {
answer = false;
//println("No internet connection.");
}
return answer;
}
@@ -7,6 +7,7 @@ class Settings {
settings = new Data();
settings.load(_s);
for (int i=0;i<settings.data.length;i++) {
if (settings.data[i].equals("Check for Net Connection")) doNetConnection = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Center Coordinates")) centerMode = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Open App Folder at Startup")) openAppFolder = setBoolean(settings.data[i+1]);
if (settings.data[i].equals("Show Splash Screen")) showSplashScreen = setBoolean(settings.data[i+1]);
@@ -10,7 +10,7 @@ ManosOsc outputs OSC from the Leap controller, tracking the coordinates of your
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

II. CONTROLS
* (D)ebug: Press the D key to toggle a detailed display of the OSC data that ManosOsc is sending. Defaults to OFF.
* (D)ebug: Press the D key to toggle a detailed display of the OSC data that ManosOsc is sending. Defaults to ON.

* (Z) reverse: Press the Z key to toggle mirrored tracking--when you move your hand toward the screen, the tracked points move toward you. Defaults to ON.

0 comments on commit 2f175d2

Please sign in to comment.
You can’t perform that action at this time.