mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-01-09 10:19:57 +01:00
DirectInput: Fix an issue with mice devices and DIDF_ABSAXIS axis mode. Now DIDF_RELAXIS is chosen if all device axes are relative.
This commit is contained in:
parent
924d55e7d3
commit
e48f275cfc
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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[]{});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue