Skip to content

Commit

Permalink
[WIP] Revert "shift axis values to the left"
Browse files Browse the repository at this point in the history
Wine introduced a change which actually relies on the behavior that axis
values are unsigned (thus 0..65535). Without this revert, all axis are
mirrored to the left respectively up.

Reverting this fixes some games, i.e. some Ubisoft titles based on the
AC Unity engine. Otherwise, the game behaves as if all axes are
constantly pushed to the upper left unless you move at least one axis.

  * FIXME: ABS_Z combined mode wasn't tested.

This partially reverts commit e266400
and 92cb47d.

See-also: wine-mirror/wine@b16fb11
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed May 5, 2020
1 parent 0940543 commit ad31ad3
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,25 +1007,11 @@ static int xpadneo_input_configured(struct hid_device *hdev,
}
}

// The HID device descriptor defines a range from 0 to 65535 for all
// absolute axis (like ABS_X), this is in contrary to what the linux
// gamepad specification defines [–32.768; 32.767].
// Therefore, we have to set the min, max, fuzz and flat values by hand:

input_set_abs_params(xdata->idev, ABS_X, -32768, 32767, 255, 4095);
input_set_abs_params(xdata->idev, ABS_Y, -32768, 32767, 255, 4095);

input_set_abs_params(xdata->idev, ABS_RX, -32768, 32767, 255, 4095);
input_set_abs_params(xdata->idev, ABS_RY, -32768, 32767, 255, 4095);

if (param_combined_z_axis)
input_set_abs_params(xdata->idev, ABS_Z, -1024, 1023, 3, 63);

// furthermore, we need to translate the incoming events to fit within
// the new range, we will do that in the xpadneo_event() hook.

// We remove the ABS_RZ event if param_combined_z_axis is enabled
if (param_combined_z_axis) {
// furthermore, we need to translate the incoming events to fit within
// the new range, we will do that in the xpadneo_event() hook.
input_set_abs_params(xdata->idev, ABS_Z, -1024, 1023, 3, 63);
// We remove the ABS_RZ event if param_combined_z_axis is enabled
__clear_bit(ABS_RZ, xdata->idev->absbit);
}

Expand Down Expand Up @@ -1064,36 +1050,21 @@ int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
(usage->hid & HID_USAGE_PAGE), (usage->hid & HID_USAGE),
usage->code, value);


// we have to shift the range of the analogues sticks (ABS_X/Y/RX/RY)
// as already explained in xpadneo_input_configured() above
// furthermore we need to combine ABS_Z and ABS_RZ if param_combined_z_axis
// is set

if (usg_type == EV_ABS) {
if (usg_code == ABS_X || usg_code == ABS_Y
|| usg_code == ABS_RX || usg_code == ABS_RY) {
hid_dbg_lvl(DBG_LVL_ALL, hdev, "shifted axis %02x, old value: %i, new value: %i\n", usg_code, value, value - 32768);
input_report_abs(idev, usg_code, value - 32768);
goto sync_and_stop_processing;
}

/* We need to combine ABS_Z and ABS_RZ if param_combined_z_axis
* is set */
if (param_combined_z_axis) {
if (usg_code == ABS_Z || usg_code == ABS_RZ) {
if (usg_code == ABS_Z)
xdata->last_abs_z = value;
if (usg_code == ABS_RZ)
xdata->last_abs_rz = value;

input_report_abs(idev, ABS_Z, 0 - xdata->last_abs_z + xdata->last_abs_rz);
goto sync_and_stop_processing;
}
}
}




/* TODO:
* This is a workaround for the wrong report (Windows report but
* Linux descriptor). We would prefer to fixup the descriptor, but we
Expand Down

0 comments on commit ad31ad3

Please sign in to comment.