Rémi Bernon : winebus.sys: Use SDL_JoystickGetType to set physical HID usage.
Alexandre Julliard
julliard at winehq.org
Thu Mar 3 16:06:42 CST 2022
Module: wine
Branch: master
Commit: 6efb40718be445111a4b757f0acd8a6c66161b25
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6efb40718be445111a4b757f0acd8a6c66161b25
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu Mar 3 12:02:03 2022 +0100
winebus.sys: Use SDL_JoystickGetType to set physical HID usage.
And pass through driving wheel and flight stick information to DInput.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winebus.sys/bus_sdl.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c
index 3d9935f0714..aedef50d3f7 100644
--- a/dlls/winebus.sys/bus_sdl.c
+++ b/dlls/winebus.sys/bus_sdl.c
@@ -117,6 +117,7 @@ static int (*pSDL_JoystickRumble)(SDL_Joystick *joystick, Uint16 low_frequency_r
static Uint16 (*pSDL_JoystickGetProduct)(SDL_Joystick * joystick);
static Uint16 (*pSDL_JoystickGetProductVersion)(SDL_Joystick * joystick);
static Uint16 (*pSDL_JoystickGetVendor)(SDL_Joystick * joystick);
+static SDL_JoystickType (*pSDL_JoystickGetType)(SDL_Joystick * joystick);
/* internal bits for extended rumble support, SDL_Haptic types are 16-bits */
#define WINE_SDL_JOYSTICK_RUMBLE 0x40000000 /* using SDL_JoystickRumble API */
@@ -258,6 +259,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
};
struct sdl_device *impl = impl_from_unix_device(iface);
int i, button_count, axis_count, ball_count, hat_count;
+ USAGE_AND_PAGE physical_usage;
axis_count = pSDL_JoystickNumAxes(impl->sdl_joystick);
if (axis_count > ARRAY_SIZE(absolute_usages))
@@ -276,10 +278,37 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
hat_count = pSDL_JoystickNumHats(impl->sdl_joystick);
button_count = pSDL_JoystickNumButtons(impl->sdl_joystick);
+ if (!pSDL_JoystickGetType) physical_usage = device_usage;
+ else switch (pSDL_JoystickGetType(impl->sdl_joystick))
+ {
+ case SDL_JOYSTICK_TYPE_ARCADE_PAD:
+ case SDL_JOYSTICK_TYPE_ARCADE_STICK:
+ case SDL_JOYSTICK_TYPE_DANCE_PAD:
+ case SDL_JOYSTICK_TYPE_DRUM_KIT:
+ case SDL_JOYSTICK_TYPE_GUITAR:
+ case SDL_JOYSTICK_TYPE_UNKNOWN:
+ physical_usage.UsagePage = HID_USAGE_PAGE_GENERIC;
+ physical_usage.Usage = HID_USAGE_GENERIC_JOYSTICK;
+ break;
+ case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
+ physical_usage.UsagePage = HID_USAGE_PAGE_GENERIC;
+ physical_usage.Usage = HID_USAGE_GENERIC_GAMEPAD;
+ break;
+ case SDL_JOYSTICK_TYPE_WHEEL:
+ physical_usage.UsagePage = HID_USAGE_PAGE_SIMULATION;
+ physical_usage.Usage = HID_USAGE_SIMULATION_AUTOMOBILE_SIMULATION_DEVICE;
+ break;
+ case SDL_JOYSTICK_TYPE_FLIGHT_STICK:
+ case SDL_JOYSTICK_TYPE_THROTTLE:
+ physical_usage.UsagePage = HID_USAGE_PAGE_SIMULATION;
+ physical_usage.Usage = HID_USAGE_SIMULATION_FLIGHT_SIMULATION_DEVICE;
+ break;
+ }
+
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
- if (!hid_device_begin_input_report(iface, &device_usage))
+ if (!hid_device_begin_input_report(iface, &physical_usage))
return STATUS_NO_MEMORY;
for (i = 0; i < axis_count; i++)
@@ -1026,6 +1055,7 @@ NTSTATUS sdl_bus_init(void *args)
pSDL_JoystickGetProduct = dlsym(sdl_handle, "SDL_JoystickGetProduct");
pSDL_JoystickGetProductVersion = dlsym(sdl_handle, "SDL_JoystickGetProductVersion");
pSDL_JoystickGetVendor = dlsym(sdl_handle, "SDL_JoystickGetVendor");
+ pSDL_JoystickGetType = dlsym(sdl_handle, "SDL_JoystickGetType");
if (pSDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0)
{
More information about the wine-cvs
mailing list