Skip to content

Commit

Permalink
winebus.sys: Also pass axis and button count to is_hidraw_enabled()
Browse files Browse the repository at this point in the history
This is useful to detect some devices which do not have a well-known
PID set.

Link: ValveSoftware/Proton#6839 (comment)
  • Loading branch information
kakra committed Oct 3, 2023
1 parent 95ebcfa commit 7fceaf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions dlls/winebus.sys/bus_udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,7 @@ static void udev_add_device(struct udev_device *dev, int fd)
const char *subsystem;
const char *devnode;
int bus = 0;
int axes = -1, buttons = -1;

if (!(devnode = udev_device_get_devnode(dev)))
{
Expand All @@ -1644,6 +1645,9 @@ static void udev_add_device(struct udev_device *dev, int fd)
close(fd);
return;
}

axes = count_abs_axis(fd);
buttons = count_buttons(fd, NULL);
#endif

get_device_subsystem_info(dev, "hid", &desc, &bus);
Expand Down Expand Up @@ -1697,7 +1701,7 @@ static void udev_add_device(struct udev_device *dev, int fd)
memcpy(desc.serialnumber, zeros, sizeof(zeros));
}

if (!is_hidraw_enabled(desc.vid, desc.pid))
if (!is_hidraw_enabled(desc.vid, desc.pid, axes, buttons))
{
TRACE("hidraw %s: deferring %s to a different backend\n", debugstr_a(devnode), debugstr_device_desc(&desc));
close(fd);
Expand All @@ -1712,12 +1716,7 @@ static void udev_add_device(struct udev_device *dev, int fd)
}
#ifdef HAS_PROPER_INPUT_HEADER
else
{
int axes=0, buttons=0;
axes = count_abs_axis(fd);
buttons = count_buttons(fd, NULL);
desc.is_gamepad = (axes == 6 && buttons >= 14);
}
#endif

TRACE("dev %p, node %s, desc %s.\n", dev, debugstr_a(devnode), debugstr_device_desc(&desc));
Expand Down
2 changes: 1 addition & 1 deletion dlls/winebus.sys/unix_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,6 @@ BOOL is_wine_blacklisted(WORD vid, WORD pid) DECLSPEC_HIDDEN;
BOOL is_dualshock4_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
BOOL is_dualsense_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
BOOL is_logitech_g920(WORD vid, WORD pid) DECLSPEC_HIDDEN;
BOOL is_hidraw_enabled(WORD vid, WORD pid) DECLSPEC_HIDDEN;
BOOL is_hidraw_enabled(WORD vid, WORD pid, INT axes, INT buttons) DECLSPEC_HIDDEN;

#endif /* __WINEBUS_UNIX_PRIVATE_H */
2 changes: 1 addition & 1 deletion dlls/winebus.sys/unixlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static BOOL is_fanatec_pedals(WORD vid, WORD pid)
return FALSE;
}

BOOL is_hidraw_enabled(WORD vid, WORD pid)
BOOL is_hidraw_enabled(WORD vid, WORD pid, INT axes, INT buttons)
{
const char *enabled = getenv("PROTON_ENABLE_HIDRAW");
char needle[16];
Expand Down

0 comments on commit 7fceaf7

Please sign in to comment.