Loading...
Searching...
No Matches
USB HID descriptor helpers

USB HID descriptor format helpers. More...

Detailed Description

USB HID descriptor format helpers.

Macros

#define USB_HID_ITEM_TYPE_MAIN   0x0
 HID Main item type.
 
#define USB_HID_ITEM_TYPE_GLOBAL   0x1
 HID Global item type.
 
#define USB_HID_ITEM_TYPE_LOCAL   0x2
 HID Local item type.
 
#define USB_HID_ITEM_TAG_INPUT   0x8
 HID Input item tag.
 
#define USB_HID_ITEM_TAG_OUTPUT   0x9
 HID Output item tag.
 
#define USB_HID_ITEM_TAG_COLLECTION   0xA
 HID Collection item tag.
 
#define USB_HID_ITEM_TAG_FEATURE   0xB
 HID Feature item tag.
 
#define USB_HID_ITEM_TAG_COLLECTION_END   0xC
 HID End Collection item tag.
 
#define USB_HID_ITEM_TAG_USAGE_PAGE   0x0
 HID Usage Page item tag.
 
#define USB_HID_ITEM_TAG_LOGICAL_MIN   0x1
 HID Logical Minimum item tag.
 
#define USB_HID_ITEM_TAG_LOGICAL_MAX   0x2
 HID Logical Maximum item tag.
 
#define USB_HID_ITEM_TAG_PHYSICAL_MIN   0x3
 HID Physical Minimum item tag.
 
#define USB_HID_ITEM_TAG_PHYSICAL_MAX   0x4
 HID Physical Maximum item tag.
 
#define USB_HID_ITEM_TAG_UNIT_EXPONENT   0x5
 HID Unit Exponent item tag.
 
#define USB_HID_ITEM_TAG_UNIT   0x6
 HID Unit item tag.
 
#define USB_HID_ITEM_TAG_REPORT_SIZE   0x7
 HID Report Size item tag.
 
#define USB_HID_ITEM_TAG_REPORT_ID   0x8
 HID Report ID item tag.
 
#define USB_HID_ITEM_TAG_REPORT_COUNT   0x9
 HID Report count item tag.
 
#define USB_HID_ITEM_TAG_USAGE   0x0
 HID Usage item tag.
 
#define USB_HID_ITEM_TAG_USAGE_MIN   0x1
 HID Usage Minimum item tag.
 
#define USB_HID_ITEM_TAG_USAGE_MAX   0x2
 HID Usage Maximum item tag.
 
#define USB_HID_COLLECTION_PHYSICAL   0x00
 Physical collection type.
 
#define USB_HID_COLLECTION_APPLICATION   0x01
 Application collection type.
 
#define USB_HID_COLLECTION_LOGICAL   0x02
 Logical (interrelated data) collection type.
 
#define USB_HID_COLLECTION_REPORT   0x03
 Report collection type.
 
#define USB_HID_COLLECTION_NAMED_ARRAY   0x04
 Named array collection type.
 
#define USB_HID_COLLECTION_USAGE_SWITCH   0x05
 Usage switch collection type.
 
#define USB_HID_COLLECTION_USAGE_MOD   0x06
 Modifier switch collection type.
 
#define USB_HID_ITEM(tag, type, size)    (((tag & 0xF) << 4) | ((type & 0x3) << 2) | (size & 0x3))
 Defines a HID descriptor short item.
 
#define USB_HID_INPUT(input)
 Defines a HID descriptor input item.
 
#define USB_HID_OUTPUT(output)
 Defines a HID descriptor output item.
 
#define USB_HID_FEATURE(feature)
 Defines a HID Feature item.
 
#define USB_HID_COLLECTION(collection)
 Defines a HID Collection item.
 
#define USB_HID_END_COLLECTION    USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION_END, USB_HID_ITEM_TYPE_MAIN, 0)
 Defines a HID End Collection item.
 
