diff --git a/src/com/jaysonh/dmx4artists/DMXControl.java b/src/com/jaysonh/dmx4artists/DMXControl.java index d0bbc55..8e4e007 100644 --- a/src/com/jaysonh/dmx4artists/DMXControl.java +++ b/src/com/jaysonh/dmx4artists/DMXControl.java @@ -233,6 +233,8 @@ public void close() */ private void setupDevice( int numChannels ) { + System.out.println("DMXForArtists version: " + VERSION_NUM); + if ( numChannels <= MAX_CHANNELS ) // make sure we don't have too many channels { this.numChannels = numChannels; @@ -280,6 +282,8 @@ public void setFixtureFadeRate( float fadeVal ) ************************************************************************************/ private final int SLEEP_TIME = 50; // number of ms for the update thread to sleep for + public final String VERSION_NUM = "1.4"; + private FTDIDmx ftdiDmx; // dmx control object private ArrayList fixtureList; // list of all the DMX fixtures diff --git a/src/com/jaysonh/dmx4artists/FTDI_D2XX.java b/src/com/jaysonh/dmx4artists/FTDI_D2XX.java index 71d5d90..0c8b60e 100644 --- a/src/com/jaysonh/dmx4artists/FTDI_D2XX.java +++ b/src/com/jaysonh/dmx4artists/FTDI_D2XX.java @@ -41,7 +41,11 @@ public interface FTDI_D2XX extends Library final static byte FT_PURGE_RX = 1; // Purge rx and tx buffers final static byte FT_PURGE_TX = 2; - FTDI_D2XX INSTANCE = (FTDI_D2XX) Native.loadLibrary("ftd2xx", FTDI_D2XX.class); + //FTDI_D2XX INSTANCE = (FTDI_D2XX) Native.loadLibrary("ftd2xx", FTDI_D2XX.class); + // Load the dylib or dll from the Processing DMXForArtist library folder + // This is hopefully more reliable than before + FTDI_D2XX INSTANCE = (FTDI_D2XX) Native.loadLibrary( new PathFinder().getLibraryPath(), FTDI_D2XX.class); + int FT_Open(short intDeviceNumber, PointerByReference handle); int FT_Close(Pointer handle); int FT_ResetDevice (Pointer handle); diff --git a/src/com/jaysonh/dmx4artists/OSXValidator.java b/src/com/jaysonh/dmx4artists/OSXValidator.java index fb052b0..2d75812 100644 --- a/src/com/jaysonh/dmx4artists/OSXValidator.java +++ b/src/com/jaysonh/dmx4artists/OSXValidator.java @@ -17,10 +17,10 @@ public boolean isValid() String[] res = commandDylib.getOutput(); - boolean dylibOK = false; - boolean permsOK = false; + boolean dylibOK = true; + boolean permsOK = true; - if(res.length > 0) + /*if(res.length > 0) { String []cols = res[0].split(" "); @@ -46,7 +46,7 @@ public boolean isValid() permsOK = true; } } - } + }*/ OSXCommand kextstatCmd = new OSXCommand("kextstat"); diff --git a/src/com/jaysonh/dmx4artists/PathFinder.java b/src/com/jaysonh/dmx4artists/PathFinder.java new file mode 100644 index 0000000..39ba944 --- /dev/null +++ b/src/com/jaysonh/dmx4artists/PathFinder.java @@ -0,0 +1,49 @@ +package com.jaysonh.dmx4artists; + +public class PathFinder +{ + String getLibraryPath() + { + String res = System.getProperty("java.class.path"); + + String [] comps; + + int os = new SystemValidator().checkOS(); + + // if osx then need to split by : + // if win then need to split by ; + if(os == SystemValidator.OS_OSX) + { + comps = res.split(":"); + }else if(os == SystemValidator.OS_WIN) + { + comps = res.split(";"); + }else + { + comps = null; //empty + } + + boolean foundLibPath = false; + String dmxLibPath = ""; + + for(int i = 0; i < comps.length && !foundLibPath;i++) + { + if( comps[i].contains("Dmx4Artists")) + { + String [] paths =comps[i].split("Dmx4Artists"); + + if(os == SystemValidator.OS_OSX) + { + dmxLibPath = paths[0] + "Dmx4Artists/dependencies/osx/libftd2xx.1.2.2.dylib"; + }else if(os == SystemValidator.OS_WIN) + { + dmxLibPath = paths[0] + "Dmx4Artists/dependencies/win/ftd2xx.dll"; + } + System.out.println("found path: " + dmxLibPath); + foundLibPath = true; + } + } + + return dmxLibPath; + } +} \ No newline at end of file diff --git a/src/com/jaysonh/dmx4artists/SystemValidator.java b/src/com/jaysonh/dmx4artists/SystemValidator.java index 46dd6e9..60946af 100644 --- a/src/com/jaysonh/dmx4artists/SystemValidator.java +++ b/src/com/jaysonh/dmx4artists/SystemValidator.java @@ -43,6 +43,24 @@ else if(osName.startsWith("mac os x")) } } + /* + * Get the operating string as a 3 letter string + */ + String getOS() + { + if( checkOS() == OS_OSX ) + { + return "osx"; + }else if(checkOS() == OS_WIN ) + { + return "win"; + }else + { + System.err.println("Unsupported operating system"); + return ""; + } + } + static final int OS_UNK = 0; static final int OS_OSX = 1; static final int OS_WIN = 2; diff --git a/src/com/jaysonh/dmx4artists/WINValidator.java b/src/com/jaysonh/dmx4artists/WINValidator.java index 9d05fff..df9beea 100644 --- a/src/com/jaysonh/dmx4artists/WINValidator.java +++ b/src/com/jaysonh/dmx4artists/WINValidator.java @@ -21,9 +21,10 @@ public class WINValidator */ public boolean isValid() { - boolean exists = false; + boolean exists = true; String foundPath = ""; - + + /* // Get the system paths for DLL files String property = System.getProperty("java.library.path"); StringTokenizer parser = new StringTokenizer(property, ";"); @@ -65,6 +66,7 @@ public boolean isValid() } return false; - } + }*/ + return true; } } \ No newline at end of file