Instead of calling bus_create_hid_device.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_sdl.c | 14 ++++---------- dlls/winebus.sys/main.c | 10 ++++++++++ dlls/winebus.sys/unix_private.h | 1 + dlls/winebus.sys/unixlib.c | 14 ++++++++++++++ dlls/winebus.sys/unixlib.h | 7 +++++++ 5 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 1f7cf237e25..80252e7e6b1 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -741,7 +741,6 @@ static void sdl_add_device(unsigned int index) .serial = {'0','0','0','0',0}, }; struct platform_private *private; - DEVICE_OBJECT *device = NULL; char guid_str[34];
SDL_Joystick* joystick; @@ -791,16 +790,11 @@ static void sdl_add_device(unsigned int index) if (!(private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*private)))) return; private->unix_device.vtbl = &sdl_device_vtbl; + private->sdl_joystick = joystick; + private->sdl_controller = controller; + private->id = id;
- device = bus_create_hid_device(&desc, &private->unix_device); - if (!device) HeapFree(GetProcessHeap(), 0, private); - else - { - private->sdl_joystick = joystick; - private->sdl_controller = controller; - private->id = id; - IoInvalidateDeviceRelations(bus_pdo, BusRelations); - } + bus_event_queue_device_created(&event_queue, &private->unix_device, &desc); }
static void process_device_event(SDL_Event *event) diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 6093a0b79eb..8a565bc3c46 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -578,6 +578,16 @@ static DWORD CALLBACK bus_main_thread(void *args) LeaveCriticalSection(&device_list_cs); IoInvalidateDeviceRelations(bus_pdo, BusRelations); break; + case BUS_EVENT_TYPE_DEVICE_CREATED: + device = bus_create_hid_device(&event->device_created.desc, event->device_created.device); + if (device) IoInvalidateDeviceRelations(bus_pdo, BusRelations); + else + { + WARN("failed to create device for %s bus device %p\n", + debugstr_w(bus.name), event->device_created.device); + winebus_call(device_remove, event->device_created.device); + } + break; } }
diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 81c4658068b..5cf999fff86 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -61,6 +61,7 @@ extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
extern void bus_event_queue_destroy(struct list *queue) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, void *context) DECLSPEC_HIDDEN; +extern BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DECLSPEC_HIDDEN;
struct hid_descriptor diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 2337cb3706d..9b0ccc0ae1a 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -327,6 +327,20 @@ BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, voi return TRUE; }
+BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) +{ + ULONG size = sizeof(struct bus_event); + struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); + if (!event) return FALSE; + + event->type = BUS_EVENT_TYPE_DEVICE_CREATED; + event->device_created.device = device; + event->device_created.desc = *desc; + list_add_tail(queue, &event->entry); + + return TRUE; +} + BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) { struct list *entry = list_head(queue); diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index 96671de0cac..85a03dd17ee 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -65,6 +65,7 @@ enum bus_event_type { BUS_EVENT_TYPE_NONE, BUS_EVENT_TYPE_DEVICE_REMOVED, + BUS_EVENT_TYPE_DEVICE_CREATED, };
struct bus_event @@ -79,6 +80,12 @@ struct bus_event const WCHAR *bus_id; void *context; } device_removed; + + struct + { + struct unix_device *device; + struct device_desc desc; + } device_created; }; };