#define USB_HID_USAGE_PAGE(page)
 Defines a HID Usage Page item.
 
#define USB_HID_USAGE_PAGE16(page)
 Defines a HID Usage Page item.
 
#define USB_HID_LOGICAL_MIN8(minimum)
 Defines a HID Logical Minimum item.
 
#define USB_HID_LOGICAL_MIN16(minimum)
 Defines a HID Logical Minimum item.
 
#define USB_HID_LOGICAL_MIN32(minimum)
 Defines a HID Logical Minimum item.
 
#define USB_HID_LOGICAL_MAX8(maximum)
 Defines a HID Logical Maximum item.
 
#define USB_HID_LOGICAL_MAX16(maximum)
 Defines a HID Logical Maximum item.
 
#define USB_HID_LOGICAL_MAX32(maximum)
 Defines a HID Logical Maximum item.
 
#define USB_HID_REPORT_SIZE(size)
 Defines a HID Report Size item.
 
#define USB_HID_REPORT_ID(id)
 Defines a HID Report ID item.
 
#define USB_HID_REPORT_COUNT(count)
 Define HID Report Count item.
 
#define USB_HID_USAGE(index)
 Defines a HID Usage Index item.
 
#define USB_HID_USAGE_MIN8(start)
 Defines a HID Usage Minimum item.
 
#define USB_HID_USAGE_MIN16(start)
 Define HID Usage Minimum item with the data length of two bytes.
 
#define USB_HID_USAGE_MAX8(end)
 Defines HID Usage Maximum item.
 
#define USB_HID_USAGE_MAX16(end)
 Defines HID Usage Maximum item.
 

Macro Definition Documentation

◆ USB_HID_COLLECTION

#define USB_HID_COLLECTION (   collection)
Value:
collection
#define USB_HID_ITEM(tag, type, size)
Defines a HID descriptor short item.
Definition hid.h:273
#define USB_HID_ITEM_TAG_COLLECTION
HID Collection item tag.
Definition hid.h:155
#define USB_HID_ITEM_TYPE_MAIN
HID Main item type.
Definition hid.h:130

Defines a HID Collection item.

Note
data length is one byte.
Parameters
collectionCollection item data

Definition at line 317 of file hid.h.

◆ USB_HID_COLLECTION_APPLICATION

#define USB_HID_COLLECTION_APPLICATION   0x01

Application collection type.

Definition at line 239 of file hid.h.

◆ USB_HID_COLLECTION_LOGICAL

#define USB_HID_COLLECTION_LOGICAL   0x02

Logical (interrelated data) collection type.

Definition at line 244 of file hid.h.

◆ USB_HID_COLLECTION_NAMED_ARRAY

#define USB_HID_COLLECTION_NAMED_ARRAY   0x04

Named array collection type.

Definition at line 254 of file hid.h.

◆ USB_HID_COLLECTION_PHYSICAL

#define USB_HID_COLLECTION_PHYSICAL   0x00

Physical collection type.

Definition at line 234 of file hid.h.

◆ USB_HID_COLLECTION_REPORT

#define USB_HID_COLLECTION_REPORT   0x03

Report collection type.

Definition at line 249 of file hid.h.

◆ USB_HID_COLLECTION_USAGE_MOD

#define USB_HID_COLLECTION_USAGE_MOD   0x06

Modifier switch collection type.

Definition at line 264 of file hid.h.

◆ USB_HID_COLLECTION_USAGE_SWITCH

#define USB_HID_COLLECTION_USAGE_SWITCH   0x05

Usage switch collection type.

Definition at line 259 of file hid.h.

◆ USB_HID_END_COLLECTION

#define USB_HID_END_COLLECTION    USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION_END, USB_HID_ITEM_TYPE_MAIN, 0)

Defines a HID End Collection item.

Definition at line 324 of file hid.h.

◆ USB_HID_FEATURE

