From ad31ad3fac275e6017d482270097e1420f6f281f Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Sun, 3 May 2020 14:18:04 +0200 Subject: [PATCH] [WIP] Revert "shift axis values to the left" 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 e2664007b123c93f890cae2e3cc439453acecb01 and 92cb47d1522489f8cd474f02444e6f7a534393c7. See-also: https://github.com/wine-mirror/wine/commit/b16fb11890b59a80816d6906e7b7b4ce52f88555 Signed-off-by: Kai Krakow --- hid-xpadneo/src/hid-xpadneo.c | 41 +++++------------------------------ 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/hid-xpadneo/src/hid-xpadneo.c b/hid-xpadneo/src/hid-xpadneo.c index 8b8a783a..d75344b3 100644 --- a/hid-xpadneo/src/hid-xpadneo.c +++ b/hid-xpadneo/src/hid-xpadneo.c @@ -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); } @@ -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