Commit 0baabde7 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winebus.sys: Use macros to define HID reports.

parent 36f18607
......@@ -138,58 +138,60 @@ static inline struct platform_private *impl_from_DEVICE_OBJECT(DEVICE_OBJECT *de
return (struct platform_private *)get_platform_private(device);
}
#include "psh_hid_macros.h"
static const BYTE REPORT_AXIS_TAIL[] = {
0x17, 0x00, 0x00, 0x00, 0x00, /* LOGICAL_MINIMUM (0) */
0x27, 0xff, 0xff, 0x00, 0x00, /* LOGICAL_MAXIMUM (65535) */
0x37, 0x00, 0x00, 0x00, 0x00, /* PHYSICAL_MINIMUM (0) */
0x47, 0xff, 0xff, 0x00, 0x00, /* PHYSICAL_MAXIMUM (65535) */
0x75, 0x10, /* REPORT_SIZE (16) */
0x95, 0x00, /* REPORT_COUNT (?) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
LOGICAL_MINIMUM(4, 0x00000000),
LOGICAL_MAXIMUM(4, 0x0000ffff),
PHYSICAL_MINIMUM(4, 0x00000000),
PHYSICAL_MAXIMUM(4, 0x0000ffff),
REPORT_SIZE(1, 16),
REPORT_COUNT(1, /* placeholder */ 0),
INPUT(1, Data|Var|Abs),
};
#define IDX_ABS_AXIS_COUNT 23
#define CONTROLLER_NUM_BUTTONS 11
static const BYTE CONTROLLER_BUTTONS[] = {
0x05, 0x09, /* USAGE_PAGE (Button) */
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
0x29, CONTROLLER_NUM_BUTTONS, /* USAGE_MAXIMUM (Button 11) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x35, 0x00, /* LOGICAL_MINIMUM (0) */
0x45, 0x01, /* LOGICAL_MAXIMUM (1) */
0x95, CONTROLLER_NUM_BUTTONS, /* REPORT_COUNT (11) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON),
USAGE_MINIMUM(1, 1),
USAGE_MAXIMUM(1, CONTROLLER_NUM_BUTTONS),
LOGICAL_MINIMUM(1, 0),
LOGICAL_MAXIMUM(1, 1),
PHYSICAL_MINIMUM(1, 0),
PHYSICAL_MAXIMUM(1, 1),
REPORT_COUNT(1, CONTROLLER_NUM_BUTTONS),
REPORT_SIZE(1, 1),
INPUT(1, Data|Var|Abs),
};
static const BYTE CONTROLLER_AXIS [] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x30, /* USAGE (X) */
0x09, 0x31, /* USAGE (Y) */
0x09, 0x33, /* USAGE (RX) */
0x09, 0x34, /* USAGE (RY) */
0x17, 0x00, 0x00, 0x00, 0x00, /* LOGICAL_MINIMUM (0) */
0x27, 0xff, 0xff, 0x00, 0x00, /* LOGICAL_MAXIMUM (65535) */
0x37, 0x00, 0x00, 0x00, 0x00, /* PHYSICAL_MINIMUM (0) */
0x47, 0xff, 0xff, 0x00, 0x00, /* PHYSICAL_MAXIMUM (65535) */
0x75, 0x10, /* REPORT_SIZE (16) */
0x95, 0x04, /* REPORT_COUNT (4) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC),
USAGE(1, HID_USAGE_GENERIC_X),
USAGE(1, HID_USAGE_GENERIC_Y),
USAGE(1, HID_USAGE_GENERIC_RX),
USAGE(1, HID_USAGE_GENERIC_RY),
LOGICAL_MINIMUM(4, 0x00000000),
LOGICAL_MAXIMUM(4, 0x0000ffff),
PHYSICAL_MINIMUM(4, 0x00000000),
PHYSICAL_MAXIMUM(4, 0x0000ffff),
REPORT_SIZE(1, 16),
REPORT_COUNT(1, 4),
INPUT(1, Data|Var|Abs),
};
static const BYTE CONTROLLER_TRIGGERS [] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x32, /* USAGE (Z) */
0x09, 0x35, /* USAGE (RZ) */
0x16, 0x00, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0xff, 0x7f, /* LOGICAL_MAXIMUM (32767) */
0x36, 0x00, 0x00, /* PHYSICAL_MINIMUM (0) */
0x46, 0xff, 0x7f, /* PHYSICAL_MAXIMUM (32767) */
0x75, 0x10, /* REPORT_SIZE (16) */
0x95, 0x02, /* REPORT_COUNT (2) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC),
USAGE(1, HID_USAGE_GENERIC_Z),
USAGE(1, HID_USAGE_GENERIC_RZ),
LOGICAL_MINIMUM(2, 0x0000),
LOGICAL_MAXIMUM(2, 0x7fff),
PHYSICAL_MINIMUM(2, 0x0000),
PHYSICAL_MAXIMUM(2, 0x7fff),
REPORT_SIZE(1, 16),
REPORT_COUNT(1, 2),
INPUT(1, Data|Var|Abs),
};
#define CONTROLLER_NUM_AXES 6
......@@ -197,26 +199,28 @@ static const BYTE CONTROLLER_TRIGGERS [] = {
#define CONTROLLER_NUM_HATSWITCHES 1
static const BYTE HAPTIC_RUMBLE[] = {
0x06, 0x00, 0xff, /* USAGE PAGE (vendor-defined) */
0x09, 0x01, /* USAGE (1) */
USAGE_PAGE(2, HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN),
USAGE(1, 0x01),
/* padding */
0x95, 0x02, /* REPORT_COUNT (2) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
REPORT_COUNT(1, 0x02),
REPORT_SIZE(1, 0x08),
OUTPUT(1, Data|Var|Abs),
/* actuators */
0x15, 0x00, /* LOGICAL MINIMUM (0) */
0x25, 0xff, /* LOGICAL MAXIMUM (255) */
0x35, 0x00, /* PHYSICAL MINIMUM (0) */
0x45, 0xff, /* PHYSICAL MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x02, /* REPORT_COUNT (2) */
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
LOGICAL_MINIMUM(1, 0x00),
LOGICAL_MAXIMUM(1, 0xff),
PHYSICAL_MINIMUM(1, 0x00),
PHYSICAL_MAXIMUM(1, 0xff),
REPORT_SIZE(1, 0x08),
REPORT_COUNT(1, 0x02),
OUTPUT(1, Data|Var|Abs),
/* padding */
0x95, 0x02, /* REPORT_COUNT (3) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
REPORT_COUNT(1, 0x02),
REPORT_SIZE(1, 0x08),
OUTPUT(1, Data|Var|Abs),
};
#include "pop_hid_macros.h"
static BYTE *add_axis_block(BYTE *report_ptr, BYTE count, BYTE page, const BYTE *usages, BOOL absolute)
{
int i;
......
......@@ -114,14 +114,16 @@ static inline struct platform_private *impl_from_DEVICE_OBJECT(DEVICE_OBJECT *de
#ifdef HAS_PROPER_INPUT_HEADER
#include "psh_hid_macros.h"
static const BYTE REPORT_ABS_AXIS_TAIL[] = {
0x17, 0x00, 0x00, 0x00, 0x00, /* LOGICAL_MINIMUM (0) */
0x27, 0xff, 0x00, 0x00, 0x00, /* LOGICAL_MAXIMUM (0xff) */
0x37, 0x00, 0x00, 0x00, 0x00, /* PHYSICAL_MINIMUM (0) */
0x47, 0xff, 0x00, 0x00, 0x00, /* PHYSICAL_MAXIMUM (256) */
0x75, 0x20, /* REPORT_SIZE (32) */
0x95, 0x00, /* REPORT_COUNT (2) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
LOGICAL_MINIMUM(4, /* placeholder */ 0x00000000),
LOGICAL_MAXIMUM(4, /* placeholder */ 0x000000ff),
PHYSICAL_MINIMUM(4, /* placeholder */ 0x00000000),
PHYSICAL_MAXIMUM(4, /* placeholder */ 0x000000ff),
REPORT_SIZE(1, 32),
REPORT_COUNT(1, /* placeholder */ 0),
INPUT(1, Data|Var|Abs),
};
#define IDX_ABS_LOG_MINIMUM 1
#define IDX_ABS_LOG_MAXIMUM 6
......@@ -129,6 +131,8 @@ static const BYTE REPORT_ABS_AXIS_TAIL[] = {
#define IDX_ABS_PHY_MAXIMUM 16
#define IDX_ABS_AXIS_COUNT 23
#include "pop_hid_macros.h"
static const BYTE ABS_TO_HID_MAP[][2] = {
{HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_X}, /*ABS_X*/
{HID_USAGE_PAGE_GENERIC, HID_USAGE_GENERIC_Y}, /*ABS_Y*/
......
......@@ -20,76 +20,80 @@
/* Blocks of data for building HID device descriptions */
#include "psh_hid_macros.h"
static const BYTE REPORT_HEADER[] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x00, /* USAGE (??) */
0xa1, 0x01, /* COLLECTION (Application) */
0x09, 0x01, /* USAGE () */
0xa1, 0x00, /* COLLECTION (Physical) */
USAGE_PAGE(1, /* placeholder */ HID_USAGE_PAGE_GENERIC),
USAGE(1, 0),
COLLECTION(1, Application),
USAGE(1, /* placeholder */ HID_USAGE_GENERIC_POINTER),
COLLECTION(1, Physical),
};
#define IDX_HEADER_PAGE 1
#define IDX_HEADER_USAGE 3
static const BYTE REPORT_BUTTONS[] = {
0x05, 0x09, /* USAGE_PAGE (Button) */
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x35, 0x00, /* PHYSICAL_MINIMUM (0) */
0x45, 0x01, /* PHYSICAL_MAXIMUM (1) */
0x95, 0x03, /* REPORT_COUNT (3) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
USAGE_PAGE(1, HID_USAGE_PAGE_BUTTON),
USAGE_MINIMUM(1, /* placeholder */ 1),
USAGE_MAXIMUM(1, /* placeholder */ 3),
LOGICAL_MINIMUM(1, 0),
LOGICAL_MAXIMUM(1, 1),
PHYSICAL_MINIMUM(1, 0),
PHYSICAL_MAXIMUM(1, 1),
REPORT_COUNT(1, /* placeholder */ 3),
REPORT_SIZE(1, 1),
INPUT(1, Data|Var|Abs),
};
#define IDX_BUTTON_MIN_USAGE 3
#define IDX_BUTTON_MAX_USAGE 5
#define IDX_BUTTON_COUNT 15
static const BYTE REPORT_PADDING[] = {
0x95, 0x03, /* REPORT_COUNT (3) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
REPORT_COUNT(1, /* placeholder */ 3),
REPORT_SIZE(1, 1),
INPUT(1, Cnst|Var|Abs),
};
#define IDX_PADDING_BIT_COUNT 1
static const BYTE REPORT_AXIS_HEADER[] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
USAGE_PAGE(1, /* placeholder */ HID_USAGE_PAGE_GENERIC),
};
#define IDX_AXIS_PAGE 1
static const BYTE REPORT_AXIS_USAGE[] = {
0x09, 0x30, /* USAGE (X) */
USAGE(1, /* placeholder */ HID_USAGE_GENERIC_X),
};
#define IDX_AXIS_USAGE 1
static const BYTE REPORT_REL_AXIS_TAIL[] = {
0x15, 0x81, /* LOGICAL_MINIMUM (0) */
0x25, 0x7f, /* LOGICAL_MAXIMUM (0xffff) */
0x75, 0x08, /* REPORT_SIZE (16) */
0x95, 0x02, /* REPORT_COUNT (2) */
0x81, 0x06, /* INPUT (Data,Var,Rel) */
LOGICAL_MINIMUM(1, 0x81),
LOGICAL_MAXIMUM(1, 0x7f),
REPORT_SIZE(1, 8),
REPORT_COUNT(1, /* placeholder */ 2),
INPUT(1, Data|Var|Rel),
};
#define IDX_REL_AXIS_COUNT 7
static const BYTE REPORT_HATSWITCH[] = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x39, /* USAGE (Hatswitch) */
0x15, 0x01, /* LOGICAL_MINIMUM (1) */
0x25, 0x08, /* LOGICAL_MAXIMUM (0x08) */
0x35, 0x00, /* PHYSICAL_MINIMUM (0) */
0x45, 0x08, /* PHYSICAL_MAXIMUM (8) */
0x75, 0x04, /* REPORT_SIZE (4) */
0x95, 0x01, /* REPORT_COUNT (1) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC),
USAGE(1, HID_USAGE_GENERIC_HATSWITCH),
LOGICAL_MINIMUM(1, 1),
LOGICAL_MAXIMUM(1, 8),
PHYSICAL_MINIMUM(1, 0),
PHYSICAL_MAXIMUM(1, 8),
REPORT_SIZE(1, 4),
REPORT_COUNT(1, /* placeholder */ 1),
INPUT(1, Data|Var|Abs),
};
#define IDX_HATSWITCH_COUNT 15
static const BYTE REPORT_TAIL[] = {
0xc0, /* END_COLLECTION */
0xc0 /* END_COLLECTION */
END_COLLECTION,
END_COLLECTION,
};
#include "pop_hid_macros.h"
static inline BYTE *add_button_block(BYTE* report_ptr, BYTE usage_min, BYTE usage_max)
{
memcpy(report_ptr, REPORT_BUTTONS, sizeof(REPORT_BUTTONS));
......
/*
* HID report helper macros.
*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#undef Data
#undef Cnst
#undef Array
#undef Var
#undef Abs
#undef Rel
#undef NoWrap
#undef Wrap
#undef NonLin
#undef Lin
#undef NoPref
#undef Pref
#undef NoNull
#undef Null
#undef NonVol
#undef Vol
#undef Bits
#undef Buff
#undef Physical
#undef Application
#undef Logical
#undef Report
#undef NamedArray
#undef UsageSwitch
#undef UsageModifier
#undef SHORT_ITEM_0
#undef SHORT_ITEM_1
#undef SHORT_ITEM_2
#undef SHORT_ITEM_4
#undef LONG_ITEM
#undef INPUT
#undef OUTPUT
#undef FEATURE
#undef COLLECTION
#undef END_COLLECTION
#undef USAGE_PAGE
#undef LOGICAL_MINIMUM
#undef LOGICAL_MAXIMUM
#undef PHYSICAL_MINIMUM
#undef PHYSICAL_MAXIMUM
#undef UNIT_EXPONENT
#undef UNIT
#undef REPORT_SIZE
#undef REPORT_ID
#undef REPORT_COUNT
#undef PUSH
#undef POP
#undef USAGE
#undef USAGE_MINIMUM
#undef USAGE_MAXIMUM
#undef DESIGNATOR_INDEX
#undef DESIGNATOR_MINIMUM
#undef DESIGNATOR_MAXIMUM
#undef STRING_INDEX
#undef STRING_MINIMUM
#undef STRING_MAXIMUM
#undef DELIMITER
/*
* HID report helper macros.
*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <hidusage.h>
#define Data 0
#define Cnst 0x01
#define Ary 0
#define Var 0x02
#define Abs 0
#define Rel 0x04
#define NoWrap 0
#define Wrap 0x08
#define NonLin 0
#define Lin 0x10
#define NoPref 0
#define Pref 0x20
#define NoNull 0
#define Null 0x40
#define NonVol 0
#define Vol 0x80
#define Bits 0
#define Buff 0x100
#define Physical 0x00
#define Application 0x01
#define Logical 0x02
#define Report 0x03
#define NamedArray 0x04
#define UsageSwitch 0x05
#define UsageModifier 0x06
#define SHORT_ITEM_0(tag,type) (((tag)<<4)|((type)<<2)|0)
#define SHORT_ITEM_1(tag,type,data) (((tag)<<4)|((type)<<2)|1),((data)&0xff)
#define SHORT_ITEM_2(tag,type,data) (((tag)<<4)|((type)<<2)|2),((data)&0xff),(((data)>>8)&0xff)
#define SHORT_ITEM_4(tag,type,data) (((tag)<<4)|((type)<<2)|3),((data)&0xff),(((data)>>8)&0xff),(((data)>>16)&0xff),(((data)>>24)&0xff)
#define LONG_ITEM(tag,size) SHORT_ITEM_2(0xf,0x3,((tag)<<8)|(size))
#define INPUT(n,data) SHORT_ITEM_##n(0x8,0,data)
#define OUTPUT(n,data) SHORT_ITEM_##n(0x9,0,data)
#define FEATURE(n,data) SHORT_ITEM_##n(0xb,0,data)
#define COLLECTION(n,data) SHORT_ITEM_##n(0xa,0,data)
#define END_COLLECTION SHORT_ITEM_0(0xc,0)
#define USAGE_PAGE(n,data) SHORT_ITEM_##n(0x0,1,data)
#define LOGICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x1,1,data)
#define LOGICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,1,data)
#define PHYSICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x3,1,data)
#define PHYSICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x4,1,data)
#define UNIT_EXPONENT(n,data) SHORT_ITEM_##n(0x5,1,data)
#define UNIT(n,data) SHORT_ITEM_##n(0x6,1,data)
#define REPORT_SIZE(n,data) SHORT_ITEM_##n(0x7,1,data)
#define REPORT_ID(n,data) SHORT_ITEM_##n(0x8,1,data)
#define REPORT_COUNT(n,data) SHORT_ITEM_##n(0x9,1,data)
#define PUSH(n,data) SHORT_ITEM_##n(0xa,1,data)
#define POP(n,data) SHORT_ITEM_##n(0xb,1,data)
#define USAGE(n,data) SHORT_ITEM_##n(0x0,2,data)
#define USAGE_MINIMUM(n,data) SHORT_ITEM_##n(0x1,2,data)
#define USAGE_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,2,data)
#define DESIGNATOR_INDEX(n,data) SHORT_ITEM_##n(0x3,2,data)
#define DESIGNATOR_MINIMUM(n,data) SHORT_ITEM_##n(0x4,2,data)
#define DESIGNATOR_MAXIMUM(n,data) SHORT_ITEM_##n(0x5,2,data)
#define STRING_INDEX(n,data) SHORT_ITEM_##n(0x6,2,data)
#define STRING_MINIMUM(n,data) SHORT_ITEM_##n(0x7,2,data)
#define STRING_MAXIMUM(n,data) SHORT_ITEM_##n(0x8,2,data)
#define DELIMITER(n,data) SHORT_ITEM_##n(0x9,2,data)
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