diff --git a/.classpath b/.classpath index 0507f35..c49f98b 100644 --- a/.classpath +++ b/.classpath @@ -5,7 +5,13 @@ - - + + + + + + + + diff --git a/lib/jinput-2.0.5.jar b/lib/jinput-2.0.5.jar deleted file mode 100644 index 2081334..0000000 Binary files a/lib/jinput-2.0.5.jar and /dev/null differ diff --git a/lib/jutils-1.0.0.jar b/lib/jutils-1.0.0.jar deleted file mode 100644 index 147b542..0000000 Binary files a/lib/jutils-1.0.0.jar and /dev/null differ diff --git a/lib/lwjgl-glfw-natives-linux.jar b/lib/lwjgl-glfw-natives-linux.jar new file mode 100644 index 0000000..701d2da Binary files /dev/null and b/lib/lwjgl-glfw-natives-linux.jar differ diff --git a/lib/lwjgl-glfw-natives-macos.jar b/lib/lwjgl-glfw-natives-macos.jar new file mode 100644 index 0000000..48644a6 Binary files /dev/null and b/lib/lwjgl-glfw-natives-macos.jar differ diff --git a/lib/lwjgl-glfw-natives-windows.jar b/lib/lwjgl-glfw-natives-windows.jar new file mode 100644 index 0000000..9f60b4a Binary files /dev/null and b/lib/lwjgl-glfw-natives-windows.jar differ diff --git a/lib/lwjgl-glfw.jar b/lib/lwjgl-glfw.jar new file mode 100644 index 0000000..aace7a6 Binary files /dev/null and b/lib/lwjgl-glfw.jar differ diff --git a/lib/lwjgl-natives-linux.jar b/lib/lwjgl-natives-linux.jar new file mode 100644 index 0000000..165e815 Binary files /dev/null and b/lib/lwjgl-natives-linux.jar differ diff --git a/lib/lwjgl-natives-macos.jar b/lib/lwjgl-natives-macos.jar new file mode 100644 index 0000000..0f6e392 Binary files /dev/null and b/lib/lwjgl-natives-macos.jar differ diff --git a/lib/lwjgl-natives-windows.jar b/lib/lwjgl-natives-windows.jar new file mode 100644 index 0000000..e70c1f7 Binary files /dev/null and b/lib/lwjgl-natives-windows.jar differ diff --git a/lib/lwjgl.jar b/lib/lwjgl.jar new file mode 100644 index 0000000..77f1d3c Binary files /dev/null and b/lib/lwjgl.jar differ diff --git a/projectBuilder.xml b/projectBuilder.xml index 50a4f1b..99d06c1 100644 --- a/projectBuilder.xml +++ b/projectBuilder.xml @@ -15,8 +15,14 @@ - - + + + + + + + + diff --git a/sigIRCv2.bat b/sigIRCv2.bat index 2a25311..256e665 100644 --- a/sigIRCv2.bat +++ b/sigIRCv2.bat @@ -1 +1,2 @@ -java -jar ./sigIRCv2.jar -Djava.library.path=lib/ \ No newline at end of file +cd "C:\Users\Joshua Sigona\git\sigIRCv2\" +java -jar sigIRCv2.jar -Djinput.useDefaultPlugin=false -Djinput.plugins=net.java.games.input.DirectInputEnvironmentPlugin diff --git a/sigIRCv2.jar b/sigIRCv2.jar index 01c416e..1e949e7 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/modules/Controller/Axis.java b/src/sig/modules/Controller/Axis.java index 5d64737..bd8e4a0 100644 --- a/src/sig/modules/Controller/Axis.java +++ b/src/sig/modules/Controller/Axis.java @@ -6,14 +6,11 @@ import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.List; -import net.java.games.input.Component; -import net.java.games.input.Controller; -import net.java.games.input.Component.Identifier; import sig.sigIRC; import sig.modules.ControllerModule; public class Axis { - List identifiers = new ArrayList(); + List identifiers = new ArrayList(); boolean twoWayAxis = false; //True = 4-way, False = 2-way Color backgroundColor=Color.BLACK,indicatorColor=Color.WHITE; double pct_x = 0; @@ -25,16 +22,20 @@ public class Axis { double range1,range2; //Range of motion. int orientation; //0=Left-to-Right, 1=Right-to-Left, 2=Bottom-to-Top, 3=Top-to-Bottom boolean visible=false; + boolean x_invert,y_invert,axis_invert; /** * 4-way axis Constructor. */ public Axis(Rectangle2D.Double rect, Controller parent_controller, - Identifier identifier, - Identifier identifier2, + Integer identifier, + Integer identifier2, Color background_color, Color indicator_color, + boolean x_invert, + boolean y_invert, + boolean axis_invert, ControllerModule module) { this.twoWayAxis=false; this.pct_x = rect.getX(); @@ -51,6 +52,9 @@ public class Axis { this.parent = module; this.backgroundColor = background_color; this.indicatorColor = indicator_color; + this.x_invert = x_invert; + this.y_invert = y_invert; + this.axis_invert = axis_invert; } /** @@ -58,12 +62,13 @@ public class Axis { */ public Axis(Rectangle2D.Double rect, Controller parent_controller, - Identifier identifier, + Integer identifier, double starting_range, double ending_range, int orientation, Color background_color, Color indicator_color, + boolean x_invert, ControllerModule module) { this.twoWayAxis=true; this.pct_x = rect.getX(); @@ -80,6 +85,7 @@ public class Axis { this.orientation = orientation; this.backgroundColor = background_color; this.indicatorColor = indicator_color; + this.x_invert = x_invert; } public void draw(Graphics g) { @@ -92,6 +98,18 @@ public class Axis { } } + public boolean is_Xinverted() { + return x_invert; + } + + public boolean is_Yinverted() { + return y_invert; + } + + public boolean is_Axisinverted() { + return axis_invert; + } + public void setupBoundsRectangle(Rectangle2D.Double rect) { this.pct_x = rect.getX(); this.pct_y = rect.getY(); @@ -107,7 +125,7 @@ public class Axis { return backgroundColor; } - public List getIdentifiers() { + public List getIdentifiers() { return identifiers; } @@ -166,8 +184,9 @@ public class Axis { g.fillRect((int)x, (int)y, (int)xscale, (int)yscale); g.setColor(a.indicatorColor); double val = 0; - if (a.identifiers.size()>=1) { - val=a.parent_controller.getComponent(a.identifiers.get(0)).getPollData(); + if (a.identifiers.size()>=1 && a.identifiers.get(0)!=-1) { + val=a.parent_controller.getAxisValue(a.identifiers.get(0))*((a.x_invert)?-1:1); + //val=a.parent_controller.getComponent(a.identifiers.get(0)).getPollData(); } double val1 = a.range1; double val2 = a.range2; @@ -196,16 +215,11 @@ public class Axis { } else { double xval=0; double yval=0; - for (int i=0;i0 && a.identifiers.get(0)!=null) { + xval = a.parent_controller.getAxisValue(a.identifiers.get(0))*((a.x_invert)?-1:1); + } + if (a.identifiers.size()>1 && a.identifiers.get(1)!=null) { + yval = a.parent_controller.getAxisValue(a.identifiers.get(1))*((a.y_invert)?-1:1); } Color color_identity = g.getColor(); g.setColor(a.backgroundColor); @@ -219,4 +233,86 @@ public class Axis { g.setColor(color_identity); } } + + + + public String getSaveString() { + StringBuilder sb = new StringBuilder(); + sb.append(pct_x);sb.append(","); + sb.append(pct_y);sb.append(","); + sb.append(pct_width);sb.append(","); + sb.append(pct_height);sb.append(","); + sb.append(twoWayAxis);sb.append(","); + if (twoWayAxis) { + sb.append((identifiers.size()>0 && + identifiers.get(0)!=null)?identifiers.get(0):"null");sb.append(","); + sb.append(range1);sb.append(","); + sb.append(range2);sb.append(","); + sb.append(orientation);sb.append(","); + } else { + sb.append((identifiers.size()>0 && + identifiers.get(0)!=null)?identifiers.get(0):"null");sb.append(","); + sb.append((identifiers.size()>1 && + identifiers.get(1)!=null)?identifiers.get(1):"null");sb.append(","); + } + sb.append(backgroundColor.getRed());sb.append(","); + sb.append(backgroundColor.getGreen());sb.append(","); + sb.append(backgroundColor.getBlue());sb.append(","); + sb.append(backgroundColor.getAlpha());sb.append(","); + sb.append(indicatorColor.getRed());sb.append(","); + sb.append(indicatorColor.getGreen());sb.append(","); + sb.append(indicatorColor.getBlue());sb.append(","); + sb.append(indicatorColor.getAlpha());sb.append(","); + sb.append(x_invert);sb.append(","); + if (!twoWayAxis) { + sb.append(y_invert);sb.append(","); + sb.append(axis_invert); + } + return sb.toString(); + } + + public static Axis loadFromString(String s, Controller controller, ControllerModule module) { + String[] split = s.split(","); + int i=0; + Rectangle2D.Double rect = new Rectangle2D.Double(Double.parseDouble(split[i++]), Double.parseDouble(split[i++]), Double.parseDouble(split[i++]), Double.parseDouble(split[i++])); + boolean twoway = Boolean.parseBoolean(split[i++]); + if (twoway) { + return new Axis(rect,controller, + Integer.parseInt(split[i++]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + Integer.parseInt(split[i++]), + new Color(Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++])), + new Color(Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++])), + Boolean.parseBoolean(split[i++]), + module + ); + } else { + return new Axis(rect,controller, + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]), + new Color(Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++])), + new Color(Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++]),Integer.parseInt(split[i++])), + Boolean.parseBoolean(split[i++]), + Boolean.parseBoolean(split[i++]), + Boolean.parseBoolean(split[i++]), + module + ); + } + /*Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + controller, + GrabIdentifierFromString(split[i++],controller), + Float.parseFloat(split[i++]), + new Color( + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]) + ), + module, + Boolean.parseBoolean(split[i++]));*/ + } } diff --git a/src/sig/modules/Controller/Button.java b/src/sig/modules/Controller/Button.java index 71c422f..c530b86 100644 --- a/src/sig/modules/Controller/Button.java +++ b/src/sig/modules/Controller/Button.java @@ -4,9 +4,6 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.geom.Rectangle2D; -import net.java.games.input.Component.Identifier; -import net.java.games.input.Component; -import net.java.games.input.Controller; import sig.sigIRC; import sig.modules.ControllerModule; @@ -15,26 +12,26 @@ public class Button { double pct_y = 0; double pct_width = 0; double pct_height = 0; - Identifier ident; - float value; + int ident; + byte value; Controller parent_controller; Color pressed_col; ControllerModule parent; boolean square; - public Button(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module) { + public Button(Rectangle2D.Double rect, Controller parent_controller, int button_identifier, byte button_val, Color col, ControllerModule module) { this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,button_val,col,module,false); } - public Button(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module, boolean square) { + public Button(Rectangle2D.Double rect, Controller parent_controller, int button_identifier, byte button_val, Color col, ControllerModule module, boolean square) { this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,button_val,col,module,square); } - public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module) { + public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, int button_identifier, byte button_val, Color col, ControllerModule module) { this(pct_x,pct_y,pct_width,pct_height,parent_controller,button_identifier,button_val,col,module,false); } - public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module, boolean square) { + public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, int button_identifier, byte button_val, Color col, ControllerModule module, boolean square) { this.pct_x = pct_x; this.pct_y = pct_y; this.pct_width=pct_width; @@ -48,7 +45,7 @@ public class Button { } public void draw(Graphics g) { - if (parent_controller.getComponent(ident).getPollData()==value) { + if (parent_controller.getButtonValue(ident)==value) { Color col_identity = g.getColor(); g.setColor(pressed_col); if (square) { @@ -76,7 +73,7 @@ public class Button { sb.append(pct_y);sb.append(","); sb.append(pct_width);sb.append(","); sb.append(pct_height);sb.append(","); - sb.append(ident.getName());sb.append(","); + sb.append(ident);sb.append(","); sb.append(value);sb.append(","); sb.append(pressed_col.getRed());sb.append(","); sb.append(pressed_col.getGreen());sb.append(","); @@ -95,8 +92,8 @@ public class Button { Double.parseDouble(split[i++]), Double.parseDouble(split[i++]), controller, - GrabIdentifierFromString(split[i++],controller), - Float.parseFloat(split[i++]), + Integer.parseInt(split[i++]), + Byte.parseByte(split[i++]), new Color( Integer.parseInt(split[i++]), Integer.parseInt(split[i++]), @@ -106,14 +103,4 @@ public class Button { module, Boolean.parseBoolean(split[i++])); } - - private static Identifier GrabIdentifierFromString(String string, Controller controller) { - for (Component cp : controller.getComponents()) { - Identifier id = cp.getIdentifier(); - if (id.getName().equals(string)) { - return id; - } - } - return null; - } } diff --git a/src/sig/modules/Controller/Component.java b/src/sig/modules/Controller/Component.java new file mode 100644 index 0000000..0f38838 --- /dev/null +++ b/src/sig/modules/Controller/Component.java @@ -0,0 +1,25 @@ +package sig.modules.Controller; + +public class Component { + + public boolean isAnalog() { + // TODO Auto-generated method stub + return false; + } + + public float getPollData() { + // TODO Auto-generated method stub + return 0; + } + + public Identifier getIdentifier() { + // TODO Auto-generated method stub + return null; + } + + public String getName() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/sig/modules/Controller/ControlConfigurationWindow.java b/src/sig/modules/Controller/ControlConfigurationWindow.java index 021878a..a813080 100644 --- a/src/sig/modules/Controller/ControlConfigurationWindow.java +++ b/src/sig/modules/Controller/ControlConfigurationWindow.java @@ -37,9 +37,6 @@ import javax.swing.border.Border; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import net.java.games.input.Component; -import net.java.games.input.Component.Identifier; -import net.java.games.input.Controller; import sig.ColorPanel; import sig.sigIRC; import sig.modules.ControllerModule; @@ -47,7 +44,7 @@ import sig.modules.ControllerModule; public class ControlConfigurationWindow extends JFrame implements WindowListener{ DialogType dialog; List panels = new ArrayList(); - List analog_controller_components = new ArrayList(); + List analog_controller_components = new ArrayList(); List analog_controller_component_labels = new ArrayList(); ControllerModule module; DecimalFormat df = new DecimalFormat("0.000"); @@ -60,7 +57,10 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener Color axis_indicator_col = Color.WHITE; int axis_width=32,axis_height=32; JButton backgroundColor,indicatorColor; + boolean x_invert,y_invert,axis_invert; int orientation=0; //0=Left-to-Right, 1=Right-to-Left, 2=Bottom-to-Top, 3=Top-to-Bottom + JCheckBox width_invert,height_invert; + java.awt.Component extra_space; ActionListener checkboxListener = new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { @@ -78,7 +78,7 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener private void UncheckPreviouslyCheckedbox(ActionEvent ev) { for (int i=0;i ident=new ArrayList(); + List ident=new ArrayList(); ident.add(null); ident.add(null); int count=0; for (int i=0;i ca = new ArrayList(); + for (int i=0;i0) { + //System.out.println(controllers.get(0).outputAxes()+","+controllers.get(0).outputButtons()); + for (int i=0;i0) { for (String s : buttondata) { @@ -334,6 +343,17 @@ public class ControllerModule extends Module{ } } } + String[] axisdata = FileUtils.readFromFile(CONTROLLERPATH+"axis_data.txt"); + if (controllers.size()>0) { + for (String s : axisdata) { + if (s.length()>0) { + //System.out.println("Creating new axis using string "+s+"."); + Axis a = Axis.loadFromString(s, controllers.get(0), this); + a.setVisible(true); + axes.add(a); + } + } + } } private void AddAxis() { @@ -341,10 +361,15 @@ public class ControllerModule extends Module{ temporary_axis.setVisible(true); axes.add(temporary_axis); temporary_axis=null; + StringBuilder sb = new StringBuilder(); + for (Axis a : axes) { + sb.append(a.getSaveString()+"\n"); + } + FileUtils.writetoFile(new String[]{sb.toString()}, CONTROLLERPATH+"axis_data.txt"); } private void AddButton() { - buttons.add(new Button(stored_rect,controller,stored_controller_button,stored_controller_value,buttoncol,this)); + buttons.add(new Button(stored_rect,controller,stored_controller_button,(byte)stored_controller_value,buttoncol,this)); StringBuilder sb = new StringBuilder(); for (Button b : buttons) { sb.append(b.getSaveString()+"\n"); diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java index 407ad1c..7278803 100644 --- a/src/sig/sigIRC.java +++ b/src/sig/sigIRC.java @@ -267,16 +267,6 @@ public class sigIRC{ manager = new FileManager("update.png"); manager.verifyAndFetchFileFromServer(); manager = new FileManager("backcolor.png"); manager.verifyAndFetchFileFromServer(); manager = new FileManager("drag_bar.png"); manager.verifyAndFetchFileFromServer(); - if (controllermodule_enabled) { - manager = new FileManager("jinput-dx8.dll"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("jinput-dx8_64.dll"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("jinput-raw.dll"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("jinput-raw_64.dll"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("jinput-wintab.dll"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("libjinput-linux.so"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("libjinput-linux64.so"); manager.verifyAndFetchFileFromServer(); - manager = new FileManager("libjinput-osx.jnilib"); manager.verifyAndFetchFileFromServer(); - } DownloadProgramUpdate(); System.out.println("Downloaded Dependencies. "); } @@ -542,6 +532,8 @@ public class sigIRC{ } System.setProperty("sun.java2d.opengl", Boolean.toString(sigIRC.hardwareAcceleration)); JFrame f = new JFrame("sigIRCv2"); + f.setAutoRequestFocus(true); + f.toFront(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (sigIRC.overlayMode && !sigIRC.showWindowControls) { f.setUndecorated(true);