diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index ac9f5cfdbda..cb85fd0fd92 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -443,17 +443,12 @@ static void sdl_device_destroy(struct unix_device *iface) static NTSTATUS sdl_device_start(struct unix_device *iface) { struct sdl_device *impl = impl_from_unix_device(iface); - NTSTATUS status; pthread_mutex_lock(&sdl_cs); - - if (impl->sdl_controller) status = build_controller_report_descriptor(iface); - else status = build_joystick_report_descriptor(iface); - impl->started = !status; - + impl->started = TRUE; pthread_mutex_unlock(&sdl_cs); - return status; + return STATUS_SUCCESS; } static void sdl_device_stop(struct unix_device *iface) @@ -1006,6 +1001,8 @@ static void sdl_add_device(unsigned int index) for (axis_offset = 0; axis_offset < axis_count; axis_offset += (options.split_controllers ? 6 : axis_count)) { + NTSTATUS status; + if (!axis_offset) strcpy(buffer, product); else snprintf(buffer, ARRAY_SIZE(buffer), "%s %d", product, axis_offset / 6); ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.product, ARRAY_SIZE(desc.product)); @@ -1019,6 +1016,15 @@ static void sdl_add_device(unsigned int index) impl->id = id; impl->axis_offset = axis_offset; + if (impl->sdl_controller) status = build_controller_report_descriptor(&impl->unix_device); + else status = build_joystick_report_descriptor(&impl->unix_device); + if (status) + { + list_remove(&impl->unix_device.entry); + impl->unix_device.vtbl->destroy(&impl->unix_device); + return; + } + bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc); } } diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 30c44979992..cb16dd39451 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -728,12 +728,6 @@ static void lnxev_device_destroy(struct unix_device *iface) static NTSTATUS lnxev_device_start(struct unix_device *iface) { - struct lnxev_device *impl = lnxev_impl_from_unix_device(iface); - NTSTATUS status; - - if ((status = build_report_descriptor(iface, impl->base.udev_device))) - return status; - pthread_mutex_lock(&udev_cs); start_polling_device(iface); pthread_mutex_unlock(&udev_cs); @@ -1321,6 +1315,13 @@ static void udev_add_device(struct udev_device *dev, int fd) strcpy(impl->devnode, devnode); impl->device_fd = fd; + if (build_report_descriptor(&impl->unix_device, impl->udev_device)) + { + list_remove(&impl->unix_device.entry); + impl->unix_device.vtbl->destroy(&impl->unix_device); + return; + } + bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc); } #endif diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 2668468305c..bd4351f059c 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -49,14 +49,6 @@ static void mouse_destroy(struct unix_device *iface) static NTSTATUS mouse_start(struct unix_device *iface) { - const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE}; - if (!hid_device_begin_report_descriptor(iface, &device_usage)) - return STATUS_NO_MEMORY; - if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_BUTTON, 1, 3)) - return STATUS_NO_MEMORY; - if (!hid_device_end_report_descriptor(iface)) - return STATUS_NO_MEMORY; - return STATUS_SUCCESS; } @@ -123,9 +115,21 @@ static const struct device_desc mouse_device_desc = static NTSTATUS mouse_device_create(void *args) { + const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE}; struct device_create_params *params = args; + struct unix_device *iface; + + if (!(iface = hid_device_create(&mouse_vtbl, sizeof(struct mouse_device)))) + return STATUS_NO_MEMORY; + if (!hid_device_begin_report_descriptor(iface, &device_usage)) + return STATUS_NO_MEMORY; + if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_BUTTON, 1, 3)) + return STATUS_NO_MEMORY; + if (!hid_device_end_report_descriptor(iface)) + return STATUS_NO_MEMORY; + params->desc = mouse_device_desc; - params->device = (UINT_PTR)hid_device_create(&mouse_vtbl, sizeof(struct mouse_device)); + params->device = (UINT_PTR)iface; return STATUS_SUCCESS; } @@ -140,14 +144,6 @@ static void keyboard_destroy(struct unix_device *iface) static NTSTATUS keyboard_start(struct unix_device *iface) { - const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD}; - if (!hid_device_begin_report_descriptor(iface, &device_usage)) - return STATUS_NO_MEMORY; - if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_KEYBOARD, 0, 101)) - return STATUS_NO_MEMORY; - if (!hid_device_end_report_descriptor(iface)) - return STATUS_NO_MEMORY; - return STATUS_SUCCESS; } @@ -214,9 +210,21 @@ static const struct device_desc keyboard_device_desc = static NTSTATUS keyboard_device_create(void *args) { + const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD}; struct device_create_params *params = args; + struct unix_device *iface; + + if (!(iface = hid_device_create(&keyboard_vtbl, sizeof(struct keyboard_device)))) + return STATUS_NO_MEMORY; + if (!hid_device_begin_report_descriptor(iface, &device_usage)) + return STATUS_NO_MEMORY; + if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_KEYBOARD, 0, 101)) + return STATUS_NO_MEMORY; + if (!hid_device_end_report_descriptor(iface)) + return STATUS_NO_MEMORY; + params->desc = keyboard_device_desc; - params->device = (UINT_PTR)hid_device_create(&keyboard_vtbl, sizeof(struct keyboard_device)); + params->device = (UINT_PTR)iface; return STATUS_SUCCESS; }