Commit 395d2685 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

hid: Change format of preparsed data.

Advantages of this format: - all table elements have constant size, that makes iterating table easier - allow report lookup by report ID in O(1) time - doesn't sort reports, it makes it possible to preserve original order of elements making output of functions more similar to native - preparsed data is created from collection, this will allow to add support for multiple top-most collections Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAric Stewart <aric@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 421c83cd
/*
* Internal HID structures
* Wine internal HID structures
*
* Copyright 2015 Aric Stewart
*
......@@ -18,18 +18,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __HID_PARSE_H
#define __HID_PARSE_H
#ifndef __WINE_PARSE_H
#define __WINE_PARSE_H
#define HID_MAGIC 0x8491759
typedef enum {
typedef enum __WINE_ELEMENT_TYPE {
UnknownElement = 0,
ButtonElement,
ValueElement,
} WINE_ELEMENT_TYPE;
typedef struct
typedef struct __WINE_ELEMENT
{
WINE_ELEMENT_TYPE ElementType;
UINT valueStartBit;
......@@ -40,33 +40,30 @@ typedef struct
} caps;
} WINE_HID_ELEMENT;
typedef struct
typedef struct __WINE_HID_REPORT
{
UCHAR reportID;
DWORD dwSize;
DWORD bitSize;
DWORD elementCount;
WINE_HID_ELEMENT Elements[1];
DWORD elementIdx;
} WINE_HID_REPORT;
typedef struct
typedef struct __WINE_HIDP_PREPARSED_DATA
{
DWORD magic;
DWORD dwSize;
HIDP_CAPS caps;
DWORD dwInputReportCount;
DWORD dwOutputReportCount;
DWORD dwFeatureReportCount;
DWORD dwOutputReportOffset;
DWORD dwFeatureReportOffset;
DWORD elementOffset;
DWORD reportCount[3];
BYTE reportIdx[3][256];
WINE_HID_REPORT InputReports[1];
WINE_HID_REPORT reports[1];
} WINE_HIDP_PREPARSED_DATA, *PWINE_HIDP_PREPARSED_DATA;
#define HID_NEXT_REPORT(d,r) ((r)?(WINE_HID_REPORT*)(((BYTE*)(r))+(r)->dwSize):(d)->InputReports)
#define HID_INPUT_REPORTS(d) ((d)->InputReports)
#define HID_OUTPUT_REPORTS(d) ((WINE_HID_REPORT*)(((BYTE*)(d)->InputReports)+(d)->dwOutputReportOffset))
#define HID_FEATURE_REPORTS(d) ((WINE_HID_REPORT*)(((BYTE*)(d)->InputReports)+(d)->dwFeatureReportOffset))
#define HID_INPUT_REPORTS(d) ((d)->reports)
#define HID_OUTPUT_REPORTS(d) ((d)->reports + (d)->reportCount[0])
#define HID_FEATURE_REPORTS(d) ((d)->reports + (d)->reportCount[0] + (d)->reportCount[1])
#define HID_ELEMS(d) ((WINE_HID_ELEMENT*)((BYTE*)(d) + (d)->elementOffset))
#endif /* __HID_PARSE_H */
#endif /* __WINE_PARSE_H */
......@@ -353,7 +353,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
if (!exit_now && irp->IoStatus.u.Status == STATUS_SUCCESS)
{
packet->reportBufferLen = irp->IoStatus.Information;
if (ext->preparseData->InputReports[0].reportID)
if (ext->preparseData->reports[0].reportID)
packet->reportId = packet->reportBuffer[0];
else
packet->reportId = 0;
......@@ -590,7 +590,7 @@ NTSTATUS WINAPI HID_Device_ioctl(DEVICE_OBJECT *device, IRP *irp)
packet = HeapAlloc(GetProcessHeap(), 0, packet_size);
if (extension->preparseData->InputReports[0].reportID)
if (extension->preparseData->reports[0].reportID)
packet->reportId = buffer[0];
else
packet->reportId = 0;
......
......@@ -43,9 +43,9 @@ typedef struct __WINE_ELEMENT
typedef struct __WINE_HID_REPORT
{
UCHAR reportID;
DWORD dwSize;
DWORD bitSize;
DWORD elementCount;
WINE_HID_ELEMENT Elements[1];
DWORD elementIdx;
} WINE_HID_REPORT;
typedef struct __WINE_HIDP_PREPARSED_DATA
......@@ -54,19 +54,16 @@ typedef struct __WINE_HIDP_PREPARSED_DATA
DWORD dwSize;
HIDP_CAPS caps;
DWORD dwInputReportCount;
DWORD dwOutputReportCount;
DWORD dwFeatureReportCount;
DWORD dwOutputReportOffset;
DWORD dwFeatureReportOffset;
DWORD elementOffset;
DWORD reportCount[3];
BYTE reportIdx[3][256];
WINE_HID_REPORT InputReports[1];
} WINE_HIDP_PREPARSED_DATA;
WINE_HID_REPORT reports[1];
} WINE_HIDP_PREPARSED_DATA, *PWINE_HIDP_PREPARSED_DATA;
#define HID_NEXT_REPORT(d,r) ((r)?(WINE_HID_REPORT*)(((BYTE*)(r))+(r)->dwSize):(d)->InputReports)
#define HID_INPUT_REPORTS(d) ((d)->InputReports)
#define HID_OUTPUT_REPORTS(d) (WINE_HID_REPORT*)(((BYTE*)(d)->InputReports)+(d)->dwOutputReportOffset)
#define HID_FEATURE_REPORTS(d) (WINE_HID_REPORT*)(((BYTE*)(d)->InputReports)+(d)->dwFeatureReportOffset)
#define HID_INPUT_REPORTS(d) ((d)->reports)
#define HID_OUTPUT_REPORTS(d) ((d)->reports + (d)->reportCount[0])
#define HID_FEATURE_REPORTS(d) ((d)->reports + (d)->reportCount[0] + (d)->reportCount[1])
#define HID_ELEMS(d) ((WINE_HID_ELEMENT*)((BYTE*)(d) + (d)->elementOffset))
#endif /* __WINE_PARSE_H */
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