nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
hid_report_mouse.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _HID_REPORT_MOUSE_H_
8#define _HID_REPORT_MOUSE_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/* Mouse report uses 5 bytes:
15 * 8 bits - pressed buttons bitmask
16 * 8 bits - wheel rotation
17 * 12 bits - x movement
18 * 12 bits - y movement
19 */
20#define REPORT_SIZE_MOUSE 5 /* Bytes */
21
22/* Mouse boot report uses 3 bytes:
23 * 8 bits - pressed buttons bitmask
24 * 8 bits - x movement
25 * 8 bits - y movement
26 */
27#define REPORT_SIZE_MOUSE_BOOT 3 /* Bytes */
28
29/* Report mask marks which bytes should are absolute and should be stored. */
30#define REPORT_MASK_MOUSE {0x01}
31
32
33#define USAGE_PAGE_MOUSE_XY 0x01
34#define USAGE_PAGE_MOUSE_WHEEL 0x01
35#define USAGE_PAGE_KEYBOARD 0x07
36#define USAGE_PAGE_LEDS 0x08
37#define USAGE_PAGE_MOUSE_BUTTONS 0x09
38
39#define MOUSE_REPORT_WHEEL_MIN (-0x7F)
40#define MOUSE_REPORT_WHEEL_MAX (0x7F)
41#define MOUSE_REPORT_XY_MIN (-0x07ff)
42#define MOUSE_REPORT_XY_MAX (0x07ff)
43#define MOUSE_REPORT_XY_MIN_BOOT (-0x80)
44#define MOUSE_REPORT_XY_MAX_BOOT (0x7f)
45#define MOUSE_REPORT_BUTTON_COUNT_MAX 8
46
47enum {
52};
53
54
55#define REPORT_MAP_MOUSE(report_id) \
56 \
57 /* Report: Mouse */ \
58 0x09, 0x01, /* Usage (Pointer) */ \
59 0xA1, 0x00, /* Collection (Physical) */ \
60 \
61 0x85, report_id, /* Report ID */ \
62 \
63 0x05, USAGE_PAGE_MOUSE_BUTTONS, \
64 0x19, 0x01, /* Usage Minimum (1) */ \
65 0x29, 0x08, /* Usage Maximum (8) */ \
66 0x15, 0x00, /* Logical Minimum (0) */ \
67 0x25, 0x01, /* Logical Maximum (1) */ \
68 0x75, 0x01, /* Report Size (1) */ \
69 0x95, MOUSE_REPORT_BUTTON_COUNT_MAX, /* Report Count */ \
70 0x81, 0x02, /* Input (Data, Variable, Absolute) */ \
71 \
72 0x05, USAGE_PAGE_MOUSE_WHEEL, \
73 0x09, 0x38, /* Usage (Wheel) */ \
74 0x15, 0x81, /* Logical Minimum (-127) */ \
75 0x25, 0x7F, /* Logical Maximum (127) */ \
76 0x75, 0x08, /* Report Size (8) */ \
77 0x95, 0x01, /* Report Count (1) */ \
78 0x81, 0x06, /* Input (Data, Variable, Relative) */ \
79 \
80 0x05, USAGE_PAGE_MOUSE_XY, \
81 0x09, 0x30, /* Usage (X) */ \
82 0x09, 0x31, /* Usage (Y) */ \
83 0x16, 0x01, 0xF8, /* Logical Maximum (2047) */ \
84 0x26, 0xFF, 0x07, /* Logical Minimum (-2047) */ \
85 0x75, 0x0C, /* Report Size (12) */ \
86 0x95, 0x02, /* Report Count (2) */ \
87 0x81, 0x06, /* Input (Data, Variable, Relative) */ \
88 \
89 0xC0 /* End Collection (Physical) */
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* _HID_REPORT_MOUSE_H_ */
@ MOUSE_REPORT_AXIS_X
Definition: hid_report_mouse.h:48
@ MOUSE_REPORT_AXIS_COUNT
Definition: hid_report_mouse.h:51
@ MOUSE_REPORT_AXIS_Y
Definition: hid_report_mouse.h:49
@ MOUSE_REPORT_AXIS_WHEEL
Definition: hid_report_mouse.h:50