Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/main.c | 67 ++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 41 deletions(-)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index a60e3cc9a2c..5b15fd08a35 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -22,12 +22,16 @@
#include "ntstatus.h" #define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" #include "winternl.h" #include "winioctl.h" #include "hidusage.h" #include "ddk/wdm.h" #include "ddk/hidport.h" #include "ddk/hidtypes.h" +#include "cfgmgr32.h" + #include "wine/asm.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -118,10 +122,11 @@ struct device_extension struct pnp_device *pnp_device;
WORD vid, pid, input; - DWORD uid, version, index; - BOOL is_gamepad; - WCHAR *serial; + DWORD version, index; + const WCHAR *busid; /* Expected to be a static constant */ + WCHAR device_id[MAX_DEVICE_ID_LEN]; + WCHAR instance_id[MAX_DEVICE_ID_LEN];
const platform_vtbl *vtbl;
@@ -145,19 +150,6 @@ static CRITICAL_SECTION device_list_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
static struct list pnp_devset = LIST_INIT(pnp_devset);
-static const WCHAR zero_serialW[]= {'0','0','0','0',0}; -static const WCHAR miW[] = {'M','I',0}; -static const WCHAR igW[] = {'I','G',0}; - -static inline WCHAR *strdupW(const WCHAR *src) -{ - WCHAR *dst; - if (!src) return NULL; - dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1)*sizeof(WCHAR)); - if (dst) strcpyW(dst, src); - return dst; -} - void *get_platform_private(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; @@ -181,40 +173,24 @@ static DWORD get_device_index(WORD vid, WORD pid, WORD input)
static WCHAR *get_instance_id(DEVICE_OBJECT *device) { - static const WCHAR formatW[] = {'%','i','&','%','s','&','%','x','&','%','i',0}; struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - const WCHAR *serial = ext->serial ? ext->serial : zero_serialW; - DWORD len = strlenW(serial) + 33; + DWORD len = strlenW(ext->instance_id); WCHAR *dst;
if ((dst = ExAllocatePool(PagedPool, len * sizeof(WCHAR)))) - sprintfW(dst, formatW, ext->version, serial, ext->uid, ext->index); + strcpyW(dst, ext->instance_id);
return dst; }
static WCHAR *get_device_id(DEVICE_OBJECT *device) { - static const WCHAR formatW[] = {'%','s','\','v','i','d','_','%','0','4','x', - '&','p','i','d','_','%','0','4','x',0}; - static const WCHAR format_inputW[] = {'%','s','\','v','i','d','_','%','0','4','x', - '&','p','i','d','_','%','0','4','x','&','%','s','_','%','0','2','i',0}; struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - DWORD len = strlenW(ext->busid) + 34; + DWORD len = strlenW(ext->device_id); WCHAR *dst;
if ((dst = ExAllocatePool(PagedPool, len * sizeof(WCHAR)))) - { - if (ext->input == (WORD)-1) - { - sprintfW(dst, formatW, ext->busid, ext->vid, ext->pid); - } - else - { - sprintfW(dst, format_inputW, ext->busid, ext->vid, ext->pid, - ext->is_gamepad ? igW : miW, ext->input); - } - } + strcpyW(dst, ext->device_id);
return dst; } @@ -251,7 +227,15 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, WORD input, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad, const platform_vtbl *vtbl, DWORD platform_data_size) { + static const WCHAR device_id_formatW[] = + { + '%','s','\','v','i','d','_','%','0','4','x','&','p','i','d','_','%','0','4','x',0 + }; static const WCHAR device_name_fmtW[] = {'\','D','e','v','i','c','e','\','%','s','#','%','p',0}; + static const WCHAR instance_id_formatW[] = {'%','i','&','%','s','&','%','x','&','%','i',0}; + static const WCHAR zero_serialW[]= {'0','0','0','0',0}; + static const WCHAR miW[] = {'&','M','I','_','%','0','2','i',0}; + static const WCHAR igW[] = {'&','I','G','_','%','0','2','i',0}; struct device_extension *ext; struct pnp_device *pnp_dev; DEVICE_OBJECT *device; @@ -286,11 +270,8 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, ext->vid = vid; ext->pid = pid; ext->input = input; - ext->uid = uid; ext->version = version; ext->index = get_device_index(vid, pid, input); - ext->is_gamepad = is_gamepad; - ext->serial = strdupW(serialW); ext->busid = busidW; ext->vtbl = vtbl; ext->last_report = NULL; @@ -298,6 +279,12 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, ext->last_report_read = TRUE; ext->buffer_size = 0;
+ length = sprintfW(ext->device_id, device_id_formatW, busidW, vid, pid); + if (input != (WORD)-1) sprintfW(ext->device_id + length, is_gamepad ? igW : miW, input); + + sprintfW(ext->instance_id, instance_id_formatW, version, + serialW ? serialW : zero_serialW, uid, ext->index); + memset(ext->platform_private, 0, platform_data_size);
InitializeListHead(&ext->irp_queue); @@ -382,7 +369,6 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) ext->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ext->cs);
- HeapFree(GetProcessHeap(), 0, ext->serial); HeapFree(GetProcessHeap(), 0, ext->last_report); IoDeleteDevice(device);
@@ -718,7 +704,6 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) ext->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ext->cs);
- HeapFree(GetProcessHeap(), 0, ext->serial); HeapFree(GetProcessHeap(), 0, ext->last_report);
irp->IoStatus.Status = STATUS_SUCCESS;
Not just the bus id, so that we can filter devices.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/main.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 5b15fd08a35..fe2856abbc9 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -197,13 +197,28 @@ static WCHAR *get_device_id(DEVICE_OBJECT *device)
static WCHAR *get_compatible_ids(DEVICE_OBJECT *device) { + static const WCHAR device_instance_formatW[] = {'%','s','\','%','s',0}; + static const WCHAR formatW[] = {'%','s',0}; struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - WCHAR *dst; + DWORD len = 0, bus_len, device_len, instance_len; + WCHAR *dst, *tmp; + + bus_len = strlenW(ext->busid); + device_len = strlenW(ext->device_id); + instance_len = strlenW(ext->instance_id); + + len += device_len + instance_len + 2; + len += device_len + 2; + len += bus_len + 2;
- if ((dst = ExAllocatePool(PagedPool, (strlenW(ext->busid) + 2) * sizeof(WCHAR)))) + if ((dst = tmp = ExAllocatePool(PagedPool, len * sizeof(WCHAR)))) { - strcpyW(dst, ext->busid); - dst[strlenW(dst) + 1] = 0; + tmp += sprintfW(tmp, device_instance_formatW, ext->device_id, ext->instance_id); + *tmp++ = 0; + tmp += sprintfW(tmp, formatW, ext->device_id); + *tmp++ = 0; + tmp += sprintfW(tmp, formatW, ext->busid); + *tmp++ = 0; }
return dst;
Please ignore just this one if possible -I think it should not conflict with any of the other patches.
After some more investigation I figured that the compatible ids and hardware ids are usually completely different set and it doesn't look like instance id should be reported in the hardware ids either.
It doesn't matter much though but I intend to change it again later anyway so this is a bit useless.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 1 + dlls/winebus.sys/bus_iohid.c | 6 ++++++ dlls/winebus.sys/bus_sdl.c | 6 ++++++ dlls/winebus.sys/bus_udev.c | 12 ++++++++++++ dlls/winebus.sys/main.c | 33 ++++++++++++++++++++++++++++----- 5 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 72bd071135b..f46daa7144d 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -39,6 +39,7 @@ typedef struct { void (*free_device)(DEVICE_OBJECT *device); int (*compare_platform_device)(DEVICE_OBJECT *device, void *platform_dev); + NTSTATUS (*start_device)(DEVICE_OBJECT *device); NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length); NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length); NTSTATUS (*begin_report_processing)(DEVICE_OBJECT *device); diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index eb6765d6aac..9b9e93f5c49 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -148,6 +148,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) return 0; }
+static NTSTATUS start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) { struct platform_private *private = impl_from_DEVICE_OBJECT(device); @@ -274,6 +279,7 @@ static const platform_vtbl iohid_vtbl = { free_device, compare_platform_device, + start_device, get_reportdescriptor, get_string, begin_report_processing, diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index c833b4e4c06..e7b7c1fef22 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -487,6 +487,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *context) return impl_from_DEVICE_OBJECT(device)->id - PtrToUlong(context); }
+static NTSTATUS start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) { struct platform_private *ext = impl_from_DEVICE_OBJECT(device); @@ -596,6 +601,7 @@ static const platform_vtbl sdl_vtbl = { free_device, compare_platform_device, + start_device, get_reportdescriptor, get_string, begin_report_processing, diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 9176dff69a7..eb6434ad2a5 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -558,6 +558,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)); }
+static NTSTATUS hidraw_start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS hidraw_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) { #ifdef HAVE_LINUX_HIDRAW_H @@ -818,6 +823,7 @@ static const platform_vtbl hidraw_vtbl = { hidraw_free_device, compare_platform_device, + hidraw_start_device, hidraw_get_reportdescriptor, hidraw_get_string, begin_report_processing, @@ -854,6 +860,11 @@ static void lnxev_free_device(DEVICE_OBJECT *device) udev_device_unref(ext->base.udev_device); }
+static NTSTATUS lnxev_start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS lnxev_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) { struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device); @@ -967,6 +978,7 @@ static NTSTATUS lnxev_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE * static const platform_vtbl lnxev_vtbl = { lnxev_free_device, compare_platform_device, + lnxev_start_device, lnxev_get_reportdescriptor, lnxev_get_string, lnxev_begin_report_processing, diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index fe2856abbc9..545b2862086 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -113,11 +113,17 @@ struct pnp_device DEVICE_OBJECT *device; };
+enum device_state +{ + DEVICE_STATE_STOPPED, + DEVICE_STATE_STARTED, + DEVICE_STATE_REMOVED, +}; + struct device_extension { CRITICAL_SECTION cs; - - BOOL removed; + enum device_state state;
struct pnp_device *pnp_device;
@@ -481,6 +487,11 @@ static void mouse_free_device(DEVICE_OBJECT *device) { }
+static NTSTATUS mouse_start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS mouse_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *ret_length) { TRACE("buffer %p, length %u.\n", buffer, length); @@ -529,6 +540,7 @@ static NTSTATUS mouse_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE * static const platform_vtbl mouse_vtbl = { .free_device = mouse_free_device, + .start_device = mouse_start_device, .get_reportdescriptor = mouse_get_reportdescriptor, .get_string = mouse_get_string, .begin_report_processing = mouse_begin_report_processing, @@ -556,6 +568,11 @@ static void keyboard_free_device(DEVICE_OBJECT *device) { }
+static NTSTATUS keyboard_start_device(DEVICE_OBJECT *device) +{ + return STATUS_SUCCESS; +} + static NTSTATUS keyboard_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *ret_length) { TRACE("buffer %p, length %u.\n", buffer, length); @@ -604,6 +621,7 @@ static NTSTATUS keyboard_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYT static const platform_vtbl keyboard_vtbl = { .free_device = keyboard_free_device, + .start_device = keyboard_start_device, .get_reportdescriptor = keyboard_get_reportdescriptor, .get_string = keyboard_get_string, .begin_report_processing = keyboard_begin_report_processing, @@ -696,13 +714,18 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) break;
case IRP_MN_START_DEVICE: - status = STATUS_SUCCESS; + EnterCriticalSection(&ext->cs); + if (ext->state != DEVICE_STATE_STOPPED) status = STATUS_SUCCESS; + else if (ext->state == DEVICE_STATE_REMOVED) status = STATUS_DELETE_PENDING; + else if (!(status = ext->vtbl->start_device(device))) ext->state = DEVICE_STATE_STARTED; + else ERR("failed to start device %p, status %#x\n", device, status); + LeaveCriticalSection(&ext->cs); break;
case IRP_MN_SURPRISE_REMOVAL: EnterCriticalSection(&ext->cs); remove_pending_irps(device); - ext->removed = TRUE; + ext->state = DEVICE_STATE_REMOVED; LeaveCriticalSection(&ext->cs); status = STATUS_SUCCESS; break; @@ -834,7 +857,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
EnterCriticalSection(&ext->cs);
- if (ext->removed) + if (ext->state == DEVICE_STATE_REMOVED) { LeaveCriticalSection(&ext->cs); irp->IoStatus.Status = STATUS_DELETE_PENDING;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_sdl.c | 19 +++---------------- dlls/winebus.sys/bus_udev.c | 17 ++--------------- dlls/winebus.sys/main.c | 30 ++++++++++++++---------------- 3 files changed, 19 insertions(+), 47 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index e7b7c1fef22..21eac3c67f4 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -489,7 +489,9 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *context)
static NTSTATUS start_device(DEVICE_OBJECT *device) { - return STATUS_SUCCESS; + struct platform_private *ext = impl_from_DEVICE_OBJECT(device); + if (ext->sdl_controller) return build_mapped_report_descriptor(ext); + return build_report_descriptor(ext); }
static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) @@ -797,25 +799,10 @@ static void try_add_device(unsigned int index)
if (device) { - NTSTATUS status; struct platform_private *private = impl_from_DEVICE_OBJECT(device); private->sdl_joystick = joystick; private->sdl_controller = controller; private->id = id; - - /* FIXME: We should probably move this to IRP_MN_START_DEVICE. */ - if (controller) - status = build_mapped_report_descriptor(private); - else - status = build_report_descriptor(private); - if (status) - { - ERR("Building report descriptor failed, removing device\n"); - bus_unlink_hid_device(device); - bus_remove_hid_device(device); - HeapFree(GetProcessHeap(), 0, serial); - return; - } IoInvalidateDeviceRelations(bus_pdo, BusRelations); } else diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index eb6434ad2a5..25c8b5f0b36 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -862,7 +862,8 @@ static void lnxev_free_device(DEVICE_OBJECT *device)
static NTSTATUS lnxev_start_device(DEVICE_OBJECT *device) { - return STATUS_SUCCESS; + struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device); + return build_report_descriptor(ext, ext->base.udev_device); }
static NTSTATUS lnxev_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) @@ -1148,20 +1149,6 @@ static void try_add_device(struct udev_device *dev) struct platform_private *private = impl_from_DEVICE_OBJECT(device); private->udev_device = udev_device_ref(dev); private->device_fd = fd; -#ifdef HAS_PROPER_INPUT_HEADER - if (strcmp(subsystem, "input") == 0) - /* FIXME: We should probably move this to IRP_MN_START_DEVICE. */ - if (build_report_descriptor((struct wine_input_private *)private, dev)) - { - ERR("Building report descriptor failed, removing device\n"); - close(fd); - udev_device_unref(dev); - bus_unlink_hid_device(device); - bus_remove_hid_device(device); - HeapFree(GetProcessHeap(), 0, serial); - return; - } -#endif IoInvalidateDeviceRelations(bus_pdo, BusRelations); } else diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 545b2862086..9e1dc1e6c3b 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -489,6 +489,13 @@ static void mouse_free_device(DEVICE_OBJECT *device)
static NTSTATUS mouse_start_device(DEVICE_OBJECT *device) { + if (!hid_descriptor_begin(&mouse_desc, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_MOUSE)) + return STATUS_NO_MEMORY; + if (!hid_descriptor_add_buttons(&mouse_desc, HID_USAGE_PAGE_BUTTON, 1, 3)) + return STATUS_NO_MEMORY; + if (!hid_descriptor_end(&mouse_desc)) + return STATUS_NO_MEMORY; + return STATUS_SUCCESS; }
@@ -552,14 +559,6 @@ static const platform_vtbl mouse_vtbl = static void mouse_device_create(void) { static const WCHAR busidW[] = {'W','I','N','E','M','O','U','S','E',0}; - - if (!hid_descriptor_begin(&mouse_desc, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_MOUSE)) - return; - if (!hid_descriptor_add_buttons(&mouse_desc, HID_USAGE_PAGE_BUTTON, 1, 3)) - return; - if (!hid_descriptor_end(&mouse_desc)) - return; - mouse_obj = bus_create_hid_device(busidW, 0, 0, -1, 0, 0, busidW, FALSE, &mouse_vtbl, 0); IoInvalidateDeviceRelations(bus_pdo, BusRelations); } @@ -570,6 +569,13 @@ static void keyboard_free_device(DEVICE_OBJECT *device)
static NTSTATUS keyboard_start_device(DEVICE_OBJECT *device) { + if (!hid_descriptor_begin(&keyboard_desc, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYBOARD)) + return STATUS_NO_MEMORY; + if (!hid_descriptor_add_buttons(&keyboard_desc, HID_USAGE_PAGE_KEYBOARD, 0, 101)) + return STATUS_NO_MEMORY; + if (!hid_descriptor_end(&keyboard_desc)) + return STATUS_NO_MEMORY; + return STATUS_SUCCESS; }
@@ -633,14 +639,6 @@ static const platform_vtbl keyboard_vtbl = static void keyboard_device_create(void) { static const WCHAR busidW[] = {'W','I','N','E','K','E','Y','B','O','A','R','D',0}; - - if (!hid_descriptor_begin(&keyboard_desc, HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_KEYBOARD)) - return; - if (!hid_descriptor_add_buttons(&keyboard_desc, HID_USAGE_PAGE_KEYBOARD, 0, 101)) - return; - if (!hid_descriptor_end(&keyboard_desc)) - return; - keyboard_obj = bus_create_hid_device(busidW, 0, 0, -1, 0, 0, busidW, FALSE, &keyboard_vtbl, 0); IoInvalidateDeviceRelations(bus_pdo, BusRelations); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 1 - dlls/winebus.sys/main.c | 17 ----------------- 2 files changed, 18 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index f46daa7144d..d07b33e86b3 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -56,7 +56,6 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, const platform_vtbl *vtbl, DWORD platform_data_size) DECLSPEC_HIDDEN; DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) DECLSPEC_HIDDEN; void bus_unlink_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; -void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN; DEVICE_OBJECT *bus_enumerate_hid_devices(const WCHAR *bus_id, enum_func function, void *context) DECLSPEC_HIDDEN;
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 9e1dc1e6c3b..5db80784a5b 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -380,23 +380,6 @@ void bus_unlink_hid_device(DEVICE_OBJECT *device) LeaveCriticalSection(&device_list_cs); }
-void bus_remove_hid_device(DEVICE_OBJECT *device) -{ - struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - struct pnp_device *pnp_device = ext->pnp_device; - - TRACE("(%p)\n", device); - - ext->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&ext->cs); - - HeapFree(GetProcessHeap(), 0, ext->last_report); - IoDeleteDevice(device); - - /* pnp_device must be released after the device is gone */ - HeapFree(GetProcessHeap(), 0, pnp_device); -} - static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices) { int i;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 1 - dlls/winebus.sys/bus_iohid.c | 27 ++++------- dlls/winebus.sys/bus_sdl.c | 6 --- dlls/winebus.sys/bus_udev.c | 94 ++++++++++++++++-------------------- dlls/winebus.sys/main.c | 17 ------- 5 files changed, 51 insertions(+), 94 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index d07b33e86b3..5f763acbf3e 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -42,7 +42,6 @@ typedef struct NTSTATUS (*start_device)(DEVICE_OBJECT *device); NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length); NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length); - NTSTATUS (*begin_report_processing)(DEVICE_OBJECT *device); NTSTATUS (*set_output_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); NTSTATUS (*get_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read); NTSTATUS (*set_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 9b9e93f5c49..394e3228838 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -150,6 +150,15 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev)
static NTSTATUS start_device(DEVICE_OBJECT *device) { + DWORD length; + struct platform_private *private = impl_from_DEVICE_OBJECT(device); + CFNumberRef num; + + num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey)); + length = CFNumberToDWORD(num); + private->buffer = HeapAlloc(GetProcessHeap(), 0, length); + + IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, device); return STATUS_SUCCESS; }
@@ -204,23 +213,6 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS begin_report_processing(DEVICE_OBJECT *device) -{ - DWORD length; - struct platform_private *private = impl_from_DEVICE_OBJECT(device); - CFNumberRef num; - - if (private->buffer) - return STATUS_SUCCESS; - - num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey)); - length = CFNumberToDWORD(num); - private->buffer = HeapAlloc(GetProcessHeap(), 0, length); - - IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, device); - return STATUS_SUCCESS; -} - static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) { IOReturn result; @@ -282,7 +274,6 @@ static const platform_vtbl iohid_vtbl = start_device, get_reportdescriptor, get_string, - begin_report_processing, set_output_report, get_feature_report, set_feature_report, diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 21eac3c67f4..4770de02ffe 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -536,11 +536,6 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS begin_report_processing(DEVICE_OBJECT *device) -{ - return STATUS_SUCCESS; -} - static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) { struct platform_private *ext = impl_from_DEVICE_OBJECT(device); @@ -606,7 +601,6 @@ static const platform_vtbl sdl_vtbl = start_device, get_reportdescriptor, get_string, - begin_report_processing, set_output_report, get_feature_report, set_feature_report, diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 25c8b5f0b36..977e5f2972a 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -558,8 +558,27 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev) return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)); }
+static DWORD CALLBACK device_report_thread(void *args); + static NTSTATUS hidraw_start_device(DEVICE_OBJECT *device) { + struct platform_private *private = impl_from_DEVICE_OBJECT(device); + + if (pipe(private->control_pipe) != 0) + { + ERR("Control pipe creation failed\n"); + return STATUS_UNSUCCESSFUL; + } + + private->report_thread = CreateThread(NULL, 0, device_report_thread, device, 0, NULL); + if (!private->report_thread) + { + ERR("Unable to create device report thread\n"); + close(private->control_pipe[0]); + close(private->control_pipe[1]); + return STATUS_UNSUCCESSFUL; + } + return STATUS_SUCCESS; }
@@ -697,31 +716,6 @@ static DWORD CALLBACK device_report_thread(void *args) return 0; }
-static NTSTATUS begin_report_processing(DEVICE_OBJECT *device) -{ - struct platform_private *private = impl_from_DEVICE_OBJECT(device); - - if (private->report_thread) - return STATUS_SUCCESS; - - if (pipe(private->control_pipe) != 0) - { - ERR("Control pipe creation failed\n"); - return STATUS_UNSUCCESSFUL; - } - - private->report_thread = CreateThread(NULL, 0, device_report_thread, device, 0, NULL); - if (!private->report_thread) - { - ERR("Unable to create device report thread\n"); - close(private->control_pipe[0]); - close(private->control_pipe[1]); - return STATUS_UNSUCCESSFUL; - } - else - return STATUS_SUCCESS; -} - static NTSTATUS hidraw_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) { struct platform_private* ext = impl_from_DEVICE_OBJECT(device); @@ -826,7 +820,6 @@ static const platform_vtbl hidraw_vtbl = hidraw_start_device, hidraw_get_reportdescriptor, hidraw_get_string, - begin_report_processing, hidraw_set_output_report, hidraw_get_feature_report, hidraw_set_feature_report, @@ -860,10 +853,32 @@ static void lnxev_free_device(DEVICE_OBJECT *device) udev_device_unref(ext->base.udev_device); }
+static DWORD CALLBACK lnxev_device_report_thread(void *args); + static NTSTATUS lnxev_start_device(DEVICE_OBJECT *device) { struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device); - return build_report_descriptor(ext, ext->base.udev_device); + NTSTATUS status; + + if ((status = build_report_descriptor(ext, ext->base.udev_device))) + return status; + + if (pipe(ext->base.control_pipe) != 0) + { + ERR("Control pipe creation failed\n"); + return STATUS_UNSUCCESSFUL; + } + + ext->base.report_thread = CreateThread(NULL, 0, lnxev_device_report_thread, device, 0, NULL); + if (!ext->base.report_thread) + { + ERR("Unable to create device report thread\n"); + close(ext->base.control_pipe[0]); + close(ext->base.control_pipe[1]); + return STATUS_UNSUCCESSFUL; + } + + return STATUS_SUCCESS; }
static NTSTATUS lnxev_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) @@ -934,30 +949,6 @@ static DWORD CALLBACK lnxev_device_report_thread(void *args) return 0; }
-static NTSTATUS lnxev_begin_report_processing(DEVICE_OBJECT *device) -{ - struct wine_input_private *private = input_impl_from_DEVICE_OBJECT(device); - - if (private->base.report_thread) - return STATUS_SUCCESS; - - if (pipe(private->base.control_pipe) != 0) - { - ERR("Control pipe creation failed\n"); - return STATUS_UNSUCCESSFUL; - } - - private->base.report_thread = CreateThread(NULL, 0, lnxev_device_report_thread, device, 0, NULL); - if (!private->base.report_thread) - { - ERR("Unable to create device report thread\n"); - close(private->base.control_pipe[0]); - close(private->base.control_pipe[1]); - return STATUS_UNSUCCESSFUL; - } - return STATUS_SUCCESS; -} - static NTSTATUS lnxev_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) { *written = 0; @@ -982,7 +973,6 @@ static const platform_vtbl lnxev_vtbl = { lnxev_start_device, lnxev_get_reportdescriptor, lnxev_get_string, - lnxev_begin_report_processing, lnxev_set_output_report, lnxev_get_feature_report, lnxev_set_feature_report, diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 5db80784a5b..c5408f29beb 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -504,11 +504,6 @@ static NTSTATUS mouse_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buff return STATUS_SUCCESS; }
-static NTSTATUS mouse_begin_report_processing(DEVICE_OBJECT *device) -{ - return STATUS_SUCCESS; -} - static NTSTATUS mouse_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) { FIXME("id %u, stub!\n", id); @@ -533,7 +528,6 @@ static const platform_vtbl mouse_vtbl = .start_device = mouse_start_device, .get_reportdescriptor = mouse_get_reportdescriptor, .get_string = mouse_get_string, - .begin_report_processing = mouse_begin_report_processing, .set_output_report = mouse_set_output_report, .get_feature_report = mouse_get_feature_report, .set_feature_report = mouse_set_feature_report, @@ -584,11 +578,6 @@ static NTSTATUS keyboard_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *b return STATUS_SUCCESS; }
-static NTSTATUS keyboard_begin_report_processing(DEVICE_OBJECT *device) -{ - return STATUS_SUCCESS; -} - static NTSTATUS keyboard_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) { FIXME("id %u, stub!\n", id); @@ -613,7 +602,6 @@ static const platform_vtbl keyboard_vtbl = .start_device = keyboard_start_device, .get_reportdescriptor = keyboard_get_reportdescriptor, .get_string = keyboard_get_string, - .begin_report_processing = keyboard_begin_report_processing, .set_output_report = keyboard_set_output_report, .get_feature_report = keyboard_get_feature_report, .set_feature_report = keyboard_set_feature_report, @@ -923,9 +911,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_GET_INPUT_REPORT\n"); - irp->IoStatus.Status = ext->vtbl->begin_report_processing(device); - if (irp->IoStatus.Status != STATUS_SUCCESS) break; - irp->IoStatus.Status = deliver_last_report(ext, packet->reportBufferLen, packet->reportBuffer, &irp->IoStatus.Information); @@ -937,8 +922,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_READ_REPORT: { TRACE_(hid_report)("IOCTL_HID_READ_REPORT\n"); - irp->IoStatus.Status = ext->vtbl->begin_report_processing(device); - if (irp->IoStatus.Status != STATUS_SUCCESS) break; if (!ext->last_report_read) { irp->IoStatus.Status = deliver_last_report(ext,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 7 +-- dlls/winebus.sys/bus_iohid.c | 41 +++++++++-------- dlls/winebus.sys/bus_sdl.c | 29 ++++++------ dlls/winebus.sys/bus_udev.c | 89 +++++++++++++++++++----------------- dlls/winebus.sys/main.c | 55 +++++++++++----------- 5 files changed, 114 insertions(+), 107 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 5f763acbf3e..3e53b9c53f1 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -22,6 +22,7 @@ #include <winbase.h> #include <winternl.h> #include <ddk/wdm.h> +#include <ddk/hidclass.h> #include <hidusage.h>
typedef int(*enum_func)(DEVICE_OBJECT *device, void *context); @@ -42,9 +43,9 @@ typedef struct NTSTATUS (*start_device)(DEVICE_OBJECT *device); NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length); NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length); - NTSTATUS (*set_output_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); - NTSTATUS (*get_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read); - NTSTATUS (*set_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); + void (*set_output_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); + void (*get_feature_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); + void (*set_feature_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); } platform_vtbl;
void *get_platform_private(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 394e3228838..4eb0ea0e4b3 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -213,57 +213,60 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn result; struct platform_private *private = impl_from_DEVICE_OBJECT(device); - result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeOutput, id, report, length); + result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeOutput, packet->reportId, + packet->reportBuffer, packet->reportBufferLen); if (result == kIOReturnSuccess) { - *written = length; - return STATUS_SUCCESS; + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn ret; - CFIndex report_length = length; + CFIndex report_length = packet->reportBufferLen; struct platform_private *private = impl_from_DEVICE_OBJECT(device);
- ret = IOHIDDeviceGetReport(private->device, kIOHIDReportTypeFeature, id, report, &report_length); + ret = IOHIDDeviceGetReport(private->device, kIOHIDReportTypeFeature, packet->reportId, + packet->reportBuffer, &report_length); if (ret == kIOReturnSuccess) { - *read = report_length; - return STATUS_SUCCESS; + io->Information = report_length; + io->Status = STATUS_SUCCESS; } else { - *read = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn result; struct platform_private *private = impl_from_DEVICE_OBJECT(device);
- result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeFeature, id, report, length); + result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeFeature, packet->reportId, + packet->reportBuffer, packet->reportBufferLen); if (result == kIOReturnSuccess) { - *written = length; - return STATUS_SUCCESS; + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 4770de02ffe..84e3ef20664 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -536,14 +536,14 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { struct platform_private *ext = impl_from_DEVICE_OBJECT(device);
- if (ext->sdl_haptic && id == 0) + if (ext->sdl_haptic && packet->reportId == 0) { - WORD left = report[2] * 128; - WORD right = report[3] * 128; + WORD left = packet->reportBuffer[2] * 128; + WORD right = packet->reportBuffer[3] * 128;
if (ext->haptic_effect_id >= 0) { @@ -572,26 +572,27 @@ static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, pSDL_HapticRumblePlay(ext->sdl_haptic, i, -1); } } - *written = length; - return STATUS_SUCCESS; + + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; } }
-static NTSTATUS get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl sdl_vtbl = diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 977e5f2972a..77a242a6087 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -716,100 +716,103 @@ static DWORD CALLBACK device_report_thread(void *args) return 0; }
-static NTSTATUS hidraw_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void hidraw_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id)) - count = write(ext->device_fd, report, length); + if ((buffer[0] = packet->reportId)) + count = write(ext->device_fd, packet->reportBuffer, length); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { - memcpy(buffer + 1, report, length); + memcpy(buffer + 1, packet->reportBuffer, length); count = write(ext->device_fd, buffer, length + 1); }
if (count > 0) { - *written = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d write failed error: %d %s\n", id, errno, strerror(errno)); - *written = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d write failed error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS hidraw_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void hidraw_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { #if defined(HAVE_LINUX_HIDRAW_H) && defined(HIDIOCGFEATURE) struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id) && length <= 0x1fff) - count = ioctl(ext->device_fd, HIDIOCGFEATURE(length), report); + if ((buffer[0] = packet->reportId) && length <= 0x1fff) + count = ioctl(ext->device_fd, HIDIOCGFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot read\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot read\n", packet->reportId, length); else { count = ioctl(ext->device_fd, HIDIOCGFEATURE(length + 1), buffer); - memcpy(report, buffer + 1, length); + memcpy(packet->reportBuffer, buffer + 1, length); }
if (count > 0) { - *read = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d read failed, error: %d %s\n", id, errno, strerror(errno)); - *read = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d read failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } #else - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; #endif }
-static NTSTATUS hidraw_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void hidraw_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { #if defined(HAVE_LINUX_HIDRAW_H) && defined(HIDIOCSFEATURE) struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id) && length <= 0x1fff) - count = ioctl(ext->device_fd, HIDIOCSFEATURE(length), report); + if ((buffer[0] = packet->reportId) && length <= 0x1fff) + count = ioctl(ext->device_fd, HIDIOCSFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { - memcpy(buffer + 1, report, length); + memcpy(buffer + 1, packet->reportBuffer, length); count = ioctl(ext->device_fd, HIDIOCSFEATURE(length + 1), buffer); }
if (count > 0) { - *written = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d write failed, error: %d %s\n", id, errno, strerror(errno)); - *written = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d write failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } #else - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; #endif }
@@ -949,22 +952,22 @@ static DWORD CALLBACK lnxev_device_report_thread(void *args) return 0; }
-static NTSTATUS lnxev_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void lnxev_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS lnxev_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void lnxev_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS lnxev_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void lnxev_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl lnxev_vtbl = { diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index c5408f29beb..cd8573cf1d0 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -504,22 +504,25 @@ static NTSTATUS mouse_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buff return STATUS_SUCCESS; }
-static NTSTATUS mouse_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS mouse_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS mouse_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl mouse_vtbl = @@ -578,22 +581,25 @@ static NTSTATUS keyboard_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *b return STATUS_SUCCESS; }
-static NTSTATUS keyboard_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS keyboard_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS keyboard_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl keyboard_vtbl = @@ -940,28 +946,21 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); - irp->IoStatus.Status = ext->vtbl->set_output_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); + ext->vtbl->set_output_report(device, packet, &irp->IoStatus); break; } case IOCTL_HID_GET_FEATURE: { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_GET_FEATURE\n"); - irp->IoStatus.Status = ext->vtbl->get_feature_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); - packet->reportBufferLen = irp->IoStatus.Information; + ext->vtbl->get_feature_report(device, packet, &irp->IoStatus); break; } case IOCTL_HID_SET_FEATURE: { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_SET_FEATURE\n"); - irp->IoStatus.Status = ext->vtbl->set_feature_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); + ext->vtbl->set_feature_report(device, packet, &irp->IoStatus); break; } default: