winebus.sys: Query product string on device creation.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-09-13 13:01:47 +02:00 committed by Alexandre Julliard
parent 9d4b70473c
commit 093c13e333
6 changed files with 28 additions and 39 deletions

View File

@ -190,9 +190,6 @@ static NTSTATUS iohid_device_get_string(struct unix_device *iface, DWORD index,
CFStringRef str;
switch (index)
{
case HID_STRING_ID_IPRODUCT:
str = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDProductKey));
break;
case HID_STRING_ID_ISERIALNUMBER:
str = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDSerialNumberKey));
break;
@ -312,6 +309,8 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
str = IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDManufacturerKey));
if (str) lstrcpynA(desc.manufacturer, str, sizeof(desc.manufacturer));
str = IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDProductKey));
if (str) lstrcpynA(desc.product, str, sizeof(desc.product));
if (IOHIDDeviceConformsTo(IOHIDDevice, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad) ||
IOHIDDeviceConformsTo(IOHIDDevice, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick))

View File

@ -517,17 +517,10 @@ static NTSTATUS sdl_device_get_reportdescriptor(struct unix_device *iface, BYTE
static NTSTATUS sdl_device_get_string(struct unix_device *iface, DWORD index, WCHAR *buffer, DWORD length)
{
struct platform_private *ext = impl_from_unix_device(iface);
const char* str = NULL;
switch (index)
{
case HID_STRING_ID_IPRODUCT:
if (ext->sdl_controller)
str = pSDL_GameControllerName(ext->sdl_controller);
else
str = pSDL_JoystickName(ext->sdl_joystick);
break;
case HID_STRING_ID_ISERIALNUMBER:
str = "000000";
break;
@ -755,6 +748,9 @@ static void sdl_add_device(unsigned int index)
if (options.map_controllers && pSDL_IsGameController(index))
controller = pSDL_GameControllerOpen(index);
if (controller) lstrcpynA(desc.product, pSDL_GameControllerName(controller), sizeof(desc.product));
else lstrcpynA(desc.product, pSDL_JoystickName(joystick), sizeof(desc.product));
id = pSDL_JoystickInstanceID(joystick);
if (pSDL_JoystickGetProductVersion != NULL) {

View File

@ -674,9 +674,6 @@ static NTSTATUS hidraw_device_get_string(struct unix_device *iface, DWORD index,
{
switch (index)
{
case HID_STRING_ID_IPRODUCT:
str = get_sysattr_string(usbdev, "product");
break;
case HID_STRING_ID_ISERIALNUMBER:
str = get_sysattr_string(usbdev, "serial");
break;
@ -690,15 +687,6 @@ static NTSTATUS hidraw_device_get_string(struct unix_device *iface, DWORD index,
#ifdef HAVE_LINUX_HIDRAW_H
switch (index)
{
case HID_STRING_ID_IPRODUCT:
{
char buf[MAX_PATH];
if (ioctl(private->device_fd, HIDIOCGRAWNAME(MAX_PATH), buf) == -1)
WARN("ioctl(HIDIOCGRAWNAME) failed: %d %s\n", errno, strerror(errno));
else
str = strdupAtoW(buf);
break;
}
case HID_STRING_ID_ISERIALNUMBER:
break;
default:
@ -961,9 +949,6 @@ static NTSTATUS lnxev_device_get_string(struct unix_device *iface, DWORD index,
str[0] = 0;
switch (index)
{
case HID_STRING_ID_IPRODUCT:
ioctl(ext->base.device_fd, EVIOCGNAME(sizeof(str)), str);
break;
case HID_STRING_ID_ISERIALNUMBER:
ioctl(ext->base.device_fd, EVIOCGUNIQ(sizeof(str)), str);
break;
@ -1083,6 +1068,9 @@ static void get_device_subsystem_info(struct udev_device *dev, char const *subsy
if (!desc->manufacturer[0] && (tmp = udev_device_get_sysattr_value(dev, "manufacturer")))
lstrcpynA(desc->manufacturer, tmp, sizeof(desc->manufacturer));
if (!desc->product[0] && (tmp = udev_device_get_sysattr_value(dev, "product")))
lstrcpynA(desc->product, tmp, sizeof(desc->product));
}
static void udev_add_device(struct udev_device *dev)
@ -1129,6 +1117,11 @@ static void udev_add_device(struct udev_device *dev)
{
desc.busid = hidraw_busidW;
if (!desc.manufacturer[0]) strcpy(desc.manufacturer, "hidraw");
#ifdef HAVE_LINUX_HIDRAW_H
if (!desc.product[0] && ioctl(fd, HIDIOCGRAWNAME(sizeof(desc.product) - 1), desc.product) < 0)
desc.product[0] = 0;
#endif
}
#ifdef HAS_PROPER_INPUT_HEADER
else if (!strcmp(subsystem, "input"))
@ -1152,6 +1145,9 @@ static void udev_add_device(struct udev_device *dev)
MultiByteToWideChar(CP_UNIXCP, 0, device_uid, -1, desc.serial, ARRAY_SIZE(desc.serial));
if (!desc.manufacturer[0]) strcpy(desc.manufacturer, "evdev");
if (!desc.product[0] && ioctl(fd, EVIOCGNAME(sizeof(desc.product) - 1), desc.product) <= 0)
desc.product[0] = 0;
}
#endif

View File

@ -112,6 +112,7 @@ struct device_extension
DWORD index;
WCHAR manufacturer[MAX_PATH];
WCHAR product[MAX_PATH];
BYTE *last_report;
DWORD last_report_size;
@ -367,6 +368,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni
ext->unix_device = unix_device;
MultiByteToWideChar(CP_UNIXCP, 0, ext->desc.manufacturer, -1, ext->manufacturer, MAX_PATH);
MultiByteToWideChar(CP_UNIXCP, 0, ext->desc.product, -1, ext->product, MAX_PATH);
InitializeListHead(&ext->irp_queue);
InitializeCriticalSection(&ext->cs);
@ -831,6 +833,11 @@ static NTSTATUS hid_get_device_string(DEVICE_OBJECT *device, DWORD index, WCHAR
if (len > buffer_len) return STATUS_BUFFER_TOO_SMALL;
else memcpy(buffer, ext->manufacturer, len);
return STATUS_SUCCESS;
case HID_STRING_ID_IPRODUCT:
len = (strlenW(ext->product) + 1) * sizeof(WCHAR);
if (len > buffer_len) return STATUS_BUFFER_TOO_SMALL;
else memcpy(buffer, ext->product, len);
return STATUS_SUCCESS;
}
return STATUS_NOT_IMPLEMENTED;

View File

@ -71,13 +71,7 @@ static NTSTATUS mouse_get_report_descriptor(struct unix_device *iface, BYTE *buf
static NTSTATUS mouse_get_string(struct unix_device *iface, DWORD index, WCHAR *buffer, DWORD length)
{
static const WCHAR nameW[] = {'W','i','n','e',' ','H','I','D',' ','m','o','u','s','e',0};
if (index != HID_STRING_ID_IPRODUCT)
return STATUS_NOT_IMPLEMENTED;
if (length < ARRAY_SIZE(nameW))
return STATUS_BUFFER_TOO_SMALL;
lstrcpyW(buffer, nameW);
return STATUS_SUCCESS;
return STATUS_NOT_IMPLEMENTED;
}
static void mouse_set_output_report(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io)
@ -120,6 +114,7 @@ static const struct device_desc mouse_device_desc =
.input = -1,
.serial = {'0','0','0','0',0},
.manufacturer = {"The Wine Project"},
.product = {"Wine HID mouse"},
};
static struct unix_device mouse_device = {.vtbl = &mouse_vtbl};
@ -165,13 +160,7 @@ static NTSTATUS keyboard_get_report_descriptor(struct unix_device *iface, BYTE *
static NTSTATUS keyboard_get_string(struct unix_device *iface, DWORD index, WCHAR *buffer, DWORD length)
{
static const WCHAR nameW[] = {'W','i','n','e',' ','H','I','D',' ','k','e','y','b','o','a','r','d',0};
if (index != HID_STRING_ID_IPRODUCT)
return STATUS_NOT_IMPLEMENTED;
if (length < ARRAY_SIZE(nameW))
return STATUS_BUFFER_TOO_SMALL;
lstrcpyW(buffer, nameW);
return STATUS_SUCCESS;
return STATUS_NOT_IMPLEMENTED;
}
static void keyboard_set_output_report(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io)
@ -214,6 +203,7 @@ static const struct device_desc keyboard_device_desc =
.input = -1,
.serial = {'0','0','0','0',0},
.manufacturer = {"The Wine Project"},
.product = {"Wine HID keyboard"},
};
static struct unix_device keyboard_device = {.vtbl = &keyboard_vtbl};

View File

@ -44,6 +44,7 @@ struct device_desc
BOOL is_gamepad;
char manufacturer[MAX_PATH];
char product[MAX_PATH];
};
struct sdl_bus_options