winepulse: Move AudioClient's GetService into mmdevapi.
[wine.git] / dlls / winehid.sys / main.c
blobca549ab472825411f5e7e4c25cd7e6b556eaf034
1 /*
2 * WINE Hid minidriver
4 * Copyright 2016 Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "ntstatus.h"
24 #define WIN32_NO_STATUS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winternl.h"
28 #include "winioctl.h"
29 #include "ddk/wdm.h"
30 #include "ddk/hidport.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(hid);
35 static NTSTATUS WINAPI internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
37 NTSTATUS status = irp->IoStatus.Status;
38 IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
39 ULONG code = irpsp->Parameters.DeviceIoControl.IoControlCode;
41 switch (code)
43 case IOCTL_GET_PHYSICAL_DESCRIPTOR:
44 case IOCTL_HID_ACTIVATE_DEVICE:
45 case IOCTL_HID_DEACTIVATE_DEVICE:
46 case IOCTL_HID_GET_INDEXED_STRING:
47 case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
48 case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
49 case IOCTL_HID_GET_REPORT_DESCRIPTOR:
50 case IOCTL_HID_GET_STRING:
51 case IOCTL_HID_GET_INPUT_REPORT:
52 case IOCTL_HID_READ_REPORT:
53 case IOCTL_HID_SET_OUTPUT_REPORT:
54 case IOCTL_HID_WRITE_REPORT:
55 case IOCTL_HID_GET_FEATURE:
56 case IOCTL_HID_SET_FEATURE:
57 /* All these are handled by the lower level driver */
58 IoSkipCurrentIrpStackLocation(irp);
59 return IoCallDriver(((HID_DEVICE_EXTENSION *)device->DeviceExtension)->NextDeviceObject, irp);
61 default:
62 FIXME("Unsupported ioctl %#lx (device=%lx access=%lx func=%lx method=%lx)\n",
63 code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3);
64 IoCompleteRequest(irp, IO_NO_INCREMENT);
65 return status;
69 static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp)
71 HID_DEVICE_EXTENSION *ext = device->DeviceExtension;
73 IoSkipCurrentIrpStackLocation(irp);
74 return IoCallDriver(ext->NextDeviceObject, irp);
77 static NTSTATUS WINAPI add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *device)
79 TRACE("(%p, %p)\n", driver, device);
80 return STATUS_SUCCESS;
83 NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path)
85 HID_MINIDRIVER_REGISTRATION registration;
87 TRACE("(%p, %s)\n", driver, debugstr_w(path->Buffer));
89 driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = internal_ioctl;
90 driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
91 driver->DriverExtension->AddDevice = add_device;
93 memset(&registration, 0, sizeof(registration));
94 registration.DriverObject = driver;
95 registration.RegistryPath = path;
96 registration.DeviceExtensionSize = sizeof(HID_DEVICE_EXTENSION);
97 registration.DevicesArePolled = FALSE;
99 return HidRegisterMinidriver(&registration);