wsdapi/tests: Add tests for CreateUdpMessageParameters.
[wine.git] / dlls / hid / hidd.c
blob1161f0cba6906c43fa2069539eb790c75e092cf6
1 /*
2 * Human Input Devices
4 * Copyright (C) 2006 Kevin Koltzau
5 * Copyright (C) 2015 Aric Stewart
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <stdarg.h>
26 #include "wine/debug.h"
28 #define WIN32_NO_STATUS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winternl.h"
32 #include "winioctl.h"
33 #include "ddk/wdm.h"
35 #include "hidusage.h"
36 #include "ddk/hidclass.h"
37 #include "ddk/hidsdi.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(hid);
41 BOOLEAN WINAPI HidD_FreePreparsedData(PHIDP_PREPARSED_DATA PreparsedData)
43 TRACE("(%p)\n", PreparsedData);
44 HeapFree(GetProcessHeap(), 0, PreparsedData);
45 return TRUE;
48 BOOLEAN WINAPI HidD_GetAttributes(HANDLE HidDeviceObject, PHIDD_ATTRIBUTES Attr)
50 HID_COLLECTION_INFORMATION info;
51 BOOLEAN ret;
53 TRACE("(%p %p)\n", HidDeviceObject, Attr);
55 ret = DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, NULL, 0, &info, sizeof(HID_COLLECTION_INFORMATION), NULL, NULL);
57 if (ret)
59 Attr->VendorID = info.VendorID;
60 Attr->ProductID = info.ProductID;
61 Attr->VersionNumber = info.VersionNumber;
63 return ret;
66 BOOLEAN WINAPI HidD_GetFeature(HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength)
68 TRACE("(%p %p %u)\n", HidDeviceObject, ReportBuffer, ReportBufferLength);
69 return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_FEATURE, NULL, 0, ReportBuffer, ReportBufferLength, NULL, NULL);
72 void WINAPI HidD_GetHidGuid(LPGUID guid)
74 TRACE("(%p)\n", guid);
75 *guid = GUID_DEVINTERFACE_HID;
78 BOOLEAN WINAPI HidD_GetInputReport(HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength)
80 TRACE("(%p %p %u)\n", HidDeviceObject, ReportBuffer, ReportBufferLength);
81 return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INPUT_REPORT, NULL, 0, ReportBuffer, ReportBufferLength, NULL, NULL);
84 BOOLEAN WINAPI HidD_GetManufacturerString(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength)
86 TRACE("(%p %p %u)\n", HidDeviceObject, Buffer, BufferLength);
87 return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MANUFACTURER_STRING, NULL, 0, Buffer, BufferLength, NULL, NULL);
90 BOOLEAN WINAPI HidD_GetNumInputBuffers(HANDLE HidDeviceObject, ULONG *NumberBuffers)
92 TRACE("(%p %p)\n", HidDeviceObject, NumberBuffers);
93 return DeviceIoControl(HidDeviceObject, IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS, NULL, 0, NumberBuffers, sizeof(*NumberBuffers), NULL, NULL);
96 BOOLEAN WINAPI HidD_SetFeature(HANDLE HidDeviceObject, PVOID ReportBuffer, ULONG ReportBufferLength)
98 TRACE("(%p %p %u)\n", HidDeviceObject, ReportBuffer, ReportBufferLength);
99 return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_FEATURE, ReportBuffer, ReportBufferLength, NULL, 0, NULL, NULL);
102 BOOLEAN WINAPI HidD_SetNumInputBuffers(HANDLE HidDeviceObject, ULONG NumberBuffers)
104 TRACE("(%p %i)\n", HidDeviceObject, NumberBuffers);
105 return DeviceIoControl(HidDeviceObject, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS, UlongToPtr(NumberBuffers), sizeof(NumberBuffers), NULL, 0, NULL, NULL);
108 BOOLEAN WINAPI HidD_GetProductString(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength)
110 TRACE("(%p %p %u)\n", HidDeviceObject, Buffer, BufferLength);
111 return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_PRODUCT_STRING, NULL, 0, Buffer, BufferLength, NULL, NULL);
114 BOOLEAN WINAPI HidD_GetSerialNumberString(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength)
116 TRACE("(%p %p %u)\n", HidDeviceObject, Buffer, BufferLength);
117 return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_SERIALNUMBER_STRING, NULL, 0, Buffer, BufferLength, NULL, NULL);
120 BOOLEAN WINAPI HidD_GetPreparsedData(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData)
122 HID_COLLECTION_INFORMATION info;
123 PHIDP_PREPARSED_DATA data;
125 TRACE("(%p %p)\n", HidDeviceObject, PreparsedData);
127 if (!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, NULL, 0,
128 &info, sizeof(HID_COLLECTION_INFORMATION), NULL, NULL))
129 return FALSE;
131 if (!(data = HeapAlloc(GetProcessHeap(), 0, info.DescriptorSize))) return FALSE;
133 if (!DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, NULL, 0,
134 data, info.DescriptorSize, NULL, NULL))
136 HeapFree( GetProcessHeap(), 0, data );
137 return FALSE;
139 *PreparsedData = data;
140 return TRUE;
143 BOOLEAN WINAPI HidD_SetOutputReport(HANDLE HidDeviceObject, void *ReportBuffer, ULONG ReportBufferLength)
145 TRACE("(%p %p %u)\n", HidDeviceObject, ReportBuffer, ReportBufferLength);
146 return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_OUTPUT_REPORT, ReportBuffer, ReportBufferLength, NULL, 0, NULL, NULL);