This matches what Windows does with common controllers like xbox 360.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com ---
This allows controllers to work in some games like Telltale games and Yakuza Kiwami.
dlls/dinput/joystick_linux.c | 9 +++------ dlls/dinput/joystick_linuxinput.c | 9 +++------ dlls/dinput/joystick_osx.c | 7 +++++-- 3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 963e62f017c..736a06e2b27 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -316,9 +316,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidProduct = joystick_devices[id].guid_product; /* we only support traditional joysticks for now */ if (version >= 0x0800) - lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); + lpddi->dwDevType = DI8DEVTYPE_GAMEPAD | (DI8DEVTYPEJOYSTICK_STANDARD << 8); else - lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); + lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a valid VID/PID */ if (joystick_devices[id].bus_type == BUS_USB && @@ -326,10 +326,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */ - if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType == DIDEVTYPE_JOYSTICK) - lpddi->wUsage = 0x04; /* Joystick */ - else - lpddi->wUsage = 0x05; /* Game Pad */ + lpddi->wUsage = 0x05; /* Game Pad */ }
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 910e755d3ed..cea669b90cb 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -355,9 +355,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidFFDriver = GUID_NULL;
if (version >= 0x0800) - lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); + lpddi->dwDevType = DI8DEVTYPE_GAMEPAD | (DI8DEVTYPEJOYSTICK_STANDARD << 8); else - lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); + lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a valid VID/PID */ if (joydevs[id].bus_type == BUS_USB && @@ -365,10 +365,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */ - if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType == DIDEVTYPE_JOYSTICK) - lpddi->wUsage = 0x04; /* Joystick */ - else - lpddi->wUsage = 0x05; /* Game Pad */ + lpddi->wUsage = 0x05; /* Game Pad */ }
MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 0701b9f42cc..daef1a12ed5 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -969,9 +969,12 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS lpddi->guidProduct.Data1 = make_vid_pid(device); /* we only support traditional joysticks for now */ if (version >= 0x0800) - lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8); + lpddi->dwDevType = DI8DEVTYPE_GAMEPAD | (DI8DEVTYPEJOYSTICK_STANDARD << 8); else - lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8); + lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_GAMEPAD << 8); + lpddi->dwDevType |= DIDEVTYPE_HID; + lpddi->wUsagePage = 0x01; /* Desktop */ + lpddi->wUsage = 0x05; /* Game Pad */ sprintf(lpddi->tszInstanceName, "Joystick %d", id);
/* get the device name */
What happens on traditional joysticks on windows? Are they really setting the gamepad flag on those too? I would have guessed they used some heuristics for setting such flag.
Thanks, Roderick
On Wed, Apr 17, 2019, 7:12 AM Andrew Eikum aeikum@codeweavers.com wrote:
This matches what Windows does with common controllers like xbox 360.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
This allows controllers to work in some games like Telltale games and Yakuza Kiwami.
dlls/dinput/joystick_linux.c | 9 +++------ dlls/dinput/joystick_linuxinput.c | 9 +++------ dlls/dinput/joystick_osx.c | 7 +++++-- 3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 963e62f017c..736a06e2b27 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -316,9 +316,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidProduct = joystick_devices[id].guid_product; /* we only support traditional joysticks for now */ if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a
valid VID/PID */ if (joystick_devices[id].bus_type == BUS_USB && @@ -326,10 +326,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */
if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType
== DIDEVTYPE_JOYSTICK)
lpddi->wUsage = 0x04; /* Joystick */
else
lpddi->wUsage = 0x05; /* Game Pad */
lpddi->wUsage = 0x05; /* Game Pad */
}
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1,
lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 910e755d3ed..cea669b90cb 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -355,9 +355,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidFFDriver = GUID_NULL;
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a
valid VID/PID */ if (joydevs[id].bus_type == BUS_USB && @@ -365,10 +365,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */
if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType
== DIDEVTYPE_JOYSTICK)
lpddi->wUsage = 0x04; /* Joystick */
else
lpddi->wUsage = 0x05; /* Game Pad */
lpddi->wUsage = 0x05; /* Game Pad */
}
MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1,
lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 0701b9f42cc..daef1a12ed5 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -969,9 +969,12 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS lpddi->guidProduct.Data1 = make_vid_pid(device); /* we only support traditional joysticks for now */ if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
lpddi->dwDevType |= DIDEVTYPE_HID;
lpddi->wUsagePage = 0x01; /* Desktop */
lpddi->wUsage = 0x05; /* Game Pad */ sprintf(lpddi->tszInstanceName, "Joystick %d", id); /* get the device name */
-- 2.21.0
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=51056
Your paranoid android.
=== debian9 (build log) ===
error: corrupt patch at line 147 Task: Patch failed to apply
=== debian9 (build log) ===
error: corrupt patch at line 147 Task: Patch failed to apply
On Wed, Apr 17, 2019 at 08:09:16AM -0700, Roderick Colenbrander wrote:
What happens on traditional joysticks on windows? Are they really setting the gamepad flag on those too? I would have guessed they used some heuristics for setting such flag.
I don't know. I didn't test, and I'm not sure how we could puzzle out such a heuristic.
Andrew
On Wed, Apr 17, 2019, 7:12 AM Andrew Eikum aeikum@codeweavers.com wrote:
This matches what Windows does with common controllers like xbox 360.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
This allows controllers to work in some games like Telltale games and Yakuza Kiwami.
dlls/dinput/joystick_linux.c | 9 +++------ dlls/dinput/joystick_linuxinput.c | 9 +++------ dlls/dinput/joystick_osx.c | 7 +++++-- 3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 963e62f017c..736a06e2b27 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -316,9 +316,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidProduct = joystick_devices[id].guid_product; /* we only support traditional joysticks for now */ if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a
valid VID/PID */ if (joystick_devices[id].bus_type == BUS_USB && @@ -326,10 +326,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */
if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType
== DIDEVTYPE_JOYSTICK)
lpddi->wUsage = 0x04; /* Joystick */
else
lpddi->wUsage = 0x05; /* Game Pad */
lpddi->wUsage = 0x05; /* Game Pad */
}
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1,
lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 910e755d3ed..cea669b90cb 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -355,9 +355,9 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver lpddi->guidFFDriver = GUID_NULL;
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
/* Assume the joystick as HID if it is attached to USB bus and has a
valid VID/PID */ if (joydevs[id].bus_type == BUS_USB && @@ -365,10 +365,7 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver { lpddi->dwDevType |= DIDEVTYPE_HID; lpddi->wUsagePage = 0x01; /* Desktop */
if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType
== DIDEVTYPE_JOYSTICK)
lpddi->wUsage = 0x04; /* Joystick */
else
lpddi->wUsage = 0x05; /* Game Pad */
lpddi->wUsage = 0x05; /* Game Pad */
}
MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1,
lpddi->tszInstanceName, MAX_PATH); diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 0701b9f42cc..daef1a12ed5 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -969,9 +969,12 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS lpddi->guidProduct.Data1 = make_vid_pid(device); /* we only support traditional joysticks for now */ if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK |
(DI8DEVTYPEJOYSTICK_STANDARD << 8);
lpddi->dwDevType = DI8DEVTYPE_GAMEPAD |
(DI8DEVTYPEJOYSTICK_STANDARD << 8); else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_GAMEPAD << 8);
lpddi->dwDevType |= DIDEVTYPE_HID;
lpddi->wUsagePage = 0x01; /* Desktop */
lpddi->wUsage = 0x05; /* Game Pad */ sprintf(lpddi->tszInstanceName, "Joystick %d", id); /* get the device name */
-- 2.21.0
On Wed, Apr 17, 2019 at 8:15 AM Andrew Eikum aeikum@codeweavers.com wrote:
On Wed, Apr 17, 2019 at 08:09:16AM -0700, Roderick Colenbrander wrote:
What happens on traditional joysticks on windows? Are they really setting the gamepad flag on those too? I would have guessed they used some heuristics for setting such flag.
I don't know. I didn't test, and I'm not sure how we could puzzle out such a heuristic.
Andrew
Dinput always was in general a thin layer over HID. I had a quick look over the HID specs again. Most devices use "Generic Desktop Page" in their report descriptors. There is a different "Usage ID" in there for gamepad (5), joystick (4) and keyboard (6). See page 26 in https://usb.org/sites/default/files/documents/hut1_12v2.pdf. This is what I would say Dinput derives its info from and we should do the same in case of HID. When not using HID, well then we probably would need a heuristic. A very rough one being "if device has only 1 stick" mark it as a joystick, though fancy flight sticks may have more.
Roderick