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
26 #include "wine/debug.h"
28 #define WIN32_NO_STATUS
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
);
48 BOOLEAN WINAPI
HidD_GetAttributes(HANDLE HidDeviceObject
, PHIDD_ATTRIBUTES Attr
)
50 HID_COLLECTION_INFORMATION info
;
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
);
59 Attr
->VendorID
= info
.VendorID
;
60 Attr
->ProductID
= info
.ProductID
;
61 Attr
->VersionNumber
= info
.VersionNumber
;
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_SetFeature(HANDLE HidDeviceObject
, PVOID ReportBuffer
, ULONG ReportBufferLength
)
92 TRACE("(%p %p %u)\n", HidDeviceObject
, ReportBuffer
, ReportBufferLength
);
93 return DeviceIoControl(HidDeviceObject
, IOCTL_HID_SET_FEATURE
, ReportBuffer
, ReportBufferLength
, NULL
, 0, NULL
, NULL
);
96 BOOLEAN WINAPI
HidD_SetNumInputBuffers(HANDLE HidDeviceObject
, ULONG NumberBuffers
)
98 TRACE("(%p %i)\n", HidDeviceObject
, NumberBuffers
);
99 return DeviceIoControl(HidDeviceObject
, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS
, UlongToPtr(NumberBuffers
), sizeof(NumberBuffers
), NULL
, 0, NULL
, NULL
);
102 BOOLEAN WINAPI
HidD_GetProductString(HANDLE HidDeviceObject
, PVOID Buffer
, ULONG BufferLength
)
104 TRACE("(%p %p %u)\n", HidDeviceObject
, Buffer
, BufferLength
);
105 return DeviceIoControl(HidDeviceObject
, IOCTL_HID_GET_PRODUCT_STRING
, NULL
, 0, Buffer
, BufferLength
, NULL
, NULL
);
108 BOOLEAN WINAPI
HidD_GetSerialNumberString(HANDLE HidDeviceObject
, PVOID Buffer
, ULONG BufferLength
)
110 TRACE("(%p %p %u)\n", HidDeviceObject
, Buffer
, BufferLength
);
111 return DeviceIoControl(HidDeviceObject
, IOCTL_HID_GET_SERIALNUMBER_STRING
, NULL
, 0, Buffer
, BufferLength
, NULL
, NULL
);
114 BOOLEAN WINAPI
HidD_GetPreparsedData(HANDLE HidDeviceObject
, PHIDP_PREPARSED_DATA
*PreparsedData
)
116 HID_COLLECTION_INFORMATION info
;
117 PHIDP_PREPARSED_DATA data
;
119 TRACE("(%p %p)\n", HidDeviceObject
, PreparsedData
);
121 if (!DeviceIoControl(HidDeviceObject
, IOCTL_HID_GET_COLLECTION_INFORMATION
, NULL
, 0,
122 &info
, sizeof(HID_COLLECTION_INFORMATION
), NULL
, NULL
))
125 if (!(data
= HeapAlloc(GetProcessHeap(), 0, info
.DescriptorSize
))) return FALSE
;
127 if (!DeviceIoControl(HidDeviceObject
, IOCTL_HID_GET_COLLECTION_DESCRIPTOR
, NULL
, 0,
128 data
, info
.DescriptorSize
, NULL
, NULL
))
130 HeapFree( GetProcessHeap(), 0, data
);
133 *PreparsedData
= data
;