winebus.sys: Return an event from SDL bus wait on device creation.
Instead of calling bus_create_hid_device. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ec9892585e
commit
507a3076de
|
@ -741,7 +741,6 @@ static void sdl_add_device(unsigned int index)
|
||||||
.serial = {'0','0','0','0',0},
|
.serial = {'0','0','0','0',0},
|
||||||
};
|
};
|
||||||
struct platform_private *private;
|
struct platform_private *private;
|
||||||
DEVICE_OBJECT *device = NULL;
|
|
||||||
char guid_str[34];
|
char guid_str[34];
|
||||||
|
|
||||||
SDL_Joystick* joystick;
|
SDL_Joystick* joystick;
|
||||||
|
@ -791,16 +790,11 @@ static void sdl_add_device(unsigned int index)
|
||||||
if (!(private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*private))))
|
if (!(private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*private))))
|
||||||
return;
|
return;
|
||||||
private->unix_device.vtbl = &sdl_device_vtbl;
|
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);
|
bus_event_queue_device_created(&event_queue, &private->unix_device, &desc);
|
||||||
if (!device) HeapFree(GetProcessHeap(), 0, private);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
private->sdl_joystick = joystick;
|
|
||||||
private->sdl_controller = controller;
|
|
||||||
private->id = id;
|
|
||||||
IoInvalidateDeviceRelations(bus_pdo, BusRelations);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_device_event(SDL_Event *event)
|
static void process_device_event(SDL_Event *event)
|
||||||
|
|
|
@ -578,6 +578,16 @@ static DWORD CALLBACK bus_main_thread(void *args)
|
||||||
LeaveCriticalSection(&device_list_cs);
|
LeaveCriticalSection(&device_list_cs);
|
||||||
IoInvalidateDeviceRelations(bus_pdo, BusRelations);
|
IoInvalidateDeviceRelations(bus_pdo, BusRelations);
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern void bus_event_queue_destroy(struct list *queue) 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_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;
|
extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct hid_descriptor
|
struct hid_descriptor
|
||||||
|
|
|
@ -327,6 +327,20 @@ BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, voi
|
||||||
return TRUE;
|
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)
|
BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event)
|
||||||
{
|
{
|
||||||
struct list *entry = list_head(queue);
|
struct list *entry = list_head(queue);
|
||||||
|
|
|
@ -65,6 +65,7 @@ enum bus_event_type
|
||||||
{
|
{
|
||||||
BUS_EVENT_TYPE_NONE,
|
BUS_EVENT_TYPE_NONE,
|
||||||
BUS_EVENT_TYPE_DEVICE_REMOVED,
|
BUS_EVENT_TYPE_DEVICE_REMOVED,
|
||||||
|
BUS_EVENT_TYPE_DEVICE_CREATED,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bus_event
|
struct bus_event
|
||||||
|
@ -79,6 +80,12 @@ struct bus_event
|
||||||
const WCHAR *bus_id;
|
const WCHAR *bus_id;
|
||||||
void *context;
|
void *context;
|
||||||
} device_removed;
|
} device_removed;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct unix_device *device;
|
||||||
|
struct device_desc desc;
|
||||||
|
} device_created;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue