winebus.sys: Load bus options in main.c.
And pass them to bus_init function. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
edbb3fac25
commit
7e1d1fac70
|
@ -52,7 +52,6 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLS
|
|||
DEVICE_OBJECT *bus_enumerate_hid_devices(const WCHAR *bus_id, enum_func function, void *context) DECLSPEC_HIDDEN;
|
||||
|
||||
/* General Bus Functions */
|
||||
DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN;
|
||||
BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HANDLE driver_key DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -99,6 +99,7 @@ static IOHIDManagerRef hid_manager;
|
|||
static CFRunLoopRef run_loop;
|
||||
|
||||
static const WCHAR busidW[] = {'I','O','H','I','D',0};
|
||||
static struct iohid_bus_options options;
|
||||
|
||||
struct platform_private
|
||||
{
|
||||
|
@ -387,6 +388,10 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender,
|
|||
|
||||
NTSTATUS iohid_bus_init(void *args)
|
||||
{
|
||||
TRACE("args %p\n", args);
|
||||
|
||||
options = *(struct iohid_bus_options *)args;
|
||||
|
||||
if (!(hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, 0L)))
|
||||
{
|
||||
ERR("IOHID manager creation failed\n");
|
||||
|
|
|
@ -60,8 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
|
|||
WINE_DECLARE_DEBUG_CHANNEL(hid_report);
|
||||
|
||||
static const WCHAR sdl_busidW[] = {'S','D','L','J','O','Y',0};
|
||||
|
||||
static DWORD map_controllers = 0;
|
||||
static struct sdl_bus_options options;
|
||||
|
||||
static void *sdl_handle = NULL;
|
||||
static UINT quit_event = -1;
|
||||
|
@ -748,7 +747,7 @@ static void try_add_device(unsigned int index)
|
|||
return;
|
||||
}
|
||||
|
||||
if (map_controllers && pSDL_IsGameController(index))
|
||||
if (options.map_controllers && pSDL_IsGameController(index))
|
||||
controller = pSDL_GameControllerOpen(index);
|
||||
|
||||
id = pSDL_JoystickInstanceID(joystick);
|
||||
|
@ -891,8 +890,9 @@ static void sdl_load_mappings(void)
|
|||
|
||||
NTSTATUS sdl_bus_init(void *args)
|
||||
{
|
||||
static const WCHAR controller_modeW[] = {'M','a','p',' ','C','o','n','t','r','o','l','l','e','r','s',0};
|
||||
static const UNICODE_STRING controller_mode = {sizeof(controller_modeW) - sizeof(WCHAR), sizeof(controller_modeW), (WCHAR*)controller_modeW};
|
||||
TRACE("args %p\n", args);
|
||||
|
||||
options = *(struct sdl_bus_options *)args;
|
||||
|
||||
if (!(sdl_handle = dlopen(SONAME_LIBSDL2, RTLD_NOW)))
|
||||
{
|
||||
|
@ -963,8 +963,6 @@ NTSTATUS sdl_bus_init(void *args)
|
|||
pSDL_JoystickEventState(SDL_ENABLE);
|
||||
pSDL_GameControllerEventState(SDL_ENABLE);
|
||||
|
||||
map_controllers = check_bus_option(&controller_mode, 1);
|
||||
|
||||
/* Process mappings */
|
||||
if (pSDL_GameControllerAddMapping != NULL) sdl_load_mappings();
|
||||
|
||||
|
|
|
@ -90,13 +90,12 @@ WINE_DECLARE_DEBUG_CHANNEL(hid_report);
|
|||
|
||||
static struct udev *udev_context = NULL;
|
||||
static struct udev_monitor *udev_monitor;
|
||||
static DWORD disable_hidraw = 0;
|
||||
static DWORD disable_input = 0;
|
||||
static int deviceloop_control[2];
|
||||
static int udev_monitor_fd;
|
||||
|
||||
static const WCHAR hidraw_busidW[] = {'H','I','D','R','A','W',0};
|
||||
static const WCHAR lnxev_busidW[] = {'L','N','X','E','V',0};
|
||||
static struct udev_bus_options options;
|
||||
|
||||
struct platform_private
|
||||
{
|
||||
|
@ -1181,11 +1180,11 @@ static void build_initial_deviceset(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!disable_hidraw)
|
||||
if (!options.disable_hidraw)
|
||||
if (udev_enumerate_add_match_subsystem(enumerate, "hidraw") < 0)
|
||||
WARN("Failed to add subsystem 'hidraw' to enumeration\n");
|
||||
#ifdef HAS_PROPER_INPUT_HEADER
|
||||
if (!disable_input)
|
||||
if (!options.disable_input)
|
||||
{
|
||||
if (udev_enumerate_add_match_subsystem(enumerate, "input") < 0)
|
||||
WARN("Failed to add subsystem 'input' to enumeration\n");
|
||||
|
@ -1224,7 +1223,7 @@ static struct udev_monitor *create_monitor(int *fd)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!disable_hidraw)
|
||||
if (!options.disable_hidraw)
|
||||
{
|
||||
if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "hidraw", NULL) < 0)
|
||||
WARN("Failed to add 'hidraw' subsystem to monitor\n");
|
||||
|
@ -1232,7 +1231,7 @@ static struct udev_monitor *create_monitor(int *fd)
|
|||
systems++;
|
||||
}
|
||||
#ifdef HAS_PROPER_INPUT_HEADER
|
||||
if (!disable_input)
|
||||
if (!options.disable_input)
|
||||
{
|
||||
if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "input", NULL) < 0)
|
||||
WARN("Failed to add 'input' subsystem to monitor\n");
|
||||
|
@ -1288,10 +1287,9 @@ static void process_monitor_event(struct udev_monitor *monitor)
|
|||
|
||||
NTSTATUS udev_bus_init(void *args)
|
||||
{
|
||||
static const WCHAR hidraw_disabledW[] = {'D','i','s','a','b','l','e','H','i','d','r','a','w',0};
|
||||
static const UNICODE_STRING hidraw_disabled = {sizeof(hidraw_disabledW) - sizeof(WCHAR), sizeof(hidraw_disabledW), (WCHAR*)hidraw_disabledW};
|
||||
static const WCHAR input_disabledW[] = {'D','i','s','a','b','l','e','I','n','p','u','t',0};
|
||||
static const UNICODE_STRING input_disabled = {sizeof(input_disabledW) - sizeof(WCHAR), sizeof(input_disabledW), (WCHAR*)input_disabledW};
|
||||
TRACE("args %p\n", args);
|
||||
|
||||
options = *(struct udev_bus_options *)args;
|
||||
|
||||
if (pipe(deviceloop_control) != 0)
|
||||
{
|
||||
|
@ -1305,16 +1303,6 @@ NTSTATUS udev_bus_init(void *args)
|
|||
goto error;
|
||||
}
|
||||
|
||||
disable_hidraw = check_bus_option(&hidraw_disabled, 0);
|
||||
if (disable_hidraw)
|
||||
TRACE("UDEV hidraw devices disabled in registry\n");
|
||||
|
||||
#ifdef HAS_PROPER_INPUT_HEADER
|
||||
disable_input = check_bus_option(&input_disabled, 0);
|
||||
if (disable_input)
|
||||
TRACE("UDEV input devices disabled in registry\n");
|
||||
#endif
|
||||
|
||||
if (!(udev_monitor = create_monitor(&udev_monitor_fd)))
|
||||
{
|
||||
ERR("UDEV monitor creation failed\n");
|
||||
|
|
|
@ -411,6 +411,20 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value)
|
||||
{
|
||||
char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])];
|
||||
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
|
||||
DWORD size;
|
||||
|
||||
if (NtQueryValueKey(driver_key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS)
|
||||
{
|
||||
if (info->Type == REG_DWORD) return *(DWORD *)info->Data;
|
||||
}
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp)
|
||||
{
|
||||
NTSTATUS status = irp->IoStatus.Status;
|
||||
|
@ -632,6 +646,7 @@ struct bus_main_params
|
|||
{
|
||||
const WCHAR *name;
|
||||
|
||||
void *init_args;
|
||||
HANDLE init_done;
|
||||
unsigned int init_code;
|
||||
unsigned int wait_code;
|
||||
|
@ -643,7 +658,7 @@ static DWORD CALLBACK bus_main_thread(void *args)
|
|||
NTSTATUS status;
|
||||
|
||||
TRACE("%s main loop starting\n", debugstr_w(bus.name));
|
||||
status = winebus_call(bus.init_code, NULL);
|
||||
status = winebus_call(bus.init_code, bus.init_args);
|
||||
SetEvent(bus.init_done);
|
||||
TRACE("%s main loop started\n", debugstr_w(bus.name));
|
||||
|
||||
|
@ -682,35 +697,55 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus)
|
|||
static NTSTATUS sdl_driver_init(void)
|
||||
{
|
||||
static const WCHAR bus_name[] = {'S','D','L',0};
|
||||
static const WCHAR controller_modeW[] = {'M','a','p',' ','C','o','n','t','r','o','l','l','e','r','s',0};
|
||||
static const UNICODE_STRING controller_mode = {sizeof(controller_modeW) - sizeof(WCHAR), sizeof(controller_modeW), (WCHAR*)controller_modeW};
|
||||
struct sdl_bus_options bus_options;
|
||||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_args = &bus_options,
|
||||
.init_code = sdl_init,
|
||||
.wait_code = sdl_wait,
|
||||
};
|
||||
|
||||
bus_options.map_controllers = check_bus_option(&controller_mode, 1);
|
||||
if (!bus_options.map_controllers) TRACE("SDL controller to XInput HID gamepad mapping disabled\n");
|
||||
|
||||
return bus_main_thread_start(&bus);
|
||||
}
|
||||
|
||||
static NTSTATUS udev_driver_init(void)
|
||||
{
|
||||
static const WCHAR bus_name[] = {'U','D','E','V',0};
|
||||
static const WCHAR hidraw_disabledW[] = {'D','i','s','a','b','l','e','H','i','d','r','a','w',0};
|
||||
static const UNICODE_STRING hidraw_disabled = {sizeof(hidraw_disabledW) - sizeof(WCHAR), sizeof(hidraw_disabledW), (WCHAR*)hidraw_disabledW};
|
||||
static const WCHAR input_disabledW[] = {'D','i','s','a','b','l','e','I','n','p','u','t',0};
|
||||
static const UNICODE_STRING input_disabled = {sizeof(input_disabledW) - sizeof(WCHAR), sizeof(input_disabledW), (WCHAR*)input_disabledW};
|
||||
struct udev_bus_options bus_options;
|
||||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_args = &bus_options,
|
||||
.init_code = udev_init,
|
||||
.wait_code = udev_wait,
|
||||
};
|
||||
|
||||
bus_options.disable_hidraw = check_bus_option(&hidraw_disabled, 0);
|
||||
if (bus_options.disable_hidraw) TRACE("UDEV hidraw devices disabled in registry\n");
|
||||
bus_options.disable_input = check_bus_option(&input_disabled, 0);
|
||||
if (bus_options.disable_input) TRACE("UDEV input devices disabled in registry\n");
|
||||
|
||||
return bus_main_thread_start(&bus);
|
||||
}
|
||||
|
||||
static NTSTATUS iohid_driver_init(void)
|
||||
{
|
||||
static const WCHAR bus_name[] = {'I','O','H','I','D'};
|
||||
struct iohid_bus_options bus_options;
|
||||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_args = &bus_options,
|
||||
.init_code = iohid_init,
|
||||
.wait_code = iohid_wait,
|
||||
};
|
||||
|
@ -1120,21 +1155,6 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length)
|
|||
LeaveCriticalSection(&ext->cs);
|
||||
}
|
||||
|
||||
DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value)
|
||||
{
|
||||
char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])];
|
||||
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION*)buffer;
|
||||
DWORD size;
|
||||
|
||||
if (NtQueryValueKey(driver_key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS)
|
||||
{
|
||||
if (info->Type == REG_DWORD)
|
||||
return *(DWORD*)info->Data;
|
||||
}
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
BOOL is_xbox_gamepad(WORD vid, WORD pid)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -29,6 +29,21 @@
|
|||
|
||||
#include "wine/unixlib.h"
|
||||
|
||||
struct sdl_bus_options
|
||||
{
|
||||
BOOL map_controllers;
|
||||
};
|
||||
|
||||
struct udev_bus_options
|
||||
{
|
||||
BOOL disable_hidraw;
|
||||
BOOL disable_input;
|
||||
};
|
||||
|
||||
struct iohid_bus_options
|
||||
{
|
||||
};
|
||||
|
||||
enum unix_funcs
|
||||
{
|
||||
sdl_init,
|
||||
|
|
Loading…
Reference in New Issue