2015-07-06 20:09:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Aric Stewart
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winternl.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "winioctl.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "ddk/wdm.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "hidusage.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "ddk/hidport.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "ddk/hidclass.h"
|
|
|
|
#include "ddk/hidpi.h"
|
2021-08-16 10:07:53 +02:00
|
|
|
#include "ddk/hidpddi.h"
|
2016-04-05 15:45:34 +02:00
|
|
|
#include "cfgmgr32.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "wine/list.h"
|
2019-10-30 20:25:58 +01:00
|
|
|
#include "wine/hid.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
|
|
|
|
#define DEFAULT_POLL_INTERVAL 200
|
|
|
|
#define MAX_POLL_INTERVAL_MSEC 10000
|
|
|
|
|
2015-09-11 17:45:54 +02:00
|
|
|
/* Ring buffer functions */
|
|
|
|
struct ReportRingBuffer;
|
|
|
|
|
2021-04-16 04:04:01 +02:00
|
|
|
typedef struct _BASE_DEVICE_EXTENSION
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/* this must be the first member */
|
|
|
|
HID_DEVICE_EXTENSION hid_ext;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2021-04-16 04:04:01 +02:00
|
|
|
DEVICE_OBJECT *child_pdo;
|
|
|
|
} fdo;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2021-04-16 04:04:01 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
DEVICE_OBJECT *parent_fdo;
|
|
|
|
|
|
|
|
HID_COLLECTION_INFORMATION information;
|
2021-08-16 10:07:53 +02:00
|
|
|
HIDP_DEVICE_DESC device_desc;
|
2021-04-16 04:04:01 +02:00
|
|
|
|
|
|
|
ULONG poll_interval;
|
|
|
|
HANDLE halt_event;
|
|
|
|
HANDLE thread;
|
|
|
|
UINT32 rawinput_handle;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2021-09-24 10:07:13 +02:00
|
|
|
KSPIN_LOCK queues_lock;
|
|
|
|
struct list queues;
|
2021-08-10 11:31:15 +02:00
|
|
|
|
2021-04-16 04:04:01 +02:00
|
|
|
UNICODE_STRING link_name;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2021-07-01 18:53:25 +02:00
|
|
|
KSPIN_LOCK lock;
|
|
|
|
BOOL removed;
|
|
|
|
|
2021-04-16 04:04:01 +02:00
|
|
|
BOOL is_mouse;
|
|
|
|
UNICODE_STRING mouse_link_name;
|
2021-04-22 21:26:51 +02:00
|
|
|
BOOL is_keyboard;
|
|
|
|
UNICODE_STRING keyboard_link_name;
|
2021-04-16 04:04:01 +02:00
|
|
|
} pdo;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
/* These are unique to the parent FDO, but stored in the children as well
|
|
|
|
* for convenience. */
|
|
|
|
WCHAR device_id[MAX_DEVICE_ID_LEN];
|
|
|
|
WCHAR instance_id[MAX_DEVICE_ID_LEN];
|
2021-09-03 07:57:36 +02:00
|
|
|
const GUID *class_guid;
|
2021-04-16 04:04:01 +02:00
|
|
|
|
|
|
|
BOOL is_fdo;
|
2015-09-01 22:02:13 +02:00
|
|
|
} BASE_DEVICE_EXTENSION;
|
2015-07-06 20:09:14 +02:00
|
|
|
|
2021-08-10 11:31:17 +02:00
|
|
|
struct hid_report
|
2021-08-10 11:31:15 +02:00
|
|
|
{
|
2021-08-10 11:31:17 +02:00
|
|
|
LONG ref;
|
|
|
|
ULONG length;
|
|
|
|
BYTE buffer[1];
|
2021-08-10 11:31:15 +02:00
|
|
|
};
|
|
|
|
|
2021-09-24 10:07:13 +02:00
|
|
|
struct hid_queue
|
2021-08-10 11:31:17 +02:00
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
KSPIN_LOCK lock;
|
|
|
|
ULONG length;
|
|
|
|
ULONG read_idx;
|
|
|
|
ULONG write_idx;
|
|
|
|
struct hid_report *reports[512];
|
2021-09-24 10:07:12 +02:00
|
|
|
LIST_ENTRY irp_queue;
|
2021-08-10 11:31:17 +02:00
|
|
|
};
|
2015-09-11 17:45:54 +02:00
|
|
|
|
2015-07-06 20:09:14 +02:00
|
|
|
typedef struct _minidriver
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
|
|
|
|
HID_MINIDRIVER_REGISTRATION minidriver;
|
|
|
|
|
|
|
|
PDRIVER_UNLOAD DriverUnload;
|
2015-09-09 17:20:11 +02:00
|
|
|
|
2019-06-06 17:12:49 +02:00
|
|
|
PDRIVER_ADD_DEVICE AddDevice;
|
2016-04-05 15:45:34 +02:00
|
|
|
PDRIVER_DISPATCH PNPDispatch;
|
2015-07-06 20:09:14 +02:00
|
|
|
} minidriver;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2021-08-03 18:55:21 +02:00
|
|
|
void call_minidriver( ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size,
|
|
|
|
void *out_buff, ULONG out_size, IO_STATUS_BLOCK *io ) DECLSPEC_HIDDEN;
|
2015-09-09 17:20:11 +02:00
|
|
|
|
2015-09-01 22:02:13 +02:00
|
|
|
/* Internal device functions */
|
2015-10-08 21:34:35 +02:00
|
|
|
void HID_StartDeviceThread(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
|
2021-09-24 10:07:13 +02:00
|
|
|
void hid_queue_remove_pending_irps( struct hid_queue *queue );
|
|
|
|
void hid_queue_destroy( struct hid_queue *queue );
|
2021-04-16 04:04:01 +02:00
|
|
|
|
|
|
|
NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
|
|
|
NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
|
|
|
NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
|
|
|
NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
|
|
|
NTSTATUS WINAPI pdo_close(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|