aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/windows
diff options
context:
space:
mode:
authorelias <[email protected]>2006-08-22 21:20:35 +0000
committerelias <[email protected]>2006-08-22 21:20:35 +0000
commitc126186f7bb604961ed6b3fd73715c31a289e41e (patch)
treefa5b27ecbc00805256ad517c89d8ff0693bb9e0a /plugins/windows
parent20d35b279349a250d5ba14c63a6a795ef80da340 (diff)
DirectInput: Fix an issue with mice devices and DIDF_ABSAXIS axis mode. Now DIDF_RELAXIS is chosen if all device axes are relative.
git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@163 e343933a-64c8-49c5-92b1-88f2ce3e89e8
Diffstat (limited to 'plugins/windows')
-rw-r--r--plugins/windows/src/java/net/java/games/input/DIDeviceObject.java6
-rw-r--r--plugins/windows/src/java/net/java/games/input/IDirectInputDevice.java26
2 files changed, 29 insertions, 3 deletions
diff --git a/plugins/windows/src/java/net/java/games/input/DIDeviceObject.java b/plugins/windows/src/java/net/java/games/input/DIDeviceObject.java
index a7c43c8..c54cd7a 100644
--- a/plugins/windows/src/java/net/java/games/input/DIDeviceObject.java
+++ b/plugins/windows/src/java/net/java/games/input/DIDeviceObject.java
@@ -90,12 +90,16 @@ final class DIDeviceObject {
}
public final synchronized int getRelativePollValue(int current_abs_value) {
+ if (device.areAxesRelative())
+ return current_abs_value;
int rel_value = current_abs_value - last_poll_value;
last_poll_value = current_abs_value;
return rel_value;
}
public final synchronized int getRelativeEventValue(int current_abs_value) {
+ if (device.areAxesRelative())
+ return current_abs_value;
int rel_value = current_abs_value - last_event_value;
last_event_value = current_abs_value;
return rel_value;
@@ -157,7 +161,7 @@ final class DIDeviceObject {
return (type & IDirectInputDevice.DIDFT_BUTTON) != 0;
}
- private final boolean isAxis() {
+ public final boolean isAxis() {
return (type & IDirectInputDevice.DIDFT_AXIS) != 0;
}
diff --git a/plugins/windows/src/java/net/java/games/input/IDirectInputDevice.java b/plugins/windows/src/java/net/java/games/input/IDirectInputDevice.java
index a788142..7201b92 100644
--- a/plugins/windows/src/java/net/java/games/input/IDirectInputDevice.java
+++ b/plugins/windows/src/java/net/java/games/input/IDirectInputDevice.java
@@ -206,6 +206,9 @@ final class IDirectInputDevice {
private final List rumblers = new ArrayList();
private final int[] device_state;
private final Map object_to_component = new HashMap();
+ private final boolean axes_in_relative_mode;
+
+
private boolean released;
private DataQueue queue;
@@ -229,9 +232,24 @@ final class IDirectInputDevice {
}
/* Some DirectInput lamer-designer made the device state
* axis mode be per-device not per-axis, so I'll just
- * get all axes as absolute and compensate for relative axes
+ * get all axes as absolute and compensate for relative axes.
+ *
+ * Unless, of course, all axes are relative like a mouse device,
+ * in which case setting the DIDF_ABSAXIS flag will result in
+ * incorrect axis values returned from GetDeviceData for some
+ * obscure reason.
*/
- setDataFormat(DIDF_ABSAXIS);
+ boolean all_relative = true;
+ for (int i = 0; i < objects.size(); i++) {
+ DIDeviceObject obj = (DIDeviceObject)objects.get(i);
+ if (obj.isAxis() && !obj.isRelative()) {
+ all_relative = false;
+ break;
+ }
+ }
+ this.axes_in_relative_mode = all_relative;
+ int axis_mode = all_relative ? DIDF_RELAXIS : DIDF_ABSAXIS;
+ setDataFormat(axis_mode);
if (rumblers.size() > 0) {
try {
setCooperativeLevel(DISCL_BACKGROUND | DISCL_EXCLUSIVE);
@@ -245,6 +263,10 @@ final class IDirectInputDevice {
this.device_state = new int[objects.size()];
}
+ public final boolean areAxesRelative() {
+ return axes_in_relative_mode;
+ }
+
public final Rumbler[] getRumblers() {
return (Rumbler[])rumblers.toArray(new Rumbler[]{});
}