Skip to content

Commit 72aeff6

Browse files
committed
hat switch experiments
1 parent 62e49e2 commit 72aeff6

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

examples/phoenix-arduino-joystick/phoenix-arduino-joystick.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ static const u8 sHidDescriptorData[] PROGMEM = {
5151
Global::ReportCount | 1, 24,
5252
Main::Input | 1, DataBits::Variable,
5353

54+
#if 0
55+
/*
56+
* 8 way hat switch
57+
* Reports an angle in 45 degree increments by mapping the values 0-7
58+
* to the angles 0-315 degrees. Report -8 (the most negative value) if
59+
* the hat is in the null position.
60+
*/
61+
Global::UsagePage | 1, usage::Page::GenericDesktop,
62+
Local::Usage | 1, usage::generic_desktop::Miscellaneous::HatSwitch,
63+
Global::LogicalMinimum | 1, 0,
64+
Global::LogicalMaximum | 1, 7,
65+
Global::PhysicalMinimum | 1, 0,
66+
Global::PhysicalMaximum | 2, 0x3b, 0x01, // 0x13b = 315
67+
Global::Unit | 1, 0x14, // Degrees | EnglishRotation
68+
Global::ReportSize | 1, 4,
69+
Global::ReportCount | 1, 1,
70+
Main::Input | 1, DataBits::Variable | DataBits::NullState,
71+
#endif
72+
5473
Main::EndCollection | 0,
5574
};
5675

src/HidDescriptorHelper.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum class Global : u8
2727
UsagePage = 0x0, // See usage::Page for values
2828
LogicalMinimum = 0x1,
2929
LogicalMaximum = 0x2,
30-
PhysicalMinumum = 0x3,
30+
PhysicalMinimum = 0x3,
3131
PhysicalMaximum = 0x4,
3232
UnitExponent = 0x5,
3333
Unit = 0x6,
@@ -115,9 +115,14 @@ constexpr u8 operator | (Local tag, int size)
115115
// Bits used in constructing values of Main::Input, Main::Output, and Main::Feature
116116
enum DataBits
117117
{
118-
Constant = 0x01, // Data if not set
119-
Variable = 0x02, // Array if not set
120-
Relative = 0x04, // Absolute if not set
118+
Constant = 0x01, // Data if not set
119+
Variable = 0x02, // Array if not set
120+
Relative = 0x04, // Absolute if not set
121+
Wrap = 0x08, // NoWrap if not set
122+
NonLinear = 0x10, // Linear if not set
123+
NoPreferred = 0x20, // Has Preferred state if not set
124+
NullState = 0x40, // NoNullPosition if not set
125+
Volatile = 0x80, // NonVolatile if not set
121126
};
122127

123128
// Values of Main::Collection

0 commit comments

Comments
 (0)