#define USB_HID_FEATURE (   feature)
Value:
feature
#define USB_HID_ITEM_TAG_FEATURE
HID Feature item tag.
Definition hid.h:160

Defines a HID Feature item.

Note
data length is one byte.
Parameters
featureFeature item data

Definition at line 306 of file hid.h.

◆ USB_HID_INPUT

#define USB_HID_INPUT (   input)
Value:
input
#define USB_HID_ITEM_TAG_INPUT
HID Input item tag.
Definition hid.h:145

Defines a HID descriptor input item.

Note
data length is one byte
Parameters
inputInput item flags

Definition at line 283 of file hid.h.

◆ USB_HID_ITEM

#define USB_HID_ITEM (   tag,
  type,
  size 
)     (((tag & 0xF) << 4) | ((type & 0x3) << 2) | (size & 0x3))

Defines a HID descriptor short item.

Parameters
tagItem tag
typeItem type
sizeItem data size

Definition at line 273 of file hid.h.

◆ USB_HID_ITEM_TAG_COLLECTION

#define USB_HID_ITEM_TAG_COLLECTION   0xA

HID Collection item tag.

Definition at line 155 of file hid.h.

◆ USB_HID_ITEM_TAG_COLLECTION_END

#define USB_HID_ITEM_TAG_COLLECTION_END   0xC

HID End Collection item tag.

Definition at line 165 of file hid.h.

◆ USB_HID_ITEM_TAG_FEATURE

#define USB_HID_ITEM_TAG_FEATURE   0xB

HID Feature item tag.

Definition at line 160 of file hid.h.

◆ USB_HID_ITEM_TAG_INPUT

#define USB_HID_ITEM_TAG_INPUT   0x8

HID Input item tag.

Definition at line 145 of file hid.h.

◆ USB_HID_ITEM_TAG_LOGICAL_MAX

#define USB_HID_ITEM_TAG_LOGICAL_MAX   0x2

HID Logical Maximum item tag.

Definition at line 179 of file hid.h.

◆ USB_HID_ITEM_TAG_LOGICAL_MIN

#define USB_HID_ITEM_TAG_LOGICAL_MIN   0x1

HID Logical Minimum item tag.

Definition at line 174 of file hid.h.

◆ USB_HID_ITEM_TAG_OUTPUT

#define USB_HID_ITEM_TAG_OUTPUT   0x9

HID Output item tag.

Definition at line 150 of file hid.h.

◆ USB_HID_ITEM_TAG_PHYSICAL_MAX

#define USB_HID_ITEM_TAG_PHYSICAL_MAX   0x4

HID Physical Maximum item tag.

Definition at line 189 of file hid.h.

◆ USB_HID_ITEM_TAG_PHYSICAL_MIN

#define USB_HID_ITEM_TAG_PHYSICAL_MIN   0x3

HID Physical Minimum item tag.

Definition at line 184 of file hid.h.

◆ USB_HID_ITEM_TAG_REPORT_COUNT

#define USB_HID_ITEM_TAG_REPORT_COUNT   0x9

HID Report count item tag.

Definition at line 214 of file hid.h.

◆ USB_HID_ITEM_TAG_REPORT_ID

#define USB_HID_ITEM_TAG_REPORT_ID   0x8

HID Report ID item tag.

Definition at line 209 of file hid.h.

◆ USB_HID_ITEM_TAG_REPORT_SIZE

#define USB_HID_ITEM_TAG_REPORT_SIZE   0x7

HID Report Size item tag.

Definition at line 204 of file hid.h.

◆ USB_HID_ITEM_TAG_UNIT

#define USB_HID_ITEM_TAG_UNIT   0x6

HID Unit item tag.

Definition at line 199 of file hid.h.

◆ USB_HID_ITEM_TAG_UNIT_EXPONENT

#define USB_HID_ITEM_TAG_UNIT_EXPONENT   0x5

HID Unit Exponent item tag.

Definition at line 194 of file hid.h.

◆ USB_HID_ITEM_TAG_USAGE

