Commit a1736729 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

hidclass.sys: Stop creating a setupapi device.

parent aff72f22
MODULE = hidclass.sys
IMPORTLIB = hidclass
IMPORTS = hal ntoskrnl
DELAYIMPORTS = setupapi
EXTRADLLFLAGS = -mno-cygwin
......
......@@ -25,7 +25,6 @@
#include "hid.h"
#include "winreg.h"
#include "winuser.h"
#include "setupapi.h"
#include "wine/debug.h"
#include "ddk/hidsdi.h"
......@@ -37,69 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(hid);
WINE_DECLARE_DEBUG_CHANNEL(hid_report);
/* user32 reserves 1 & 2 for winemouse and winekeyboard,
* keep this in sync with user_private.h */
#define WINE_MOUSE_HANDLE 1
#define WINE_KEYBOARD_HANDLE 2
static UINT32 alloc_rawinput_handle(void)
{
static LONG counter = WINE_KEYBOARD_HANDLE + 1;
return InterlockedIncrement(&counter);
}
NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device)
{
WCHAR device_instance_id[MAX_DEVICE_ID_LEN];
SP_DEVINFO_DATA Data;
HDEVINFO devinfo;
BASE_DEVICE_EXTENSION *ext;
USAGE usage, page;
ext = device->DeviceExtension;
page = ext->u.pdo.preparsed_data->caps.UsagePage;
usage = ext->u.pdo.preparsed_data->caps.Usage;
lstrcpyW(device_instance_id, ext->device_id);
lstrcatW(device_instance_id, L"\\");
lstrcatW(device_instance_id, ext->instance_id);
devinfo = SetupDiCreateDeviceInfoList(&GUID_DEVCLASS_HIDCLASS, NULL);
if (devinfo == INVALID_HANDLE_VALUE)
{
FIXME( "failed to get ClassDevs %x\n", GetLastError());
return STATUS_UNSUCCESSFUL;
}
Data.cbSize = sizeof(Data);
if (SetupDiCreateDeviceInfoW(devinfo, device_instance_id, &GUID_DEVCLASS_HIDCLASS, NULL, NULL, DICD_INHERIT_CLASSDRVS, &Data))
{
if (!SetupDiRegisterDeviceInfo(devinfo, &Data, 0, NULL, NULL, NULL))
{
FIXME( "failed to register device info %x\n", GetLastError());
goto error;
}
}
else if (GetLastError() != ERROR_DEVINST_ALREADY_EXISTS)
{
FIXME( "failed to create device info %x\n", GetLastError());
goto error;
}
SetupDiDestroyDeviceInfoList(devinfo);
if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_MOUSE)
ext->u.pdo.rawinput_handle = WINE_MOUSE_HANDLE;
else if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_KEYBOARD)
ext->u.pdo.rawinput_handle = WINE_KEYBOARD_HANDLE;
else
ext->u.pdo.rawinput_handle = alloc_rawinput_handle();
return STATUS_SUCCESS;
error:
SetupDiDestroyDeviceInfoList(devinfo);
return STATUS_UNSUCCESSFUL;
}
IRP *pop_irp_from_queue(BASE_DEVICE_EXTENSION *ext)
{
LIST_ENTRY *entry;
......
......@@ -106,7 +106,6 @@ typedef struct _minidriver
NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) DECLSPEC_HIDDEN;
/* Internal device functions */
NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
void HID_StartDeviceThread(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
IRP *pop_irp_from_queue(BASE_DEVICE_EXTENSION *ext) DECLSPEC_HIDDEN;
......
......@@ -86,6 +86,17 @@ static NTSTATUS get_device_id(DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WCH
return irp_status.u.Status;
}
/* user32 reserves 1 & 2 for winemouse and winekeyboard,
* keep this in sync with user_private.h */
#define WINE_MOUSE_HANDLE 1
#define WINE_KEYBOARD_HANDLE 2
static UINT32 alloc_rawinput_handle(void)
{
static LONG counter = WINE_KEYBOARD_HANDLE + 1;
return InterlockedIncrement(&counter);
}
static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *bus_pdo)
{
WCHAR device_id[MAX_DEVICE_ID_LEN], instance_id[MAX_DEVICE_ID_LEN], pdo_name[255];
......@@ -93,6 +104,7 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *b
HID_DEVICE_ATTRIBUTES attr = {0};
DEVICE_OBJECT *fdo, *child_pdo;
UNICODE_STRING string;
USAGE page, usage;
NTSTATUS status;
minidriver *minidriver;
HID_DESCRIPTOR descriptor;
......@@ -214,7 +226,14 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *b
IoInvalidateDeviceRelations(bus_pdo, BusRelations);
HID_LinkDevice(child_pdo);
page = pdo_ext->u.pdo.preparsed_data->caps.UsagePage;
usage = pdo_ext->u.pdo.preparsed_data->caps.Usage;
if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_MOUSE)
pdo_ext->u.pdo.rawinput_handle = WINE_MOUSE_HANDLE;
else if (page == HID_USAGE_PAGE_GENERIC && usage == HID_USAGE_GENERIC_KEYBOARD)
pdo_ext->u.pdo.rawinput_handle = WINE_KEYBOARD_HANDLE;
else
pdo_ext->u.pdo.rawinput_handle = alloc_rawinput_handle();
pdo_ext->u.pdo.poll_interval = DEFAULT_POLL_INTERVAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment