aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorendolf <[email protected]>2004-07-07 23:09:41 +0000
committerendolf <[email protected]>2004-07-07 23:09:41 +0000
commit45cfed89c4464a4fe2489e84fef01ccfaaa70574 (patch)
treebda7765c846656f79b007e3a22c48c4803a29812 /plugins
parent4e20995f4af9114fbee823e4f0e45ea09eb3448b (diff)
If a joystick hat isn't configured properly, or if it's digital, then the axis data is not -32676, 0 or 32767 it is -1, 0 or 1. Updated the hat object to reflect this.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@82 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins')
-rw-r--r--plugins/linux/src/java/net/java/games/input/LinuxDevice.java40
1 files changed, 22 insertions, 18 deletions
diff --git a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
index 7233ce4..5e4be01 100644
--- a/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
+++ b/plugins/linux/src/java/net/java/games/input/LinuxDevice.java
@@ -85,6 +85,18 @@ public class LinuxDevice extends AbstractController {
*/
private ArrayList axesArray = new ArrayList();
+ /** Creates a new instance of LinuxDevice
+ * @param nativeID The native ID of this device
+ * @param name The name of this device
+ * @param numButtons The number of buttons the devices has
+ * @param numRelAxes The number of raltive axes this device has
+ * @param numAbsAxes The number of absolute axes this device has
+ */
+ public LinuxDevice(int nativeID, String name, int numButtons, int numRelAxes, int numAbsAxes, Controller.Type type) {
+ this(nativeID, name, numButtons, numRelAxes, numAbsAxes);
+ typeGuess = type;
+ }
+
/** Creates a new instance of LinuxDevice
* @param nativeID The native ID of this device
* @param name The name of this device
@@ -407,10 +419,6 @@ public class LinuxDevice extends AbstractController {
private LinuxAxis createButton(int buttonNumber, int nativeButtonType) {
Axis.Identifier id = LinuxNativeTypesMap.getButtonID(nativeButtonType);
String name = LinuxNativeTypesMap.getButtonName(nativeButtonType);
- System.out.println("native button type: " + nativeButtonType + " id: " + id + " name: " + name);
- if(id!=null) {
- System.out.println("id.name: " + id.getName());
- }
if(name == null) {
name = "Uknown button";
id = new ButtonID(name);
@@ -467,12 +475,6 @@ public class LinuxDevice extends AbstractController {
private LinuxHat createHat(String name, int xAxisID, int yAxisID) {
return new LinuxHat(this, name, xAxisID, yAxisID);
}
-
- public Axis[] getButtons() {
- Axis[] buttonsCopy = new Axis[buttons.length];
- System.arraycopy(buttons, 0, buttonsCopy, 0, buttons.length);
- return buttonsCopy;
- }
/** Polls axes for data. Returns false if the controller is no longer valid.
* Polling reflects the current state of the device when polled.
@@ -644,6 +646,8 @@ public class LinuxDevice extends AbstractController {
public LinuxHat(LinuxDevice controller, String name, int xAxisID, int yAxisID) {
super(name, Axis.Identifier.POV);
+ System.out.println("Creating a Hat for device " + controller.getName() + " named " + name + " from axis " + xAxisID + " and " + yAxisID);
+
this.controller = controller;
this.xAxisID = xAxisID;
this.yAxisID = yAxisID;
@@ -701,21 +705,21 @@ public class LinuxDevice extends AbstractController {
if((newXAxisValue == 0) && (newYAxisValue == 0)) {
value = POV.OFF;
- } else if((newXAxisValue == 32767) && (newYAxisValue == 32767)) {
+ } else if((newXAxisValue > 0) && (newYAxisValue < 0)) {
value = POV.UP_RIGHT;
- } else if((newXAxisValue == 32767) && (newYAxisValue == 0)) {
+ } else if((newXAxisValue > 0) && (newYAxisValue == 0)) {
value = POV.RIGHT;
- } else if((newXAxisValue == 32767) && (newYAxisValue == -32767)) {
+ } else if((newXAxisValue > 0) && (newYAxisValue > 0)) {
value = POV.DOWN_RIGHT;
- } else if((newXAxisValue == 0) && (newYAxisValue == -32767)) {
+ } else if((newXAxisValue == 0) && (newYAxisValue > 0)) {
value = POV.DOWN;
- } else if((newXAxisValue == -32767) && (newYAxisValue == -32767)) {
+ } else if((newXAxisValue < 0) && (newYAxisValue > 0)) {
value = POV.DOWN_LEFT;
- } else if((newXAxisValue == -32767) && (newYAxisValue == 0)) {
+ } else if((newXAxisValue < 0) && (newYAxisValue == 0)) {
value = POV.LEFT;
- } else if((newXAxisValue == -32767) && (newYAxisValue == 32767)) {
+ } else if((newXAxisValue < 0) && (newYAxisValue < 0)) {
value = POV.UP_LEFT;
- } else if((newXAxisValue == 0) && (newYAxisValue == 32767)) {
+ } else if((newXAxisValue == 0) && (newYAxisValue < 0)) {
value = POV.UP;
}