#define USB_HID_ITEM_TAG_USAGE   0x0

HID Usage item tag.

Definition at line 219 of file hid.h.

◆ USB_HID_ITEM_TAG_USAGE_MAX

#define USB_HID_ITEM_TAG_USAGE_MAX   0x2

HID Usage Maximum item tag.

Definition at line 229 of file hid.h.

◆ USB_HID_ITEM_TAG_USAGE_MIN

#define USB_HID_ITEM_TAG_USAGE_MIN   0x1

HID Usage Minimum item tag.

Definition at line 224 of file hid.h.

◆ USB_HID_ITEM_TAG_USAGE_PAGE

#define USB_HID_ITEM_TAG_USAGE_PAGE   0x0

HID Usage Page item tag.

Definition at line 170 of file hid.h.

◆ USB_HID_ITEM_TYPE_GLOBAL

#define USB_HID_ITEM_TYPE_GLOBAL   0x1

HID Global item type.

Definition at line 135 of file hid.h.

◆ USB_HID_ITEM_TYPE_LOCAL

#define USB_HID_ITEM_TYPE_LOCAL   0x2

HID Local item type.

Definition at line 140 of file hid.h.

◆ USB_HID_ITEM_TYPE_MAIN

#define USB_HID_ITEM_TYPE_MAIN   0x0

HID Main item type.

Definition at line 130 of file hid.h.

◆ USB_HID_LOGICAL_MAX16

#define USB_HID_LOGICAL_MAX16 (   maximum)
Value:
(maximum & 0xff), (maximum >> 8)
#define USB_HID_ITEM_TAG_LOGICAL_MAX
HID Logical Maximum item tag.
Definition hid.h:179
#define USB_HID_ITEM_TYPE_GLOBAL
HID Global item type.
Definition hid.h:135

Defines a HID Logical Maximum item.

Note
data length is two bytes.
Parameters
maximumMaximum value in logical units

Definition at line 404 of file hid.h.

◆ USB_HID_LOGICAL_MAX32

#define USB_HID_LOGICAL_MAX32 (   maximum)
Value:
maximum & 0xff, \
(maximum >> 8) & 0xff, \
(maximum >> 16) & 0xff, \
(maximum >> 24) & 0xff

Defines a HID Logical Maximum item.

Note
data length is four bytes.
Parameters
maximumMaximum value in logical units

Definition at line 415 of file hid.h.

◆ USB_HID_LOGICAL_MAX8

#define USB_HID_LOGICAL_MAX8 (   maximum)
Value:

Defines a HID Logical Maximum item.

Note
data length is one byte.
Parameters
maximumMaximum value in logical units

Definition at line 393 of file hid.h.

◆ USB_HID_LOGICAL_MIN16

#define USB_HID_LOGICAL_MIN16 (   minimum)
Value:
minimum & 0xff, (minimum >> 8)
#define USB_HID_ITEM_TAG_LOGICAL_MIN
HID Logical Minimum item tag.
Definition hid.h:174

Defines a HID Logical Minimum item.

Note
data length is two bytes.
Parameters
minimumMinimum value in logical units

Definition at line 367 of file hid.h.

◆ USB_HID_LOGICAL_MIN32

#define USB_HID_LOGICAL_MIN32 (   minimum)
Value:
minimum & 0xff, \
(minimum >> 8) & 0xff, \
(minimum >> 16) & 0xff, \
(minimum >> 24) & 0xff

Defines a HID Logical Minimum item.

Note
data length is four bytes.
Parameters
minimumMinimum value in logical units

Definition at line 379 of file hid.h.

◆ USB_HID_LOGICAL_MIN8

#define USB_HID_LOGICAL_MIN8 (   minimum)
Value:

Defines a HID Logical Minimum item.

Note
data length is one byte.
Parameters
minimumMinimum value in logical units

Definition at line 356 of file hid.h.

◆ USB_HID_OUTPUT

