Re-implemented controller input system using LWJGL instead. Controller
inputs now work outside of window focus.
This commit is contained in:
parent
93e062ad42
commit
e203715025
10
.classpath
10
.classpath
@ -5,7 +5,13 @@
|
|||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-io-2.5.jar"/>
|
<classpathentry kind="lib" path="lib/commons-io-2.5.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
|
<classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/jinput-2.0.5.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-glfw.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/jutils-1.0.0.jar"/>
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-glfw-natives-linux.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-glfw-natives-macos.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-glfw-natives-windows.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-natives-linux.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-natives-macos.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/git/sigIRCv2/lib/lwjgl-natives-windows.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
lib/lwjgl-glfw-natives-linux.jar
Normal file
BIN
lib/lwjgl-glfw-natives-linux.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-glfw-natives-macos.jar
Normal file
BIN
lib/lwjgl-glfw-natives-macos.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-glfw-natives-windows.jar
Normal file
BIN
lib/lwjgl-glfw-natives-windows.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-glfw.jar
Normal file
BIN
lib/lwjgl-glfw.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-natives-linux.jar
Normal file
BIN
lib/lwjgl-natives-linux.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-natives-macos.jar
Normal file
BIN
lib/lwjgl-natives-macos.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl-natives-windows.jar
Normal file
BIN
lib/lwjgl-natives-windows.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl.jar
Normal file
BIN
lib/lwjgl.jar
Normal file
Binary file not shown.
@ -15,8 +15,14 @@
|
|||||||
<fileset dir="${dir.jarfile}/bin"/>
|
<fileset dir="${dir.jarfile}/bin"/>
|
||||||
<zipfileset excludes="META-INF/*.SF" src="lib/commons-io-2.5.jar"/>
|
<zipfileset excludes="META-INF/*.SF" src="lib/commons-io-2.5.jar"/>
|
||||||
<zipfileset excludes="META-INF/*.SF" src="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
|
<zipfileset excludes="META-INF/*.SF" src="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
|
||||||
<zipfileset excludes="META-INF/*.SF" src="lib/jinput-2.0.5.jar"/>
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-glfw.jar"/>
|
||||||
<zipfileset excludes="META-INF/*.SF" src="lib/jutils-1.0.0.jar"/>
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-glfw-natives-linux.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-glfw-natives-windows.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-glfw-natives-macos.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-natives-linux.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-natives-windows.jar"/>
|
||||||
|
<zipfileset excludes="META-INF/*.SF" src="lib/lwjgl-natives-macos.jar"/>
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1 +1,2 @@
|
|||||||
java -jar ./sigIRCv2.jar -Djava.library.path=lib/
|
cd "C:\Users\Joshua Sigona\git\sigIRCv2\"
|
||||||
|
java -jar sigIRCv2.jar -Djinput.useDefaultPlugin=false -Djinput.plugins=net.java.games.input.DirectInputEnvironmentPlugin
|
||||||
|
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
@ -6,14 +6,11 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.sigIRC;
|
||||||
import sig.modules.ControllerModule;
|
import sig.modules.ControllerModule;
|
||||||
|
|
||||||
public class Axis {
|
public class Axis {
|
||||||
List<Identifier> identifiers = new ArrayList<Identifier>();
|
List<Integer> identifiers = new ArrayList<Integer>();
|
||||||
boolean twoWayAxis = false; //True = 4-way, False = 2-way
|
boolean twoWayAxis = false; //True = 4-way, False = 2-way
|
||||||
Color backgroundColor=Color.BLACK,indicatorColor=Color.WHITE;
|
Color backgroundColor=Color.BLACK,indicatorColor=Color.WHITE;
|
||||||
double pct_x = 0;
|
double pct_x = 0;
|
||||||
@ -25,16 +22,20 @@ public class Axis {
|
|||||||
double range1,range2; //Range of motion.
|
double range1,range2; //Range of motion.
|
||||||
int orientation; //0=Left-to-Right, 1=Right-to-Left, 2=Bottom-to-Top, 3=Top-to-Bottom
|
int orientation; //0=Left-to-Right, 1=Right-to-Left, 2=Bottom-to-Top, 3=Top-to-Bottom
|
||||||
boolean visible=false;
|
boolean visible=false;
|
||||||
|
boolean x_invert,y_invert,axis_invert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 4-way axis Constructor.
|
* 4-way axis Constructor.
|
||||||
*/
|
*/
|
||||||
public Axis(Rectangle2D.Double rect,
|
public Axis(Rectangle2D.Double rect,
|
||||||
Controller parent_controller,
|
Controller parent_controller,
|
||||||
Identifier identifier,
|
Integer identifier,
|
||||||
Identifier identifier2,
|
Integer identifier2,
|
||||||
Color background_color,
|
Color background_color,
|
||||||
Color indicator_color,
|
Color indicator_color,
|
||||||
|
boolean x_invert,
|
||||||
|
boolean y_invert,
|
||||||
|
boolean axis_invert,
|
||||||
ControllerModule module) {
|
ControllerModule module) {
|
||||||
this.twoWayAxis=false;
|
this.twoWayAxis=false;
|
||||||
this.pct_x = rect.getX();
|
this.pct_x = rect.getX();
|
||||||
@ -51,6 +52,9 @@ public class Axis {
|
|||||||
this.parent = module;
|
this.parent = module;
|
||||||
this.backgroundColor = background_color;
|
this.backgroundColor = background_color;
|
||||||
this.indicatorColor = indicator_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,
|
public Axis(Rectangle2D.Double rect,
|
||||||
Controller parent_controller,
|
Controller parent_controller,
|
||||||
Identifier identifier,
|
Integer identifier,
|
||||||
double starting_range,
|
double starting_range,
|
||||||
double ending_range,
|
double ending_range,
|
||||||
int orientation,
|
int orientation,
|
||||||
Color background_color,
|
Color background_color,
|
||||||
Color indicator_color,
|
Color indicator_color,
|
||||||
|
boolean x_invert,
|
||||||
ControllerModule module) {
|
ControllerModule module) {
|
||||||
this.twoWayAxis=true;
|
this.twoWayAxis=true;
|
||||||
this.pct_x = rect.getX();
|
this.pct_x = rect.getX();
|
||||||
@ -80,6 +85,7 @@ public class Axis {
|
|||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.backgroundColor = background_color;
|
this.backgroundColor = background_color;
|
||||||
this.indicatorColor = indicator_color;
|
this.indicatorColor = indicator_color;
|
||||||
|
this.x_invert = x_invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
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) {
|
public void setupBoundsRectangle(Rectangle2D.Double rect) {
|
||||||
this.pct_x = rect.getX();
|
this.pct_x = rect.getX();
|
||||||
this.pct_y = rect.getY();
|
this.pct_y = rect.getY();
|
||||||
@ -107,7 +125,7 @@ public class Axis {
|
|||||||
return backgroundColor;
|
return backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Identifier> getIdentifiers() {
|
public List<Integer> getIdentifiers() {
|
||||||
return identifiers;
|
return identifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +184,9 @@ public class Axis {
|
|||||||
g.fillRect((int)x, (int)y, (int)xscale, (int)yscale);
|
g.fillRect((int)x, (int)y, (int)xscale, (int)yscale);
|
||||||
g.setColor(a.indicatorColor);
|
g.setColor(a.indicatorColor);
|
||||||
double val = 0;
|
double val = 0;
|
||||||
if (a.identifiers.size()>=1) {
|
if (a.identifiers.size()>=1 && a.identifiers.get(0)!=-1) {
|
||||||
val=a.parent_controller.getComponent(a.identifiers.get(0)).getPollData();
|
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 val1 = a.range1;
|
||||||
double val2 = a.range2;
|
double val2 = a.range2;
|
||||||
@ -196,16 +215,11 @@ public class Axis {
|
|||||||
} else {
|
} else {
|
||||||
double xval=0;
|
double xval=0;
|
||||||
double yval=0;
|
double yval=0;
|
||||||
for (int i=0;i<a.identifiers.size();i++) {
|
if (a.identifiers.size()>0 && a.identifiers.get(0)!=null) {
|
||||||
Identifier ident = a.identifiers.get(i);
|
xval = a.parent_controller.getAxisValue(a.identifiers.get(0))*((a.x_invert)?-1:1);
|
||||||
if (ident.getName().contains("x") ||
|
}
|
||||||
ident.getName().contains("X")) {
|
if (a.identifiers.size()>1 && a.identifiers.get(1)!=null) {
|
||||||
xval = a.parent_controller.getComponent(ident).getPollData();
|
yval = a.parent_controller.getAxisValue(a.identifiers.get(1))*((a.y_invert)?-1:1);
|
||||||
} else
|
|
||||||
if (ident.getName().contains("y") ||
|
|
||||||
ident.getName().contains("Y")) {
|
|
||||||
yval = a.parent_controller.getComponent(ident).getPollData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Color color_identity = g.getColor();
|
Color color_identity = g.getColor();
|
||||||
g.setColor(a.backgroundColor);
|
g.setColor(a.backgroundColor);
|
||||||
@ -219,4 +233,86 @@ public class Axis {
|
|||||||
g.setColor(color_identity);
|
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++]));*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.geom.Rectangle2D;
|
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.sigIRC;
|
||||||
import sig.modules.ControllerModule;
|
import sig.modules.ControllerModule;
|
||||||
|
|
||||||
@ -15,26 +12,26 @@ public class Button {
|
|||||||
double pct_y = 0;
|
double pct_y = 0;
|
||||||
double pct_width = 0;
|
double pct_width = 0;
|
||||||
double pct_height = 0;
|
double pct_height = 0;
|
||||||
Identifier ident;
|
int ident;
|
||||||
float value;
|
byte value;
|
||||||
Controller parent_controller;
|
Controller parent_controller;
|
||||||
Color pressed_col;
|
Color pressed_col;
|
||||||
ControllerModule parent;
|
ControllerModule parent;
|
||||||
boolean square;
|
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);
|
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);
|
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);
|
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_x = pct_x;
|
||||||
this.pct_y = pct_y;
|
this.pct_y = pct_y;
|
||||||
this.pct_width=pct_width;
|
this.pct_width=pct_width;
|
||||||
@ -48,7 +45,7 @@ public class Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
if (parent_controller.getComponent(ident).getPollData()==value) {
|
if (parent_controller.getButtonValue(ident)==value) {
|
||||||
Color col_identity = g.getColor();
|
Color col_identity = g.getColor();
|
||||||
g.setColor(pressed_col);
|
g.setColor(pressed_col);
|
||||||
if (square) {
|
if (square) {
|
||||||
@ -76,7 +73,7 @@ public class Button {
|
|||||||
sb.append(pct_y);sb.append(",");
|
sb.append(pct_y);sb.append(",");
|
||||||
sb.append(pct_width);sb.append(",");
|
sb.append(pct_width);sb.append(",");
|
||||||
sb.append(pct_height);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(value);sb.append(",");
|
||||||
sb.append(pressed_col.getRed());sb.append(",");
|
sb.append(pressed_col.getRed());sb.append(",");
|
||||||
sb.append(pressed_col.getGreen());sb.append(",");
|
sb.append(pressed_col.getGreen());sb.append(",");
|
||||||
@ -95,8 +92,8 @@ public class Button {
|
|||||||
Double.parseDouble(split[i++]),
|
Double.parseDouble(split[i++]),
|
||||||
Double.parseDouble(split[i++]),
|
Double.parseDouble(split[i++]),
|
||||||
controller,
|
controller,
|
||||||
GrabIdentifierFromString(split[i++],controller),
|
Integer.parseInt(split[i++]),
|
||||||
Float.parseFloat(split[i++]),
|
Byte.parseByte(split[i++]),
|
||||||
new Color(
|
new Color(
|
||||||
Integer.parseInt(split[i++]),
|
Integer.parseInt(split[i++]),
|
||||||
Integer.parseInt(split[i++]),
|
Integer.parseInt(split[i++]),
|
||||||
@ -106,14 +103,4 @@ public class Button {
|
|||||||
module,
|
module,
|
||||||
Boolean.parseBoolean(split[i++]));
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
25
src/sig/modules/Controller/Component.java
Normal file
25
src/sig/modules/Controller/Component.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -37,9 +37,6 @@ import javax.swing.border.Border;
|
|||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
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.ColorPanel;
|
||||||
import sig.sigIRC;
|
import sig.sigIRC;
|
||||||
import sig.modules.ControllerModule;
|
import sig.modules.ControllerModule;
|
||||||
@ -47,7 +44,7 @@ import sig.modules.ControllerModule;
|
|||||||
public class ControlConfigurationWindow extends JFrame implements WindowListener{
|
public class ControlConfigurationWindow extends JFrame implements WindowListener{
|
||||||
DialogType dialog;
|
DialogType dialog;
|
||||||
List<JPanel> panels = new ArrayList<JPanel>();
|
List<JPanel> panels = new ArrayList<JPanel>();
|
||||||
List<Component> analog_controller_components = new ArrayList<Component>();
|
List<Integer> analog_controller_components = new ArrayList<Integer>();
|
||||||
List<JCheckBox> analog_controller_component_labels = new ArrayList<JCheckBox>();
|
List<JCheckBox> analog_controller_component_labels = new ArrayList<JCheckBox>();
|
||||||
ControllerModule module;
|
ControllerModule module;
|
||||||
DecimalFormat df = new DecimalFormat("0.000");
|
DecimalFormat df = new DecimalFormat("0.000");
|
||||||
@ -60,7 +57,10 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
Color axis_indicator_col = Color.WHITE;
|
Color axis_indicator_col = Color.WHITE;
|
||||||
int axis_width=32,axis_height=32;
|
int axis_width=32,axis_height=32;
|
||||||
JButton backgroundColor,indicatorColor;
|
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
|
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(){
|
ActionListener checkboxListener = new ActionListener(){
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ev) {
|
public void actionPerformed(ActionEvent ev) {
|
||||||
@ -78,7 +78,7 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
|
|
||||||
private void UncheckPreviouslyCheckedbox(ActionEvent ev) {
|
private void UncheckPreviouslyCheckedbox(ActionEvent ev) {
|
||||||
for (int i=0;i<analog_controller_components.size();i++) {
|
for (int i=0;i<analog_controller_components.size();i++) {
|
||||||
if (analog_controller_components.get(i).getName().equals(ev.getActionCommand())) {
|
if (Integer.toString(analog_controller_components.get(i)).equals(ev.getActionCommand())) {
|
||||||
analog_controller_component_labels.get(i).setSelected(false);
|
analog_controller_component_labels.get(i).setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,6 +93,7 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
previewpanel.setAxis(false);
|
previewpanel.setAxis(false);
|
||||||
twowayAxis_adjustContainer.setVisible(false);
|
twowayAxis_adjustContainer.setVisible(false);
|
||||||
twowayAxis_adjustOrientationContainer.setVisible(false);
|
twowayAxis_adjustOrientationContainer.setVisible(false);
|
||||||
|
height_invert.setVisible(true);
|
||||||
}break;
|
}break;
|
||||||
case "two":{
|
case "two":{
|
||||||
previewpanel.setAxis(true);
|
previewpanel.setAxis(true);
|
||||||
@ -108,8 +109,10 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
}
|
}
|
||||||
twowayAxis_adjustContainer.setVisible(true);
|
twowayAxis_adjustContainer.setVisible(true);
|
||||||
twowayAxis_adjustOrientationContainer.setVisible(true);
|
twowayAxis_adjustOrientationContainer.setVisible(true);
|
||||||
|
height_invert.setVisible(false);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
extra_space.setVisible(two_axis_button.isSelected());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ActionListener backgroundColorListener = new ActionListener(){
|
ActionListener backgroundColorListener = new ActionListener(){
|
||||||
@ -156,6 +159,16 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
ActionListener invertListener = new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent ev) {
|
||||||
|
if (ev.getActionCommand().equals("x")) {
|
||||||
|
x_invert=width_invert.isSelected();
|
||||||
|
} else {
|
||||||
|
y_invert=height_invert.isSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ControlConfigurationWindow(DialogType type, ControllerModule parent_module) {
|
public ControlConfigurationWindow(DialogType type, ControllerModule parent_module) {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
@ -222,20 +235,19 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
selectionPanel2.setBackground(new Color(0,0,255,96));
|
selectionPanel2.setBackground(new Color(0,0,255,96));
|
||||||
int counter=0;
|
int counter=0;
|
||||||
for (Controller c : module.getControllers()) {
|
for (Controller c : module.getControllers()) {
|
||||||
for (Component cp : c.getComponents()) {
|
for (int i=0;i<c.getAxes().length;i++) {
|
||||||
if (cp.isAnalog()) {
|
float axis = c.getAxisValue(i);
|
||||||
analog_controller_components.add(cp);
|
analog_controller_components.add(i);
|
||||||
JCheckBox component_checkbox = new JCheckBox(GetComponentValue(cp),false);
|
JCheckBox component_checkbox = new JCheckBox(GetComponentValue(i),false);
|
||||||
component_checkbox.setActionCommand(cp.getName());
|
component_checkbox.setActionCommand(Integer.toString(i));
|
||||||
component_checkbox.addActionListener(checkboxListener);
|
component_checkbox.addActionListener(checkboxListener);
|
||||||
analog_controller_component_labels.add(component_checkbox);
|
analog_controller_component_labels.add(component_checkbox);
|
||||||
axisPanel.add(component_checkbox);
|
axisPanel.add(component_checkbox);
|
||||||
counter=Math.floorMod(counter+1, 5);
|
counter=Math.floorMod(counter+1, 5);
|
||||||
if (counter==0) {
|
if (counter==0) {
|
||||||
panels.add(axisPanel);
|
panels.add(axisPanel);
|
||||||
axisPanel = new JPanel();
|
axisPanel = new JPanel();
|
||||||
axisPanel.setLayout(new BoxLayout(axisPanel,BoxLayout.LINE_AXIS));
|
axisPanel.setLayout(new BoxLayout(axisPanel,BoxLayout.LINE_AXIS));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,21 +296,45 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
|
|
||||||
Container sizePanel = new Container();
|
Container sizePanel = new Container();
|
||||||
sizePanel.setLayout(new BoxLayout(sizePanel,BoxLayout.PAGE_AXIS));
|
sizePanel.setLayout(new BoxLayout(sizePanel,BoxLayout.PAGE_AXIS));
|
||||||
|
JPanel widthPanel = new JPanel();
|
||||||
|
widthPanel.setLayout(new BoxLayout(widthPanel,BoxLayout.LINE_AXIS));
|
||||||
|
widthPanel.setPreferredSize(new Dimension(164,20));
|
||||||
|
JPanel heightPanel = new JPanel();
|
||||||
|
heightPanel.setPreferredSize(new Dimension(164,20));
|
||||||
|
heightPanel.setLayout(new BoxLayout(heightPanel,BoxLayout.LINE_AXIS));
|
||||||
JLabel widthLabel = new JLabel("Width: ");
|
JLabel widthLabel = new JLabel("Width: ");
|
||||||
JTextField width_field = new JTextField("32",3);
|
JTextField width_field = new JTextField("32",3);
|
||||||
|
width_field.setPreferredSize(new Dimension(32,20));
|
||||||
|
width_field.setMaximumSize(new Dimension(32,20));
|
||||||
|
width_invert = new JCheckBox("Inverted");
|
||||||
|
width_invert.addActionListener(invertListener);
|
||||||
|
width_invert.setActionCommand("x");
|
||||||
ResizeTextField width_field_listener = new ResizeTextField(width_field,this,SizeType.WIDTH);
|
ResizeTextField width_field_listener = new ResizeTextField(width_field,this,SizeType.WIDTH);
|
||||||
width_field.getDocument().addDocumentListener(width_field_listener);
|
width_field.getDocument().addDocumentListener(width_field_listener);
|
||||||
JLabel heightLabel = new JLabel("Height: ");
|
JLabel heightLabel = new JLabel("Height: ");
|
||||||
JTextField height_field = new JTextField("32",3);
|
JTextField height_field = new JTextField("32",3);
|
||||||
|
height_field.setPreferredSize(new Dimension(32,20));
|
||||||
|
height_field.setMaximumSize(new Dimension(32,20));
|
||||||
|
height_invert = new JCheckBox("Inverted");
|
||||||
|
height_invert.addActionListener(invertListener);
|
||||||
|
extra_space = Box.createRigidArea(height_invert.getMaximumSize());
|
||||||
|
extra_space.setVisible(two_axis_button.isSelected());
|
||||||
|
width_invert.setActionCommand("y");
|
||||||
ResizeTextField height_field_listener = new ResizeTextField(height_field,this,SizeType.HEIGHT);
|
ResizeTextField height_field_listener = new ResizeTextField(height_field,this,SizeType.HEIGHT);
|
||||||
height_field.getDocument().addDocumentListener(height_field_listener);
|
height_field.getDocument().addDocumentListener(height_field_listener);
|
||||||
|
|
||||||
sizePanel.add(widthLabel);
|
widthPanel.add(widthLabel);
|
||||||
sizePanel.add(width_field);
|
widthPanel.add(width_field);
|
||||||
sizePanel.add(Box.createRigidArea(new Dimension(4,0)));
|
widthPanel.add(width_invert);
|
||||||
sizePanel.add(heightLabel);
|
heightPanel.add(heightLabel);
|
||||||
sizePanel.add(height_field);
|
heightPanel.add(height_field);
|
||||||
sizePanel.setPreferredSize(new Dimension(56,96));
|
heightPanel.add(height_invert);
|
||||||
|
heightPanel.add(extra_space);
|
||||||
|
|
||||||
|
sizePanel.add(widthPanel);
|
||||||
|
sizePanel.add(Box.createRigidArea(new Dimension(0,8)));
|
||||||
|
sizePanel.add(heightPanel);
|
||||||
|
sizePanel.setPreferredSize(new Dimension(164,64));
|
||||||
|
|
||||||
ButtonGroup twoWayAxisOrientationGroup = new ButtonGroup();
|
ButtonGroup twoWayAxisOrientationGroup = new ButtonGroup();
|
||||||
JRadioButton twoWayAxis_LeftToRight = new JRadioButton("Left-to-Right",true);
|
JRadioButton twoWayAxis_LeftToRight = new JRadioButton("Left-to-Right",true);
|
||||||
@ -389,8 +425,9 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetComponentValue(Component component) {
|
private String GetComponentValue(int axis) {
|
||||||
return component.getName()+": "+df.format(component.getPollData())+" ";
|
float val = module.getControllers().get(0).getAxisValue(axis);
|
||||||
|
return "Axis "+axis+": "+df.format(val)+" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -443,10 +480,10 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
protected Axis ConstructTemporaryAxis() {
|
protected Axis ConstructTemporaryAxis() {
|
||||||
Axis a;
|
Axis a;
|
||||||
if (two_axis_button.isSelected()) {
|
if (two_axis_button.isSelected()) {
|
||||||
Identifier ident=null;
|
int ident=-1;
|
||||||
for (int i=0;i<analog_controller_component_labels.size();i++) {
|
for (int i=0;i<analog_controller_component_labels.size();i++) {
|
||||||
if (analog_controller_component_labels.get(i).isSelected()) {
|
if (analog_controller_component_labels.get(i).isSelected()) {
|
||||||
ident=analog_controller_components.get(i).getIdentifier();
|
ident=analog_controller_components.get(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,15 +495,16 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
orientation,
|
orientation,
|
||||||
axis_background_col,
|
axis_background_col,
|
||||||
axis_indicator_col,
|
axis_indicator_col,
|
||||||
|
x_invert,
|
||||||
module);
|
module);
|
||||||
} else {
|
} else {
|
||||||
List<Identifier> ident=new ArrayList<Identifier>();
|
List<Integer> ident=new ArrayList<Integer>();
|
||||||
ident.add(null);
|
ident.add(null);
|
||||||
ident.add(null);
|
ident.add(null);
|
||||||
int count=0;
|
int count=0;
|
||||||
for (int i=0;i<analog_controller_component_labels.size();i++) {
|
for (int i=0;i<analog_controller_component_labels.size();i++) {
|
||||||
if (analog_controller_component_labels.get(i).isSelected()) {
|
if (analog_controller_component_labels.get(i).isSelected()) {
|
||||||
ident.set(count++,analog_controller_components.get(i).getIdentifier());
|
ident.set(count++,analog_controller_components.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = new Axis(new Rectangle2D.Double(),
|
a = new Axis(new Rectangle2D.Double(),
|
||||||
@ -475,6 +513,9 @@ public class ControlConfigurationWindow extends JFrame implements WindowListener
|
|||||||
ident.get(1),
|
ident.get(1),
|
||||||
axis_background_col,
|
axis_background_col,
|
||||||
axis_indicator_col,
|
axis_indicator_col,
|
||||||
|
x_invert,
|
||||||
|
y_invert,
|
||||||
|
axis_invert,
|
||||||
module);
|
module);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
|
80
src/sig/modules/Controller/Controller.java
Normal file
80
src/sig/modules/Controller/Controller.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package sig.modules.Controller;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
|
||||||
|
public class Controller {
|
||||||
|
int identifier;
|
||||||
|
float[] axes;
|
||||||
|
byte[] buttons;
|
||||||
|
|
||||||
|
public Controller(int identifier) {
|
||||||
|
this.identifier=identifier;
|
||||||
|
FloatBuffer axisBuffer = GLFW.glfwGetJoystickAxes(identifier);
|
||||||
|
axes = new float[axisBuffer.limit()];
|
||||||
|
axisBuffer.get(axes);
|
||||||
|
ByteBuffer buttonBuffer = GLFW.glfwGetJoystickButtons(identifier);
|
||||||
|
buttons = new byte[buttonBuffer.limit()];
|
||||||
|
buttonBuffer.get(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String outputAxes() {
|
||||||
|
return Arrays.toString(axes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String outputButtons() {
|
||||||
|
return Arrays.toString(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] getAxes() {
|
||||||
|
return axes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getButtons() {
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAxisValue(int axisNumber) {
|
||||||
|
return axes[axisNumber];
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getButtonValue(int buttonNumber) {
|
||||||
|
return buttons[buttonNumber];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Type getType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void poll() {
|
||||||
|
//System.out.println(Glfw.glfwGetJoystickParam(identifier, 1));
|
||||||
|
FloatBuffer axisBuffer = GLFW.glfwGetJoystickAxes(identifier);
|
||||||
|
axes = new float[axisBuffer.limit()];
|
||||||
|
axisBuffer.get(axes);
|
||||||
|
ByteBuffer buttonBuffer = GLFW.glfwGetJoystickButtons(identifier);
|
||||||
|
buttons = new byte[buttonBuffer.limit()];
|
||||||
|
buttonBuffer.get(buttons);
|
||||||
|
//System.out.println(outputAxes()+","+outputButtons());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Component[] getComponents() {
|
||||||
|
return new Component[]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Component getComponent(Identifier identifier2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
src/sig/modules/Controller/Identifier.java
Normal file
11
src/sig/modules/Controller/Identifier.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package sig.modules.Controller;
|
||||||
|
|
||||||
|
import java.awt.geom.RectangularShape;
|
||||||
|
|
||||||
|
public class Identifier {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5
src/sig/modules/Controller/Type.java
Normal file
5
src/sig/modules/Controller/Type.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package sig.modules.Controller;
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
GAMEPAD
|
||||||
|
}
|
@ -7,6 +7,7 @@ import java.awt.Image;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -15,18 +16,19 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import net.java.games.input.Component;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import net.java.games.input.Component.Identifier;
|
|
||||||
import net.java.games.input.Controller;
|
|
||||||
import net.java.games.input.Controller.Type;
|
|
||||||
import net.java.games.input.ControllerEnvironment;
|
|
||||||
import sig.Module;
|
import sig.Module;
|
||||||
import sig.sigIRC;
|
import sig.sigIRC;
|
||||||
import sig.modules.Controller.Axis;
|
import sig.modules.Controller.Axis;
|
||||||
import sig.modules.Controller.Button;
|
import sig.modules.Controller.Button;
|
||||||
import sig.modules.Controller.ClickableButton;
|
import sig.modules.Controller.ClickableButton;
|
||||||
|
import sig.modules.Controller.Component;
|
||||||
import sig.modules.Controller.ControlConfigurationWindow;
|
import sig.modules.Controller.ControlConfigurationWindow;
|
||||||
|
import sig.modules.Controller.Controller;
|
||||||
import sig.modules.Controller.EditMode;
|
import sig.modules.Controller.EditMode;
|
||||||
|
import sig.modules.Controller.Identifier;
|
||||||
|
import sig.modules.Controller.Type;
|
||||||
import sig.modules.Controller.clickablebutton.AddClickableButton;
|
import sig.modules.Controller.clickablebutton.AddClickableButton;
|
||||||
import sig.modules.Controller.clickablebutton.CopyClickableButton;
|
import sig.modules.Controller.clickablebutton.CopyClickableButton;
|
||||||
import sig.utils.DrawUtils;
|
import sig.utils.DrawUtils;
|
||||||
@ -44,7 +46,7 @@ public class ControllerModule extends Module{
|
|||||||
String status = "";
|
String status = "";
|
||||||
Point start_drag,end_drag;
|
Point start_drag,end_drag;
|
||||||
Rectangle2D.Double stored_rect;
|
Rectangle2D.Double stored_rect;
|
||||||
Identifier stored_controller_button;
|
int stored_controller_button;
|
||||||
float stored_controller_value;
|
float stored_controller_value;
|
||||||
Color buttoncol;
|
Color buttoncol;
|
||||||
Controller controller;
|
Controller controller;
|
||||||
@ -54,18 +56,21 @@ public class ControllerModule extends Module{
|
|||||||
|
|
||||||
public ControllerModule(Rectangle2D bounds, String moduleName) {
|
public ControllerModule(Rectangle2D bounds, String moduleName) {
|
||||||
super(bounds, moduleName);
|
super(bounds, moduleName);
|
||||||
Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
if (!GLFW.glfwInit()) {
|
||||||
for (Controller c : ca) {
|
System.out.println("Failed to initialize GLFW!");
|
||||||
if (c.getType()==Type.GAMEPAD) {
|
} else {
|
||||||
controllers.add(c);
|
System.out.println("Successfully initialized GLFW.");
|
||||||
System.out.println("Recognized "+c.getName()+": "+c.getType());
|
|
||||||
//System.out.println("Components: ");
|
|
||||||
/*for (Component cp : c.getComponents()) {
|
|
||||||
System.out.println(" "+cp.getName()+" ("+cp.getIdentifier().getName()+")");
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
//System.out.println(c.getName()+": "+c.getType());
|
|
||||||
}
|
}
|
||||||
|
List<Controller> ca = new ArrayList<Controller>();
|
||||||
|
for (int i=0;i<GLFW.GLFW_JOYSTICK_LAST;i++) {
|
||||||
|
//System.out.println("Joystick "+i+": "+GLFW.glfwGetJoystickName(i));
|
||||||
|
if (GLFW.glfwGetJoystickName(i)!=null) {
|
||||||
|
Controller c = new Controller(i);
|
||||||
|
ca.add(c);
|
||||||
|
System.out.println("Recognized "+GLFW.glfwGetJoystickName(i)+": "+c.outputAxes()+","+c.outputButtons());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controllers.addAll(ca);
|
||||||
try {
|
try {
|
||||||
controller_img = ImageIO.read(new File(CONTROLLERPATH+"controller_template.png")).getScaledInstance((int)position.getWidth(), -1, 0);
|
controller_img = ImageIO.read(new File(CONTROLLERPATH+"controller_template.png")).getScaledInstance((int)position.getWidth(), -1, 0);
|
||||||
//System.out.println("Size of controller: "+controller_img.getWidth(sigIRC.panel)+","+controller_img.getHeight(sigIRC.panel));
|
//System.out.println("Size of controller: "+controller_img.getWidth(sigIRC.panel)+","+controller_img.getHeight(sigIRC.panel));
|
||||||
@ -73,7 +78,7 @@ public class ControllerModule extends Module{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//buttons.add(new Button(0.1,0.05,0.1,0.05,controllers.get(0),Identifier.Button._3,Color.RED,this));
|
//buttons.add(new Button(0.1,0.05,0.1,0.05,controllers.get(0),Identifier.Button._3,Color.RED,this));
|
||||||
LoadButtonData();
|
LoadButtonAndAxisData();
|
||||||
click_buttons.add(new AddClickableButton(new Rectangle(
|
click_buttons.add(new AddClickableButton(new Rectangle(
|
||||||
0,(int)position.getHeight()-41,96,20),"Add Button",this));
|
0,(int)position.getHeight()-41,96,20),"Add Button",this));
|
||||||
click_buttons.add(new CopyClickableButton(new Rectangle(
|
click_buttons.add(new CopyClickableButton(new Rectangle(
|
||||||
@ -236,12 +241,13 @@ public class ControllerModule extends Module{
|
|||||||
}
|
}
|
||||||
super.run();
|
super.run();
|
||||||
if (MODE==EditMode.BUTTONSET) {
|
if (MODE==EditMode.BUTTONSET) {
|
||||||
stored_controller_button=null;
|
stored_controller_button=-1;
|
||||||
for (Controller c : controllers) {
|
for (Controller c : controllers) {
|
||||||
for (Component cp : c.getComponents()) {
|
for (int i=0;i<c.getButtons().length;i++) {
|
||||||
if (!cp.isAnalog() && cp.getPollData()!=0.0f) {
|
byte b = c.getButtonValue(i);
|
||||||
stored_controller_button = cp.getIdentifier();
|
if (b!=(byte)0) {
|
||||||
stored_controller_value = cp.getPollData();
|
stored_controller_button = i;
|
||||||
|
stored_controller_value = b;
|
||||||
controller=c;
|
controller=c;
|
||||||
MODE=EditMode.COLORSET;
|
MODE=EditMode.COLORSET;
|
||||||
buttoncol = PopupColorPanel();
|
buttoncol = PopupColorPanel();
|
||||||
@ -250,7 +256,7 @@ public class ControllerModule extends Module{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stored_controller_button!=null) {
|
if (stored_controller_button!=-1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,16 +272,19 @@ public class ControllerModule extends Module{
|
|||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
super.draw(g);
|
super.draw(g);
|
||||||
for (int i=0;i<controllers.get(0).getComponents().length;i++) {
|
if (controllers.size()>0) {
|
||||||
Component cp = controllers.get(0).getComponents()[i];
|
//System.out.println(controllers.get(0).outputAxes()+","+controllers.get(0).outputButtons());
|
||||||
/*if (!cp.isAnalog()) {
|
for (int i=0;i<controllers.get(0).getComponents().length;i++) {
|
||||||
if (cp.getPollData()!=0) {
|
Component cp = controllers.get(0).getComponents()[i];
|
||||||
//System.out.println("Button "+cp.getIdentifier()+" held down! Value: "+cp.getPollData());
|
/*if (!cp.isAnalog()) {
|
||||||
//DrawUtils.drawText(g,position.getX(),position.getY(),Color.BLACK,"Button "+cp.getIdentifier()+" held down!");
|
if (cp.getPollData()!=0) {
|
||||||
}
|
//System.out.println("Button "+cp.getIdentifier()+" held down! Value: "+cp.getPollData());
|
||||||
}*/
|
//DrawUtils.drawText(g,position.getX(),position.getY(),Color.BLACK,"Button "+cp.getIdentifier()+" held down!");
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
g.drawImage(controller_img, (int)(position.getX()), (int)(position.getY()), sigIRC.panel);
|
||||||
}
|
}
|
||||||
g.drawImage(controller_img, (int)(position.getX()), (int)(position.getY()), sigIRC.panel);
|
|
||||||
DrawUtils.drawText(g, position.getX(), position.getY()+8, Color.BLACK, status);
|
DrawUtils.drawText(g, position.getX(), position.getY()+8, Color.BLACK, status);
|
||||||
for (Button b : buttons) {
|
for (Button b : buttons) {
|
||||||
b.draw(g);
|
b.draw(g);
|
||||||
@ -325,7 +334,7 @@ public class ControllerModule extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadButtonData() {
|
private void LoadButtonAndAxisData() {
|
||||||
String[] buttondata = FileUtils.readFromFile(CONTROLLERPATH+"button_data.txt");
|
String[] buttondata = FileUtils.readFromFile(CONTROLLERPATH+"button_data.txt");
|
||||||
if (controllers.size()>0) {
|
if (controllers.size()>0) {
|
||||||
for (String s : buttondata) {
|
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() {
|
private void AddAxis() {
|
||||||
@ -341,10 +361,15 @@ public class ControllerModule extends Module{
|
|||||||
temporary_axis.setVisible(true);
|
temporary_axis.setVisible(true);
|
||||||
axes.add(temporary_axis);
|
axes.add(temporary_axis);
|
||||||
temporary_axis=null;
|
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() {
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Button b : buttons) {
|
for (Button b : buttons) {
|
||||||
sb.append(b.getSaveString()+"\n");
|
sb.append(b.getSaveString()+"\n");
|
||||||
|
@ -267,16 +267,6 @@ public class sigIRC{
|
|||||||
manager = new FileManager("update.png"); manager.verifyAndFetchFileFromServer();
|
manager = new FileManager("update.png"); manager.verifyAndFetchFileFromServer();
|
||||||
manager = new FileManager("backcolor.png"); manager.verifyAndFetchFileFromServer();
|
manager = new FileManager("backcolor.png"); manager.verifyAndFetchFileFromServer();
|
||||||
manager = new FileManager("drag_bar.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();
|
DownloadProgramUpdate();
|
||||||
System.out.println("Downloaded Dependencies. ");
|
System.out.println("Downloaded Dependencies. ");
|
||||||
}
|
}
|
||||||
@ -542,6 +532,8 @@ public class sigIRC{
|
|||||||
}
|
}
|
||||||
System.setProperty("sun.java2d.opengl", Boolean.toString(sigIRC.hardwareAcceleration));
|
System.setProperty("sun.java2d.opengl", Boolean.toString(sigIRC.hardwareAcceleration));
|
||||||
JFrame f = new JFrame("sigIRCv2");
|
JFrame f = new JFrame("sigIRCv2");
|
||||||
|
f.setAutoRequestFocus(true);
|
||||||
|
f.toFront();
|
||||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
if (sigIRC.overlayMode && !sigIRC.showWindowControls) {
|
if (sigIRC.overlayMode && !sigIRC.showWindowControls) {
|
||||||
f.setUndecorated(true);
|
f.setUndecorated(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user