Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
usb_hid.h File Reference

USB HID Class device API header. More...

#include <usb/class/hid.h>

Go to the source code of this file.

Data Structures

struct  hid_ops
 USB HID device interface. More...
 

Macros

#define HID_CLASS_DESCRIPTOR_HID   __DEPRECATED_MACRO USB_DESC_HID
 
#define HID_CLASS_DESCRIPTOR_REPORT   __DEPRECATED_MACRO USB_DESC_HID_REPORT
 
#define HID_GET_REPORT   __DEPRECATED_MACRO USB_HID_GET_REPORT
 
#define HID_GET_IDLE   __DEPRECATED_MACRO USB_HID_GET_IDLE
 
#define HID_GET_PROTOCOL   __DEPRECATED_MACRO USB_HID_GET_PROTOCOL
 
#define HID_SET_REPORT   __DEPRECATED_MACRO USB_HID_SET_REPORT
 
#define HID_SET_IDLE   __DEPRECATED_MACRO USB_HID_SET_IDLE
 
#define HID_SET_PROTOCOL   __DEPRECATED_MACRO USB_HID_SET_PROTOCOL
 
#define ITEM_MAIN   __DEPRECATED_MACRO 0x0
 
#define ITEM_GLOBAL   __DEPRECATED_MACRO 0x1
 
#define ITEM_LOCAL   __DEPRECATED_MACRO 0x2
 
#define ITEM_TAG_INPUT   __DEPRECATED_MACRO 0x8
 
#define ITEM_TAG_OUTPUT   __DEPRECATED_MACRO 0x9
 
#define ITEM_TAG_COLLECTION   __DEPRECATED_MACRO 0xA
 
#define ITEM_TAG_COLLECTION_END   __DEPRECATED_MACRO 0xC
 
#define ITEM_TAG_USAGE_PAGE   __DEPRECATED_MACRO 0x0
 
#define ITEM_TAG_LOGICAL_MIN   __DEPRECATED_MACRO 0x1
 
#define ITEM_TAG_LOGICAL_MAX   __DEPRECATED_MACRO 0x2
 
#define ITEM_TAG_REPORT_SIZE   __DEPRECATED_MACRO 0x7
 
#define ITEM_TAG_REPORT_ID   __DEPRECATED_MACRO 0x8
 
#define ITEM_TAG_REPORT_COUNT   __DEPRECATED_MACRO 0x9
 
#define ITEM_TAG_USAGE   __DEPRECATED_MACRO 0x0
 
#define ITEM_TAG_USAGE_MIN   __DEPRECATED_MACRO 0x1
 
#define ITEM_TAG_USAGE_MAX   __DEPRECATED_MACRO 0x2
 
#define HID_MAIN_ITEM(bTag, bSize)    __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_MAIN, bSize)
 
#define HID_GLOBAL_ITEM(bTag, bSize)    __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_GLOBAL, bSize)
 
#define HID_LOCAL_ITEM(bTag, bSize)    __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_LOCAL, bSize)
 
#define HID_MI_COLLECTION    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_COLLECTION, 1)
 
#define HID_MI_COLLECTION_END    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_COLLECTION_END, 0)
 
#define HID_MI_INPUT    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_INPUT, 1)
 
#define HID_MI_OUTPUT    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_OUTPUT, 1)
 
#define HID_GI_USAGE_PAGE    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_USAGE_PAGE, 1)
 
#define HID_GI_LOGICAL_MIN(size)    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_LOGICAL_MIN, size)
 
#define HID_GI_LOGICAL_MAX(size)    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_LOGICAL_MAX, size)
 
#define HID_GI_REPORT_SIZE    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_SIZE, 1)
 
#define HID_GI_REPORT_ID    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_ID, 1)
 
#define HID_GI_REPORT_COUNT    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_COUNT, 1)
 
#define HID_LI_USAGE    __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE, 1)
 
#define HID_LI_USAGE_MIN(size)    __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE_MIN, size)
 
#define HID_LI_USAGE_MAX(size)    __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE_MAX, size)
 
#define USAGE_GEN_DESKTOP   __DEPRECATED_MACRO 0x01
 
#define USAGE_GEN_KEYBOARD   __DEPRECATED_MACRO 0x07
 
#define USAGE_GEN_LEDS   __DEPRECATED_MACRO 0x08
 
#define USAGE_GEN_BUTTON   __DEPRECATED_MACRO 0x09
 
#define USAGE_GEN_DESKTOP_UNDEFINED   __DEPRECATED_MACRO 0x00
 
#define USAGE_GEN_DESKTOP_POINTER   __DEPRECATED_MACRO 0x01
 
#define USAGE_GEN_DESKTOP_MOUSE   __DEPRECATED_MACRO 0x02
 
#define USAGE_GEN_DESKTOP_JOYSTICK   __DEPRECATED_MACRO 0x04
 
#define USAGE_GEN_DESKTOP_GAMEPAD   __DEPRECATED_MACRO 0x05
 
#define USAGE_GEN_DESKTOP_KEYBOARD   __DEPRECATED_MACRO 0x06
 
#define USAGE_GEN_DESKTOP_KEYPAD   __DEPRECATED_MACRO 0x07
 
#define USAGE_GEN_DESKTOP_X   __DEPRECATED_MACRO 0x30
 
#define USAGE_GEN_DESKTOP_Y   __DEPRECATED_MACRO 0x31
 
#define USAGE_GEN_DESKTOP_WHEEL   __DEPRECATED_MACRO 0x38
 
#define COLLECTION_PHYSICAL   __DEPRECATED_MACRO 0x00
 
#define COLLECTION_APPLICATION   __DEPRECATED_MACRO 0x01
 

Typedefs

typedef int(* hid_cb_t) (const struct device *dev, struct usb_setup_packet *setup, int32_t *len, uint8_t **data)
 
typedef void(* hid_int_ready_callback) (const struct device *dev)
 
typedef void(* hid_protocol_cb_t) (const struct device *dev, uint8_t protocol)
 
typedef void(* hid_idle_cb_t) (const struct device *dev, uint16_t report_id)
 

Functions

void usb_hid_register_device (const struct device *dev, const uint8_t *desc, size_t size, const struct hid_ops *op)
 Register HID device. More...
 
int hid_int_ep_write (const struct device *dev, const uint8_t *data, uint32_t data_len, uint32_t *bytes_ret)
 Write to USB HID interrupt endpoint buffer. More...
 
int hid_int_ep_read (const struct device *dev, uint8_t *data, uint32_t max_data_len, uint32_t *ret_bytes)
 Read from USB HID interrupt endpoint buffer. More...
 
int usb_hid_set_proto_code (const struct device *dev, uint8_t proto_code)
 Set USB HID class Protocol Code. More...
 
int usb_hid_init (const struct device *dev)
 Initialize USB HID class support. More...
 

Detailed Description

USB HID Class device API header.

Macro Definition Documentation

◆ COLLECTION_APPLICATION

#define COLLECTION_APPLICATION   __DEPRECATED_MACRO 0x01

◆ COLLECTION_PHYSICAL

#define COLLECTION_PHYSICAL   __DEPRECATED_MACRO 0x00

◆ HID_CLASS_DESCRIPTOR_HID

#define HID_CLASS_DESCRIPTOR_HID   __DEPRECATED_MACRO USB_DESC_HID

◆ HID_CLASS_DESCRIPTOR_REPORT

#define HID_CLASS_DESCRIPTOR_REPORT   __DEPRECATED_MACRO USB_DESC_HID_REPORT

◆ HID_GET_IDLE

#define HID_GET_IDLE   __DEPRECATED_MACRO USB_HID_GET_IDLE

◆ HID_GET_PROTOCOL

#define HID_GET_PROTOCOL   __DEPRECATED_MACRO USB_HID_GET_PROTOCOL

◆ HID_GET_REPORT

#define HID_GET_REPORT   __DEPRECATED_MACRO USB_HID_GET_REPORT

◆ HID_GI_LOGICAL_MAX

#define HID_GI_LOGICAL_MAX (   size)     __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_LOGICAL_MAX, size)

◆ HID_GI_LOGICAL_MIN

#define HID_GI_LOGICAL_MIN (   size)     __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_LOGICAL_MIN, size)

◆ HID_GI_REPORT_COUNT

#define HID_GI_REPORT_COUNT    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_COUNT, 1)

◆ HID_GI_REPORT_ID

#define HID_GI_REPORT_ID    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_ID, 1)

◆ HID_GI_REPORT_SIZE

#define HID_GI_REPORT_SIZE    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_REPORT_SIZE, 1)

◆ HID_GI_USAGE_PAGE

#define HID_GI_USAGE_PAGE    __DEPRECATED_MACRO HID_GLOBAL_ITEM(ITEM_TAG_USAGE_PAGE, 1)

◆ HID_GLOBAL_ITEM

#define HID_GLOBAL_ITEM (   bTag,
  bSize 
)     __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_GLOBAL, bSize)

◆ HID_LI_USAGE

#define HID_LI_USAGE    __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE, 1)

◆ HID_LI_USAGE_MAX

#define HID_LI_USAGE_MAX (   size)     __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE_MAX, size)

◆ HID_LI_USAGE_MIN

#define HID_LI_USAGE_MIN (   size)     __DEPRECATED_MACRO HID_LOCAL_ITEM(ITEM_TAG_USAGE_MIN, size)

◆ HID_LOCAL_ITEM

#define HID_LOCAL_ITEM (   bTag,
  bSize 
)     __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_LOCAL, bSize)

◆ HID_MAIN_ITEM

#define HID_MAIN_ITEM (   bTag,
  bSize 
)     __DEPRECATED_MACRO HID_ITEM(bTag, ITEM_MAIN, bSize)

◆ HID_MI_COLLECTION

#define HID_MI_COLLECTION    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_COLLECTION, 1)

◆ HID_MI_COLLECTION_END

#define HID_MI_COLLECTION_END    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_COLLECTION_END, 0)

◆ HID_MI_INPUT

#define HID_MI_INPUT    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_INPUT, 1)

◆ HID_MI_OUTPUT

#define HID_MI_OUTPUT    __DEPRECATED_MACRO HID_MAIN_ITEM(ITEM_TAG_OUTPUT, 1)

◆ HID_SET_IDLE

#define HID_SET_IDLE   __DEPRECATED_MACRO USB_HID_SET_IDLE

◆ HID_SET_PROTOCOL

#define HID_SET_PROTOCOL   __DEPRECATED_MACRO USB_HID_SET_PROTOCOL

◆ HID_SET_REPORT

#define HID_SET_REPORT   __DEPRECATED_MACRO USB_HID_SET_REPORT

◆ ITEM_GLOBAL

#define ITEM_GLOBAL   __DEPRECATED_MACRO 0x1

◆ ITEM_LOCAL

#define ITEM_LOCAL   __DEPRECATED_MACRO 0x2

◆ ITEM_MAIN

#define ITEM_MAIN   __DEPRECATED_MACRO 0x0

◆ ITEM_TAG_COLLECTION

#define ITEM_TAG_COLLECTION   __DEPRECATED_MACRO 0xA

◆ ITEM_TAG_COLLECTION_END

#define ITEM_TAG_COLLECTION_END   __DEPRECATED_MACRO 0xC

◆ ITEM_TAG_INPUT

#define ITEM_TAG_INPUT   __DEPRECATED_MACRO 0x8

◆ ITEM_TAG_LOGICAL_MAX

#define ITEM_TAG_LOGICAL_MAX   __DEPRECATED_MACRO 0x2

◆ ITEM_TAG_LOGICAL_MIN

#define ITEM_TAG_LOGICAL_MIN   __DEPRECATED_MACRO 0x1

◆ ITEM_TAG_OUTPUT

#define ITEM_TAG_OUTPUT   __DEPRECATED_MACRO 0x9

◆ ITEM_TAG_REPORT_COUNT

#define ITEM_TAG_REPORT_COUNT   __DEPRECATED_MACRO 0x9

◆ ITEM_TAG_REPORT_ID

#define ITEM_TAG_REPORT_ID   __DEPRECATED_MACRO 0x8

◆ ITEM_TAG_REPORT_SIZE

#define ITEM_TAG_REPORT_SIZE   __DEPRECATED_MACRO 0x7

◆ ITEM_TAG_USAGE

#define ITEM_TAG_USAGE   __DEPRECATED_MACRO 0x0

◆ ITEM_TAG_USAGE_MAX

#define ITEM_TAG_USAGE_MAX   __DEPRECATED_MACRO 0x2

◆ ITEM_TAG_USAGE_MIN

#define ITEM_TAG_USAGE_MIN   __DEPRECATED_MACRO 0x1

◆ ITEM_TAG_USAGE_PAGE

#define ITEM_TAG_USAGE_PAGE   __DEPRECATED_MACRO 0x0

◆ USAGE_GEN_BUTTON

#define USAGE_GEN_BUTTON   __DEPRECATED_MACRO 0x09

◆ USAGE_GEN_DESKTOP

#define USAGE_GEN_DESKTOP   __DEPRECATED_MACRO 0x01

◆ USAGE_GEN_DESKTOP_GAMEPAD

#define USAGE_GEN_DESKTOP_GAMEPAD   __DEPRECATED_MACRO 0x05

◆ USAGE_GEN_DESKTOP_JOYSTICK

#define USAGE_GEN_DESKTOP_JOYSTICK   __DEPRECATED_MACRO 0x04

◆ USAGE_GEN_DESKTOP_KEYBOARD

#define USAGE_GEN_DESKTOP_KEYBOARD   __DEPRECATED_MACRO 0x06

◆ USAGE_GEN_DESKTOP_KEYPAD

#define USAGE_GEN_DESKTOP_KEYPAD   __DEPRECATED_MACRO 0x07

◆ USAGE_GEN_DESKTOP_MOUSE

#define USAGE_GEN_DESKTOP_MOUSE   __DEPRECATED_MACRO 0x02

◆ USAGE_GEN_DESKTOP_POINTER

#define USAGE_GEN_DESKTOP_POINTER   __DEPRECATED_MACRO 0x01

◆ USAGE_GEN_DESKTOP_UNDEFINED

#define USAGE_GEN_DESKTOP_UNDEFINED   __DEPRECATED_MACRO 0x00

◆ USAGE_GEN_DESKTOP_WHEEL

#define USAGE_GEN_DESKTOP_WHEEL   __DEPRECATED_MACRO 0x38

◆ USAGE_GEN_DESKTOP_X

#define USAGE_GEN_DESKTOP_X   __DEPRECATED_MACRO 0x30

◆ USAGE_GEN_DESKTOP_Y

#define USAGE_GEN_DESKTOP_Y   __DEPRECATED_MACRO 0x31

◆ USAGE_GEN_KEYBOARD

#define USAGE_GEN_KEYBOARD   __DEPRECATED_MACRO 0x07

◆ USAGE_GEN_LEDS

#define USAGE_GEN_LEDS   __DEPRECATED_MACRO 0x08