#define USB_HID_OUTPUT (   output)
Value:
output
#define USB_HID_ITEM_TAG_OUTPUT
HID Output item tag.
Definition hid.h:150

Defines a HID descriptor output item.

Note
data length is one byte
Parameters
outputOutput item flags

Definition at line 294 of file hid.h.

◆ USB_HID_REPORT_COUNT

#define USB_HID_REPORT_COUNT (   count)
Value:
count
#define USB_HID_ITEM_TAG_REPORT_COUNT
HID Report count item tag.
Definition hid.h:214

Define HID Report Count item.

Note
data length is one byte.
Parameters
countNumber of data fields included in the report

Definition at line 451 of file hid.h.

◆ USB_HID_REPORT_ID

#define USB_HID_REPORT_ID (   id)
Value:
id
#define USB_HID_ITEM_TAG_REPORT_ID
HID Report ID item tag.
Definition hid.h:209

Defines a HID Report ID item.

Note
data length is one byte.
Parameters
idReport ID

Definition at line 440 of file hid.h.

◆ USB_HID_REPORT_SIZE

#define USB_HID_REPORT_SIZE (   size)
Value:
size
#define USB_HID_ITEM_TAG_REPORT_SIZE
HID Report Size item tag.
Definition hid.h:204

Defines a HID Report Size item.

Note
data length is one byte.
Parameters
sizeReport field size in bits

Definition at line 429 of file hid.h.

◆ USB_HID_USAGE

#define USB_HID_USAGE (   index)
Value:
index
#define USB_HID_ITEM_TAG_USAGE
HID Usage item tag.
Definition hid.h:219
#define USB_HID_ITEM_TYPE_LOCAL
HID Local item type.
Definition hid.h:140

Defines a HID Usage Index item.

Note
data length is one byte.
Parameters
indexNumber of data fields included in the report

Definition at line 462 of file hid.h.

◆ USB_HID_USAGE_MAX16

#define USB_HID_USAGE_MAX16 (   end)
Value:
end & 0xff, (end >> 8) & 0xff
#define USB_HID_ITEM_TAG_USAGE_MAX
HID Usage Maximum item tag.
Definition hid.h:229

Defines HID Usage Maximum item.

Note
data length is one byte.
Parameters
endEnding Usage

Definition at line 506 of file hid.h.

◆ USB_HID_USAGE_MAX8

#define USB_HID_USAGE_MAX8 (   end)
Value:

Defines HID Usage Maximum item.

Note
data length is one byte.
Parameters
endEnding Usage

Definition at line 495 of file hid.h.

◆ USB_HID_USAGE_MIN16

#define USB_HID_USAGE_MIN16 (   start)
Value:
start & 0xff, (start >> 8) & 0xff
#define USB_HID_ITEM_TAG_USAGE_MIN
HID Usage Minimum item tag.
Definition hid.h:224

Define HID Usage Minimum item with the data length of two bytes.

Note
data length is two bytes.
Parameters
startStarting Usage

Definition at line 484 of file hid.h.

◆ USB_HID_USAGE_MIN8

#define USB_HID_USAGE_MIN8 (   start)
Value:

Defines a HID Usage Minimum item.

Note
data length is one byte.
Parameters
startStarting Usage

Definition at line 473 of file hid.h.

◆ USB_HID_USAGE_PAGE

#define USB_HID_USAGE_PAGE (   page)
Value:
page
#define USB_HID_ITEM_TAG_USAGE_PAGE
HID Usage Page item tag.
Definition hid.h:170

Defines a HID Usage Page item.

Note
data length is one byte.
Parameters
pageUsage Page

Definition at line 334 of file hid.h.

◆ USB_HID_USAGE_PAGE16

#define USB_HID_USAGE_PAGE16 (   page)
Value:

Defines a HID Usage Page item.

Note
data length is two bytes.
Parameters
pageUsage page

Definition at line 345 of file hid.h.