6
6
7
7
const size_t kNumAxes = 4 ;
8
8
using AxesValueType = int16_t ;
9
- const AxesValueType kAxesMin = -32768 ;
10
- const AxesValueType kAxesMax = 32767 ;
9
+ #define AXIS_BITS 10
10
+ const AxesValueType kAxesMin = (-1 << (AXIS_BITS - 1 ));
11
+ const AxesValueType kAxesMax = -kAxesMin - 1 ;
11
12
12
13
const size_t kNumButtonGroups = 3 ;
13
14
@@ -19,6 +20,10 @@ struct ReportData {
19
20
20
21
using namespace usb ::hid;
21
22
23
+ constexpr uint8_t GetByte (int16_t x, uint8_t b) {
24
+ return (x >> (b << 3 ));
25
+ }
26
+
22
27
const u8 kReportId = 1 ;
23
28
static const u8 sHidDescriptorData [] PROGMEM = {
24
29
Global::UsagePage | 1 , usage::Page::GenericDesktop,
@@ -34,9 +39,14 @@ static const u8 sHidDescriptorData[] PROGMEM = {
34
39
Local::Usage | 1 , usage::generic_desktop::Axis::Y,
35
40
Local::Usage | 1 , usage::generic_desktop::Axis::Rz,
36
41
Local::Usage | 1 , usage::generic_desktop::Axis::Z,
37
- Global::LogicalMinimum | 2 , 0x00 , 0x80 , // kAxesMin = -32768
38
- Global::LogicalMaximum | 2 , 0xFF , 0x7F , // kAxesMax = 32767
39
- Global::ReportSize | 1 , 16 ,
42
+ #if AXIS_BITS > 8
43
+ Global::LogicalMinimum | 2 , GetByte (kAxesMin , 0 ), GetByte (kAxesMin , 1 ),
44
+ Global::LogicalMaximum | 2 , GetByte (kAxesMax , 0 ), GetByte (kAxesMax , 1 ),
45
+ #else // AXIS_BITS <= 8
46
+ Global::LogicalMinimum | 1 , kAxesMin ,
47
+ Global::LogicalMaximum | 1 , kAxesMax ,
48
+ #endif
49
+ Global::ReportSize | 1 , sizeof (AxesValueType) * 8 ,
40
50
Global::ReportCount | 1 , 4 ,
41
51
Main::Input | 1 , DataBits::Variable,
42
52
Main::EndCollection | 0 ,
0 commit comments