2021-08-23 10:49:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Rémi Bernon for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINEBUS_UNIXLIB_H
|
|
|
|
#define __WINEBUS_UNIXLIB_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winternl.h>
|
2021-09-03 09:30:49 +02:00
|
|
|
#include <ddk/hidclass.h>
|
2021-08-23 10:49:39 +02:00
|
|
|
#include <hidusage.h>
|
|
|
|
|
2021-09-03 09:30:48 +02:00
|
|
|
#include "wine/debug.h"
|
2021-08-30 11:22:52 +02:00
|
|
|
#include "wine/list.h"
|
2021-08-23 10:49:39 +02:00
|
|
|
|
2021-09-03 09:30:48 +02:00
|
|
|
struct device_desc
|
|
|
|
{
|
2022-01-31 10:10:59 +01:00
|
|
|
UINT vid;
|
|
|
|
UINT pid;
|
|
|
|
UINT version;
|
|
|
|
UINT input;
|
|
|
|
UINT uid;
|
2021-09-03 09:30:48 +02:00
|
|
|
BOOL is_gamepad;
|
2021-09-13 13:01:46 +02:00
|
|
|
|
2021-10-05 10:55:50 +02:00
|
|
|
WCHAR manufacturer[MAX_PATH];
|
|
|
|
WCHAR product[MAX_PATH];
|
|
|
|
WCHAR serialnumber[MAX_PATH];
|
2021-09-03 09:30:48 +02:00
|
|
|
};
|
|
|
|
|
2021-08-23 10:49:40 +02:00
|
|
|
struct sdl_bus_options
|
|
|
|
{
|
|
|
|
BOOL map_controllers;
|
2021-09-16 10:17:55 +02:00
|
|
|
/* freed after bus_init */
|
2022-01-31 10:10:59 +01:00
|
|
|
UINT mappings_count;
|
2021-09-16 10:17:55 +02:00
|
|
|
char **mappings;
|
2021-08-23 10:49:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct udev_bus_options
|
|
|
|
{
|
|
|
|
BOOL disable_hidraw;
|
|
|
|
BOOL disable_input;
|
winebus.sys: Add code path to bypass udevd and use inotify.
In a container with a non-trivial user namespace, we cannot rely on
libudev communicating with udevd as a way to monitor device nodes,
for the following reasons:
* If uid 0 from the host is not mapped to uid 0 in the container, libudev
cannot authenticate netlink messages from the host, because their sender
uid appears to be the overflowuid. Resolving this by mapping uid 0 into
the container is not allowed when creating user namespaces as an
unprivileged user, and even when running as a privileged user, it might
be desirable for the real uid 0 to not be mapped as a way to harden the
security boundary between container and host.
* Depending on the container configuration, initial enumeration might
not be able to read /run/udev from the host system. If it can't, sysfs
attributes will still work because those are read directly from the
kernel via sysfs, but udev properties coming from user-space rules
(in particular ID_INPUT_JOYSTICK and friends) will appear to be missing.
* The protocols between udevd and libudev (netlink messages for monitoring,
and /run/udev for initial enumeration) are considered to be private to
a particular version of udev, and are not a stable API; but in a
container, we cannot expect that our copy of libudev is at exactly the
same version as udevd on the host system.
Sidestep this by adding a code path that continues to use libudev for
the parts that work regardless of whether udevd is running or can be
communicated with.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-20 11:07:27 +02:00
|
|
|
BOOL disable_udevd;
|
2021-08-23 10:49:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iohid_bus_options
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2021-08-23 10:49:41 +02:00
|
|
|
struct unix_device;
|
|
|
|
|
2021-08-30 11:22:51 +02:00
|
|
|
enum bus_event_type
|
|
|
|
{
|
|
|
|
BUS_EVENT_TYPE_NONE,
|
2021-08-30 11:22:52 +02:00
|
|
|
BUS_EVENT_TYPE_DEVICE_REMOVED,
|
2021-09-06 09:17:31 +02:00
|
|
|
BUS_EVENT_TYPE_DEVICE_CREATED,
|
2021-09-15 09:04:41 +02:00
|
|
|
BUS_EVENT_TYPE_INPUT_REPORT,
|
2021-08-30 11:22:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bus_event
|
|
|
|
{
|
|
|
|
enum bus_event_type type;
|
2021-08-30 11:22:52 +02:00
|
|
|
struct list entry;
|
|
|
|
|
2021-09-16 10:17:52 +02:00
|
|
|
struct unix_device *device;
|
2021-08-30 11:22:52 +02:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2021-09-06 09:17:31 +02:00
|
|
|
struct device_desc desc;
|
|
|
|
} device_created;
|
2021-09-15 09:04:41 +02:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
USHORT length;
|
|
|
|
BYTE buffer[1];
|
|
|
|
} input_report;
|
2021-08-30 11:22:52 +02:00
|
|
|
};
|
2021-08-30 11:22:51 +02:00
|
|
|
};
|
|
|
|
|
2021-08-30 11:22:55 +02:00
|
|
|
struct device_create_params
|
|
|
|
{
|
2021-09-03 09:30:48 +02:00
|
|
|
struct device_desc desc;
|
2021-08-30 11:22:55 +02:00
|
|
|
struct unix_device *device;
|
|
|
|
};
|
|
|
|
|
2021-09-03 09:30:49 +02:00
|
|
|
struct device_descriptor_params
|
|
|
|
{
|
|
|
|
struct unix_device *iface;
|
|
|
|
BYTE *buffer;
|
2022-01-31 10:10:59 +01:00
|
|
|
UINT length;
|
|
|
|
UINT *out_length;
|
2021-09-03 09:30:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct device_report_params
|
|
|
|
{
|
|
|
|
struct unix_device *iface;
|
|
|
|
HID_XFER_PACKET *packet;
|
|
|
|
IO_STATUS_BLOCK *io;
|
|
|
|
};
|
|
|
|
|
2021-08-23 10:49:39 +02:00
|
|
|
enum unix_funcs
|
|
|
|
{
|
|
|
|
sdl_init,
|
|
|
|
sdl_wait,
|
|
|
|
sdl_stop,
|
|
|
|
udev_init,
|
|
|
|
udev_wait,
|
|
|
|
udev_stop,
|
|
|
|
iohid_init,
|
|
|
|
iohid_wait,
|
|
|
|
iohid_stop,
|
2021-08-30 11:22:55 +02:00
|
|
|
mouse_create,
|
|
|
|
keyboard_create,
|
2021-09-03 09:30:49 +02:00
|
|
|
device_remove,
|
|
|
|
device_start,
|
|
|
|
device_get_report_descriptor,
|
|
|
|
device_set_output_report,
|
|
|
|
device_get_feature_report,
|
|
|
|
device_set_feature_report,
|
2021-08-23 10:49:39 +02:00
|
|
|
};
|
|
|
|
|
2021-09-03 09:30:48 +02:00
|
|
|
static inline const char *debugstr_device_desc(struct device_desc *desc)
|
|
|
|
{
|
|
|
|
if (!desc) return "(null)";
|
2021-09-20 09:37:06 +02:00
|
|
|
return wine_dbg_sprintf("{vid %04x, pid %04x, version %04x, input %d, uid %08x, is_gamepad %u}",
|
|
|
|
desc->vid, desc->pid, desc->version, desc->input, desc->uid, desc->is_gamepad);
|
2021-09-03 09:30:48 +02:00
|
|
|
}
|
|
|
|
|
2021-08-23 10:49:39 +02:00
|
|
|
#endif /* __WINEBUS_UNIXLIB_H */
|