winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1030 discussions
Start a n
N
ew thread
Rémi Bernon : winebus.sys: Create devices using a struct device_desc descriptor.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 08f943b5954e4e7b0deaa4f97922fab0c2c4dc5a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=08f943b5954e4e7b0deaa4f9…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 09:30:48 2021 +0200 winebus.sys: Create devices using a struct device_desc descriptor. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winebus.sys/bus.h | 5 +-- dlls/winebus.sys/bus_iohid.c | 34 +++++++++-------- dlls/winebus.sys/bus_sdl.c | 44 ++++++++++------------ dlls/winebus.sys/bus_udev.c | 73 ++++++++++++++++++------------------ dlls/winebus.sys/main.c | 88 +++++++++++++++----------------------------- dlls/winebus.sys/unixlib.c | 16 ++++++++ dlls/winebus.sys/unixlib.h | 22 +++++++++++ 7 files changed, 145 insertions(+), 137 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=08f943b5954e4e7b0dea…
1
0
0
0
Rémi Bernon : xinput1_3: Use the internal WINEXINPUT device interface class.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: f299b42738207c18dd66b17366431672f9004341 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f299b42738207c18dd66b173…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:39 2021 +0200 xinput1_3: Use the internal WINEXINPUT device interface class. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/xinput1_3/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/xinput1_3/main.c b/dlls/xinput1_3/main.c index 4770b64681e..44493ddb2a1 100644 --- a/dlls/xinput1_3/main.c +++ b/dlls/xinput1_3/main.c @@ -43,6 +43,8 @@ #include "wine/debug.h" +DEFINE_GUID(GUID_DEVINTERFACE_WINEXINPUT,0x6c53d5fd,0x6480,0x440f,0xb6,0x18,0x47,0x67,0x50,0xc5,0xe1,0xa6); + /* Not defined in the headers, used only by XInputGetStateEx */ #define XINPUT_GAMEPAD_GUIDE 0x0400 @@ -324,7 +326,7 @@ static void update_controller_list(void) GUID guid; int i; - HidD_GetHidGuid(&guid); + guid = GUID_DEVINTERFACE_WINEXINPUT; set = SetupDiGetClassDevsW(&guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); detail->cbSize = sizeof(*detail); @@ -335,8 +337,6 @@ static void update_controller_list(void) if (!SetupDiGetDeviceInterfaceDetailW(set, &iface, detail, sizeof(buffer), NULL, NULL)) continue; - if (!wcsstr(detail->DevicePath, L"IG_")) continue; - if (find_opened_device(detail, &i)) continue; /* already opened */ if (i == XUSER_MAX_COUNT) break; /* no more slots */
1
0
0
0
Rémi Bernon : xinput1_3/tests: Wait for the state to change before checking it.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: b680794c217c7ee5905c37273800a0f25f8a302d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b680794c217c7ee5905c3727…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:38 2021 +0200 xinput1_3/tests: Wait for the state to change before checking it. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/xinput1_3/tests/xinput.c | 84 +++++++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/dlls/xinput1_3/tests/xinput.c b/dlls/xinput1_3/tests/xinput.c index 272a41c690c..811fe045d10 100644 --- a/dlls/xinput1_3/tests/xinput.c +++ b/dlls/xinput1_3/tests/xinput.c @@ -434,10 +434,10 @@ static void check_hid_caps(DWORD index, HANDLE device, PHIDP_PREPARSED_DATA pre HIDP_LINK_COLLECTION_NODE collections[16]; HIDP_BUTTON_CAPS button_caps[16]; HIDP_VALUE_CAPS value_caps[16]; + XINPUT_STATE last_state, state; XINPUT_CAPABILITIES xi_caps; char buffer[200] = {0}; ULONG length, value; - XINPUT_STATE state; USAGE usages[15]; NTSTATUS status; USHORT count; @@ -637,19 +637,31 @@ static void check_hid_caps(DWORD index, HANDLE device, PHIDP_PREPARSED_DATA pre else if (attrs->VendorID == 0x045e && attrs->ProductID == 0x02ff) skip("skipping interactive tests (Xbox One For Windows)\n"); else { - trace("press A button on gamepad %d\n", index); + res = pXInputGetState(index, &last_state); + ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); - SetLastError(0xdeadbeef); - memset(buffer, 0, sizeof(buffer)); - length = hid_caps->InputReportByteLength; - ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); - ok(ret, "ReadFile failed, last error %u\n", GetLastError()); - ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); + trace("press A button on gamepad %d\n", index); - res = pXInputGetState(index, &state); - ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + do + { + Sleep(5); + res = pXInputGetState(index, &state); + ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + } while (res == ERROR_SUCCESS && state.dwPacketNumber == last_state.dwPacketNumber); ok(state.Gamepad.wButtons & XINPUT_GAMEPAD_A, "unexpected button state %#x\n", state.Gamepad.wButtons); + /* now read as many reports from the device to get a consistent final state */ + for (i = 0; i < (state.dwPacketNumber - last_state.dwPacketNumber); ++i) + { + SetLastError(0xdeadbeef); + memset(buffer, 0, sizeof(buffer)); + length = hid_caps->InputReportByteLength; + ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); + ok(ret, "ReadFile failed, last error %u\n", GetLastError()); + ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); + } + last_state = state; + length = ARRAY_SIZE(usages); status = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, usages, &length, preparsed, buffer, hid_caps->InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_GetUsages returned %#x\n", status); @@ -658,17 +670,26 @@ static void check_hid_caps(DWORD index, HANDLE device, PHIDP_PREPARSED_DATA pre trace("release A on gamepad %d\n", index); - SetLastError(0xdeadbeef); - memset(buffer, 0, sizeof(buffer)); - length = hid_caps->InputReportByteLength; - ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); - ok(ret, "ReadFile failed, last error %u\n", GetLastError()); - ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); - - res = pXInputGetState(index, &state); - ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + do + { + Sleep(5); + res = pXInputGetState(index, &state); + ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + } while (res == ERROR_SUCCESS && state.dwPacketNumber == last_state.dwPacketNumber); ok(!state.Gamepad.wButtons, "unexpected button state %#x\n", state.Gamepad.wButtons); + /* now read as many reports from the device to get a consistent final state */ + for (i = 0; i < (state.dwPacketNumber - last_state.dwPacketNumber); ++i) + { + SetLastError(0xdeadbeef); + memset(buffer, 0, sizeof(buffer)); + length = hid_caps->InputReportByteLength; + ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); + ok(ret, "ReadFile failed, last error %u\n", GetLastError()); + ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); + } + last_state = state; + length = ARRAY_SIZE(usages); status = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, usages, &length, preparsed, buffer, hid_caps->InputReportByteLength); ok(status == HIDP_STATUS_SUCCESS, "HidP_GetUsages returned %#x\n", status); @@ -678,15 +699,24 @@ static void check_hid_caps(DWORD index, HANDLE device, PHIDP_PREPARSED_DATA pre do { - SetLastError(0xdeadbeef); - memset(buffer, 0, sizeof(buffer)); - length = hid_caps->InputReportByteLength; - ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); - ok(ret, "ReadFile failed, last error %u\n", GetLastError()); - ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); + do + { + Sleep(5); + res = pXInputGetState(index, &state); + ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + } while (res == ERROR_SUCCESS && state.dwPacketNumber == last_state.dwPacketNumber); - res = pXInputGetState(index, &state); - ok(res == ERROR_SUCCESS, "XInputGetState returned %#x\n", res); + /* now read as many reports from the device to get a consistent final state */ + for (i = 0; i < (state.dwPacketNumber - last_state.dwPacketNumber); ++i) + { + SetLastError(0xdeadbeef); + memset(buffer, 0, sizeof(buffer)); + length = hid_caps->InputReportByteLength; + ret = ReadFile(device, buffer, hid_caps->InputReportByteLength, &length, NULL); + ok(ret, "ReadFile failed, last error %u\n", GetLastError()); + ok(length == hid_caps->InputReportByteLength, "ReadFile returned length %u\n", length); + } + last_state = state; value = 0; status = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_X, &value, preparsed, buffer, hid_caps->InputReportByteLength);
1
0
0
0
Rémi Bernon : winexinput.sys: Create an additional internal xinput PDO.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 99614467c19482e24bcf7eef980710b56cc86f8c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=99614467c19482e24bcf7eef…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:37 2021 +0200 winexinput.sys: Create an additional internal xinput PDO. This internal xinput PDO is an HID compatible pass-through device, but it needs to be kept private and is listed on the internal WINEXINPUT device interface class, instead of the HID device interface class. This is a Wine extension for convenience and native XInput driver uses a different, undocumented, device interface. We now filter the report read requests to make sure only one is sent through to the lower bus device, and we complete both gamepad and xinput read requests at once using the returned data. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winexinput.sys/main.c | 158 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index afa3b20f1bf..60f7a8ed5dd 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -53,6 +53,7 @@ __ASM_STDCALL_FUNC(wrap_fastcall_func1, 8, struct device { BOOL is_fdo; + BOOL is_gamepad; BOOL removed; WCHAR device_id[MAX_DEVICE_ID_LEN]; }; @@ -75,12 +76,18 @@ struct func_device /* the bogus HID gamepad, as exposed by native XUSB */ DEVICE_OBJECT *gamepad_device; + + /* the Wine-specific hidden HID device, used by XInput */ + DEVICE_OBJECT *xinput_device; + WCHAR instance_id[MAX_DEVICE_ID_LEN]; /* everything below requires holding the cs */ CRITICAL_SECTION cs; ULONG report_len; char *report_buf; + IRP *pending_read; + BOOL pending_is_gamepad; }; static inline struct func_device *fdo_from_DEVICE_OBJECT(DEVICE_OBJECT *device) @@ -90,6 +97,108 @@ static inline struct func_device *fdo_from_DEVICE_OBJECT(DEVICE_OBJECT *device) else return CONTAINING_RECORD(impl, struct phys_device, base)->fdo; } +static NTSTATUS WINAPI read_completion(DEVICE_OBJECT *device, IRP *xinput_irp, void *context) +{ + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(xinput_irp); + ULONG offset, read_len = stack->Parameters.DeviceIoControl.OutputBufferLength; + struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); + char *read_buf = xinput_irp->UserBuffer; + IRP *gamepad_irp = context; + + gamepad_irp->IoStatus.Status = xinput_irp->IoStatus.Status; + gamepad_irp->IoStatus.Information = xinput_irp->IoStatus.Information; + + if (!xinput_irp->IoStatus.Status) + { + RtlEnterCriticalSection(&fdo->cs); + offset = fdo->report_buf[0] ? 0 : 1; + memcpy(fdo->report_buf + offset, read_buf, read_len); + memcpy(gamepad_irp->UserBuffer, read_buf, read_len); + RtlLeaveCriticalSection(&fdo->cs); + } + + IoCompleteRequest(gamepad_irp, IO_NO_INCREMENT); + if (xinput_irp->PendingReturned) IoMarkIrpPending(xinput_irp); + return STATUS_SUCCESS; +} + +/* check for a pending read from the other PDO, and complete both at a time. + * if there's none, save irp as pending, the other PDO will complete it. + * if the device is being removed, complete irp with an error. */ +static NTSTATUS try_complete_pending_read(DEVICE_OBJECT *device, IRP *irp) +{ + struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); + struct device *impl = impl_from_DEVICE_OBJECT(device); + IRP *pending, *xinput_irp, *gamepad_irp; + BOOL removed, pending_is_gamepad; + + RtlEnterCriticalSection(&fdo->cs); + pending_is_gamepad = fdo->pending_is_gamepad; + if ((removed = impl->removed)) + pending = NULL; + else if ((pending = fdo->pending_read)) + fdo->pending_read = NULL; + else + { + fdo->pending_read = irp; + fdo->pending_is_gamepad = impl->is_gamepad; + IoMarkIrpPending(irp); + } + RtlLeaveCriticalSection(&fdo->cs); + + if (removed) + { + irp->IoStatus.Status = STATUS_DELETE_PENDING; + irp->IoStatus.Information = 0; + IoCompleteRequest(irp, IO_NO_INCREMENT); + return STATUS_DELETE_PENDING; + } + + if (!pending) return STATUS_PENDING; + + /* only one read at a time per device from hidclass.sys design */ + if (pending_is_gamepad == impl->is_gamepad) ERR("multiple read requests!\n"); + gamepad_irp = impl->is_gamepad ? irp : pending; + xinput_irp = impl->is_gamepad ? pending : irp; + + /* pass xinput irp down, and complete gamepad irp on its way back */ + IoCopyCurrentIrpStackLocationToNext(xinput_irp); + IoSetCompletionRoutine(xinput_irp, read_completion, gamepad_irp, TRUE, TRUE, TRUE); + return IoCallDriver(fdo->bus_device, xinput_irp); +} + +static NTSTATUS WINAPI gamepad_internal_ioctl(DEVICE_OBJECT *device, IRP *irp) +{ + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); + ULONG code = stack->Parameters.DeviceIoControl.IoControlCode; + struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); + + TRACE("device %p, irp %p, code %#x, bus_device %p.\n", device, irp, code, fdo->bus_device); + + switch (code) + { + case IOCTL_HID_GET_INPUT_REPORT: + { + HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer; + + RtlEnterCriticalSection(&fdo->cs); + memcpy(packet->reportBuffer, fdo->report_buf, fdo->report_len); + irp->IoStatus.Information = fdo->report_len; + RtlLeaveCriticalSection(&fdo->cs); + + irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + + default: + IoSkipCurrentIrpStackLocation(irp); + return IoCallDriver(fdo->bus_device, irp); + } + + return STATUS_SUCCESS; +} + static NTSTATUS WINAPI internal_ioctl(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); @@ -107,6 +216,9 @@ static NTSTATUS WINAPI internal_ioctl(DEVICE_OBJECT *device, IRP *irp) TRACE("device %p, irp %p, code %#x, bus_device %p.\n", device, irp, code, fdo->bus_device); + if (code == IOCTL_HID_READ_REPORT) return try_complete_pending_read(device, irp); + if (impl->is_gamepad) return gamepad_internal_ioctl(device, irp); + IoSkipCurrentIrpStackLocation(irp); return IoCallDriver(fdo->bus_device, irp); } @@ -172,6 +284,7 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) struct device *impl = impl_from_DEVICE_OBJECT(device); ULONG code = stack->MinorFunction; NTSTATUS status; + IRP *pending; TRACE("device %p, irp %p, code %#x, bus_device %p.\n", device, irp, code, fdo->bus_device); @@ -184,6 +297,18 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) case IRP_MN_SURPRISE_REMOVAL: status = STATUS_SUCCESS; if (InterlockedExchange(&impl->removed, TRUE)) break; + + RtlEnterCriticalSection(&fdo->cs); + pending = fdo->pending_read; + fdo->pending_read = NULL; + RtlLeaveCriticalSection(&fdo->cs); + + if (pending) + { + pending->IoStatus.Status = STATUS_DELETE_PENDING; + pending->IoStatus.Information = 0; + IoCompleteRequest(pending, IO_NO_INCREMENT); + } break; case IRP_MN_REMOVE_DEVICE: @@ -247,7 +372,7 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) static NTSTATUS create_child_pdos(DEVICE_OBJECT *device) { struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); - DEVICE_OBJECT *gamepad_device; + DEVICE_OBJECT *gamepad_device, *xinput_device; struct phys_device *pdo; UNICODE_STRING name_str; WCHAR *tmp, name[255]; @@ -264,10 +389,23 @@ static NTSTATUS create_child_pdos(DEVICE_OBJECT *device) return status; } + swprintf(name, ARRAY_SIZE(name), L"\\Device\\WINEXINPUT#%p&%p&1", + device->DriverObject, fdo->bus_device); + RtlInitUnicodeString(&name_str, name); + + if ((status = IoCreateDevice(device->DriverObject, sizeof(struct phys_device), + &name_str, 0, 0, FALSE, &xinput_device))) + { + ERR("failed to create xinput device, status %#x.\n", status); + IoDeleteDevice(gamepad_device); + return status; + } + fdo->gamepad_device = gamepad_device; pdo = gamepad_device->DeviceExtension; pdo->fdo = fdo; pdo->base.is_fdo = FALSE; + pdo->base.is_gamepad = TRUE; wcscpy(pdo->base.device_id, fdo->base.device_id); if ((tmp = wcsstr(pdo->base.device_id, L"&MI_"))) memcpy(tmp, L"&IG", 6); @@ -275,6 +413,18 @@ static NTSTATUS create_child_pdos(DEVICE_OBJECT *device) TRACE("device %p, gamepad device %p.\n", device, gamepad_device); + fdo->xinput_device = xinput_device; + pdo = xinput_device->DeviceExtension; + pdo->fdo = fdo; + pdo->base.is_fdo = FALSE; + pdo->base.is_gamepad = FALSE; + wcscpy(pdo->base.device_id, fdo->base.device_id); + + if ((tmp = wcsstr(pdo->base.device_id, L"&MI_"))) memcpy(tmp, L"&XI", 6); + else wcscat(pdo->base.device_id, L"&XI_00"); + + TRACE("device %p, xinput device %p.\n", device, xinput_device); + IoInvalidateDeviceRelations(fdo->bus_device, BusRelations); return STATUS_SUCCESS; } @@ -363,6 +513,12 @@ static NTSTATUS WINAPI fdo_pnp(DEVICE_OBJECT *device, IRP *irp) } devices->Count = 0; + if ((child = fdo->xinput_device)) + { + devices->Objects[devices->Count] = child; + call_fastcall_func1(ObfReferenceObject, child); + devices->Count++; + } if ((child = fdo->gamepad_device)) { devices->Objects[devices->Count] = child;
1
0
0
0
Rémi Bernon : hidclass.sys: Use a separate class for devices matching WINEXINPUT\*&XI_*.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: ed63e1bcf0d5a56af52ce813691889cb7dd4e7ec URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ed63e1bcf0d5a56af52ce813…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:36 2021 +0200 hidclass.sys: Use a separate class for devices matching WINEXINPUT\*&XI_*. Although these devices will be HID compatible we need to not have them listed on the HID class, as they should only be used internally by Wine XInput implementation. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/hidclass.sys/hid.h | 1 + dlls/hidclass.sys/pnp.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h index 1ca6a926872..e65fabb2aea 100644 --- a/dlls/hidclass.sys/hid.h +++ b/dlls/hidclass.sys/hid.h @@ -84,6 +84,7 @@ typedef struct _BASE_DEVICE_EXTENSION * for convenience. */ WCHAR device_id[MAX_DEVICE_ID_LEN]; WCHAR instance_id[MAX_DEVICE_ID_LEN]; + const GUID *class_guid; BOOL is_fdo; } BASE_DEVICE_EXTENSION; diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index db45aea2fd3..8755afbce6c 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -38,6 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(hid); DEFINE_DEVPROPKEY(DEVPROPKEY_HID_HANDLE, 0xbc62e415, 0xf4fe, 0x405c, 0x8e, 0xda, 0x63, 0x6f, 0xb5, 0x9f, 0x08, 0x98, 2); +DEFINE_GUID(GUID_DEVINTERFACE_WINEXINPUT, 0x6c53d5fd, 0x6480, 0x440f, 0xb6, 0x18, 0x47, 0x67, 0x50, 0xc5, 0xe1, 0xa6); #if defined(__i386__) && !defined(_WIN32) @@ -133,6 +134,7 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *b { WCHAR device_id[MAX_DEVICE_ID_LEN], instance_id[MAX_DEVICE_ID_LEN]; BASE_DEVICE_EXTENSION *ext; + BOOL is_xinput_class; DEVICE_OBJECT *fdo; NTSTATUS status; minidriver *minidriver; @@ -166,6 +168,10 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *b swprintf(ext->device_id, ARRAY_SIZE(ext->device_id), L"HID\\%s", wcsrchr(device_id, '\\') + 1); wcscpy(ext->instance_id, instance_id); + is_xinput_class = !wcsncmp(device_id, L"WINEXINPUT\\", 7) && wcsstr(device_id, L"&XI_") != NULL; + if (is_xinput_class) ext->class_guid = &GUID_DEVINTERFACE_WINEXINPUT; + else ext->class_guid = &GUID_DEVINTERFACE_HID; + status = minidriver->AddDevice(minidriver->minidriver.DriverObject, fdo); if (status != STATUS_SUCCESS) { @@ -220,6 +226,7 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo) KeInitializeSpinLock(&pdo_ext->u.pdo.irp_queue_lock); wcscpy(pdo_ext->device_id, fdo_ext->device_id); wcscpy(pdo_ext->instance_id, fdo_ext->instance_id); + pdo_ext->class_guid = fdo_ext->class_guid; pdo_ext->u.pdo.information.VendorID = attr.VendorID; pdo_ext->u.pdo.information.ProductID = attr.ProductID; @@ -445,7 +452,7 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device, IRP *irp) } case IRP_MN_START_DEVICE: - if ((status = IoRegisterDeviceInterface(device, &GUID_DEVINTERFACE_HID, NULL, &ext->u.pdo.link_name))) + if ((status = IoRegisterDeviceInterface(device, ext->class_guid, NULL, &ext->u.pdo.link_name))) { ERR("Failed to register interface, status %#x.\n", status); break;
1
0
0
0
Rémi Bernon : winexinput.sys: Request the bus device report descriptor on startup.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 90175a745c46d5054e474f2662b77553e014c13e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=90175a745c46d5054e474f26…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:35 2021 +0200 winexinput.sys: Request the bus device report descriptor on startup. So everything will be ready in the device fdo (or fail to start the device entirely), when we need it later. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winexinput.sys/Makefile.in | 2 +- dlls/winexinput.sys/main.c | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/dlls/winexinput.sys/Makefile.in b/dlls/winexinput.sys/Makefile.in index 592c90295b2..2e9af1429d8 100644 --- a/dlls/winexinput.sys/Makefile.in +++ b/dlls/winexinput.sys/Makefile.in @@ -1,5 +1,5 @@ MODULE = winexinput.sys -IMPORTS = ntoskrnl +IMPORTS = ntoskrnl hidparse EXTRADLLFLAGS = -mno-cygwin -Wl,--subsystem,native C_SRCS = \ diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index 515d109a2ad..afa3b20f1bf 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -31,6 +31,7 @@ #include "cfgmgr32.h" #include "ddk/wdm.h" #include "ddk/hidport.h" +#include "ddk/hidpddi.h" #include "wine/asm.h" #include "wine/debug.h" @@ -75,6 +76,11 @@ struct func_device /* the bogus HID gamepad, as exposed by native XUSB */ DEVICE_OBJECT *gamepad_device; WCHAR instance_id[MAX_DEVICE_ID_LEN]; + + /* everything below requires holding the cs */ + CRITICAL_SECTION cs; + ULONG report_len; + char *report_buf; }; static inline struct func_device *fdo_from_DEVICE_OBJECT(DEVICE_OBJECT *device) @@ -273,6 +279,59 @@ static NTSTATUS create_child_pdos(DEVICE_OBJECT *device) return STATUS_SUCCESS; } +static NTSTATUS sync_ioctl(DEVICE_OBJECT *device, DWORD code, void *in_buf, DWORD in_len, void *out_buf, DWORD out_len) +{ + IO_STATUS_BLOCK io; + KEVENT event; + IRP *irp; + + KeInitializeEvent(&event, NotificationEvent, FALSE); + irp = IoBuildDeviceIoControlRequest(code, device, in_buf, in_len, out_buf, out_len, TRUE, &event, &io); + if (IoCallDriver(device, irp) == STATUS_PENDING) KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); + + return io.Status; +} + +static NTSTATUS initialize_device(DEVICE_OBJECT *device) +{ + struct func_device *fdo = fdo_from_DEVICE_OBJECT(device); + ULONG i, report_desc_len, report_count; + PHIDP_REPORT_DESCRIPTOR report_desc; + PHIDP_PREPARSED_DATA preparsed; + HIDP_DEVICE_DESC device_desc; + HIDP_REPORT_IDS *reports; + HID_DESCRIPTOR hid_desc; + NTSTATUS status; + HIDP_CAPS caps; + + if ((status = sync_ioctl(fdo->bus_device, IOCTL_HID_GET_DEVICE_DESCRIPTOR, NULL, 0, &hid_desc, sizeof(hid_desc)))) + return status; + + if (!(report_desc_len = hid_desc.DescriptorList[0].wReportLength)) return STATUS_UNSUCCESSFUL; + if (!(report_desc = malloc(report_desc_len))) return STATUS_NO_MEMORY; + + status = sync_ioctl(fdo->bus_device, IOCTL_HID_GET_REPORT_DESCRIPTOR, NULL, 0, report_desc, report_desc_len); + if (!status) status = HidP_GetCollectionDescription(report_desc, report_desc_len, PagedPool, &device_desc); + free(report_desc); + if (status != HIDP_STATUS_SUCCESS) return status; + + preparsed = device_desc.CollectionDesc->PreparsedData; + status = HidP_GetCaps(preparsed, &caps); + if (status != HIDP_STATUS_SUCCESS) return status; + + reports = device_desc.ReportIDs; + report_count = device_desc.ReportIDsLength; + for (i = 0; i < report_count; ++i) if (!reports[i].ReportID || reports[i].InputLength) break; + if (i == report_count) i = 0; /* no input report?!, just use first ID */ + + fdo->report_len = caps.InputReportByteLength; + if (!(fdo->report_buf = malloc(fdo->report_len))) return STATUS_NO_MEMORY; + fdo->report_buf[0] = reports[i].ReportID; + + HidP_FreeCollectionDescription(&device_desc); + return STATUS_SUCCESS; +} + static NTSTATUS WINAPI set_event_completion(DEVICE_OBJECT *device, IRP *irp, void *context) { if (irp->PendingReturned) KeSetEvent((KEVENT *)context, IO_NO_INCREMENT, FALSE); @@ -329,6 +388,7 @@ static NTSTATUS WINAPI fdo_pnp(DEVICE_OBJECT *device, IRP *irp) KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); status = irp->IoStatus.Status; } + if (!status) status = initialize_device(device); if (!status) status = create_child_pdos(device); if (status) irp->IoStatus.Status = status; @@ -339,6 +399,8 @@ static NTSTATUS WINAPI fdo_pnp(DEVICE_OBJECT *device, IRP *irp) IoSkipCurrentIrpStackLocation(irp); status = IoCallDriver(fdo->bus_device, irp); IoDetachDevice(fdo->bus_device); + RtlDeleteCriticalSection(&fdo->cs); + free(fdo->report_buf); IoDeleteDevice(device); return status; @@ -422,6 +484,9 @@ static NTSTATUS WINAPI add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *bus_devi fdo->bus_device = bus_device; wcscpy(fdo->instance_id, instance_id); + RtlInitializeCriticalSection(&fdo->cs); + fdo->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": func_device.cs"); + TRACE("device %p, bus_id %s, device_id %s, instance_id %s.\n", device, debugstr_w(bus_id), debugstr_w(fdo->base.device_id), debugstr_w(fdo->instance_id));
1
0
0
0
Rémi Bernon : winexinput.sys: Handle IRP_MN_QUERY_DEVICE_RELATIONS in pdo_pnp.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 1b9bb7f974b70cf74c56c74009efb7f468c432f9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1b9bb7f974b70cf74c56c740…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:34 2021 +0200 winexinput.sys: Handle IRP_MN_QUERY_DEVICE_RELATIONS in pdo_pnp. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winexinput.sys/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index 386b4bbb228..515d109a2ad 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -223,6 +223,10 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) status = STATUS_SUCCESS; break; + case IRP_MN_QUERY_DEVICE_RELATIONS: + status = irp->IoStatus.Status; + break; + default: FIXME("code %#x, not implemented!\n", code); status = irp->IoStatus.Status;
1
0
0
0
Rémi Bernon : winexinput.sys: Don't set RawDeviceOk in IRP_MN_QUERY_CAPABILITIES.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 75adc44191d86758501874cb85d1bb816b65605b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=75adc44191d86758501874cb…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Sep 3 07:57:33 2021 +0200 winexinput.sys: Don't set RawDeviceOk in IRP_MN_QUERY_CAPABILITIES. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winexinput.sys/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dlls/winexinput.sys/main.c b/dlls/winexinput.sys/main.c index a0b6c9bf0eb..386b4bbb228 100644 --- a/dlls/winexinput.sys/main.c +++ b/dlls/winexinput.sys/main.c @@ -220,12 +220,8 @@ static NTSTATUS WINAPI pdo_pnp(DEVICE_OBJECT *device, IRP *irp) } case IRP_MN_QUERY_CAPABILITIES: - { - DEVICE_CAPABILITIES *caps = stack->Parameters.DeviceCapabilities.Capabilities; - caps->RawDeviceOK = 1; status = STATUS_SUCCESS; break; - } default: FIXME("code %#x, not implemented!\n", code);
1
0
0
0
Jacek Caban : gdi32: Use NtGdiDeleteObjectApp instead of DeleteObject in ntgdi functions.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 8e70a0a5cc2ca7bb2fe127afed8b8545ebc93acf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8e70a0a5cc2ca7bb2fe127af…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 3 13:59:52 2021 +0100 gdi32: Use NtGdiDeleteObjectApp instead of DeleteObject in ntgdi functions. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdi32/bitblt.c | 12 ++++++------ dlls/gdi32/bitmap.c | 4 ++-- dlls/gdi32/clipping.c | 14 +++++++------- dlls/gdi32/dc.c | 12 ++++++------ dlls/gdi32/dib.c | 14 +++++++------- dlls/gdi32/dibdrv/bitblt.c | 2 +- dlls/gdi32/dibdrv/graphics.c | 38 +++++++++++++++++++------------------- dlls/gdi32/dibdrv/objects.c | 8 ++++---- dlls/gdi32/font.c | 6 +++--- dlls/gdi32/gdiobj.c | 2 +- dlls/gdi32/painting.c | 2 +- dlls/gdi32/path.c | 2 +- dlls/gdi32/region.c | 2 +- 13 files changed, 59 insertions(+), 59 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=8e70a0a5cc2ca7bb2fe1…
1
0
0
0
Jacek Caban : gdi32: Use internal get_stock_object in ntgdi functions.
by Alexandre Julliard
03 Sep '21
03 Sep '21
Module: wine Branch: master Commit: 072a100f66215763a67edc4629fe5d3b73f6734c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=072a100f66215763a67edc46…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 3 13:59:51 2021 +0100 gdi32: Use internal get_stock_object in ntgdi functions. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdi32/bitblt.c | 2 +- dlls/gdi32/bitmap.c | 2 +- dlls/gdi32/dc.c | 20 ++++++++++---------- dlls/gdi32/dibdrv/objects.c | 8 ++++---- dlls/gdi32/font.c | 2 +- dlls/gdi32/gdiobj.c | 23 +++++++++++++++++++++++ dlls/gdi32/ntgdi_private.h | 1 + dlls/gdi32/painting.c | 2 +- dlls/gdi32/palette.c | 8 ++++---- dlls/gdi32/pen.c | 2 +- 10 files changed, 47 insertions(+), 23 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=072a100f66215763a67e…
1
0
0
0
← Newer
1
...
89
90
91
92
93
94
95
...
103
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Results per page:
10
25
50
100
200