Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBJoystick by
Revision 5:767e64df3776, committed 2017-01-18
- Comitter:
- smartsystemdesign
- Date:
- Wed Jan 18 04:54:07 2017 +0000
- Parent:
- 4:0ffbedd2cb73
- Commit message:
- Fixed joystick controls not moving error. Thanks, Wim!
Changed in this revision
| USBJoystick.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBJoystick.cpp Fri Jan 13 17:11:32 2017 +0000
+++ b/USBJoystick.cpp Wed Jan 18 04:54:07 2017 +0000
@@ -45,12 +45,18 @@
HID_REPORT report;
// Fill the report according to the Joystick Descriptor
- report.data[0] = _x & 0xffff;
- report.data[1] = _y & 0xffff;
- report.data[2] = _z & 0xffff;
- report.data[3] = _rx & 0xffff;
- report.data[4] = _ry & 0xffff;
- report.data[5] = _rz & 0xffff;
+ report.data[0] = _x & 0xff;
+ report.data[1] = (_x >> 8) & 0xff;
+ report.data[2] = _y & 0xff;
+ report.data[3] = (_y >> 8) & 0xff;
+ report.data[4] = _z & 0xff;
+ report.data[5] = (_z >> 8) & 0xff;
+ report.data[6] = _rx & 0xff;
+ report.data[7] = (_rx >> 8) & 0xff;
+ report.data[8] = _ry & 0xff;
+ report.data[9] = (_ry >> 8) & 0xff;
+ report.data[10] = _rz & 0xff;
+ report.data[11] = (_rz >> 8) & 0xff;
#if (BUTTONS4 == 1)
//Hat and 4 Buttons
@@ -59,10 +65,10 @@
//Use 4 bit padding for hat4 or hat8
- report.data[6] = (_hat & 0x0f) ;
+ report.data[12] = (_hat & 0x0f) ;
//Use 4 bit padding for buttons
- report.data[7] = (_buttons & 0x0f) ;
+ report.data[13] = (_buttons & 0x0f) ;
report.length = 8;
#endif
@@ -75,23 +81,23 @@
// report.length = 6;
//Use 4 bit padding for hat4 or hat8
- report.data[6] = (_hat & 0x0f) ;
+ report.data[12] = (_hat & 0x0f) ;
//Use 8 bits for buttons
- report.data[7] = (_buttons & 0xff) ;
+ report.data[13] = (_buttons & 0xff) ;
report.length = 8;
#endif
#if (BUTTONS32 == 1)
//Use 4 bit padding for hat4 or hat8
- report.data[6] = (_hat & 0x0f) ;
+ report.data[12] = (_hat & 0x0f) ;
//No bit padding for 32 buttons
- report.data[7] = (_buttons >> 0) & 0xff;
- report.data[8] = (_buttons >> 8) & 0xff;
- report.data[9] = (_buttons >> 16) & 0xff;
- report.data[10] = (_buttons >> 24) & 0xff;
- report.length = 11;
+ report.data[13] = (_buttons >> 0) & 0xff;
+ report.data[14] = (_buttons >> 8) & 0xff;
+ report.data[15] = (_buttons >> 16) & 0xff;
+ report.data[16] = (_buttons >> 24) & 0xff;
+ report.length = 17;
#endif
return send(&report);
@@ -153,7 +159,7 @@
REPORT_SIZE(1), 0x10, // REPORT_SIZE describes the number of bits in this element (16, in this case)
REPORT_COUNT(1), 0x06,
INPUT(1), 0x02, // Data, Variable, Absolute
- END_COLLECTION(0),
+ END_COLLECTION(0),
#if (HAT4 == 1)
// 4 Position Hat Switch
@@ -173,7 +179,7 @@
LOGICAL_MINIMUM(1), 0x00, // 0
LOGICAL_MAXIMUM(1), 0x07, // 7
PHYSICAL_MINIMUM(1), 0x00, // Physical_Minimum (0)
- PHYSICAL_MAXIMUM(2), 0x3B, 0x01, // Physical_Maximum (315)
+ PHYSICAL_MAXIMUM(2), 0x3B, 0x01, // Physical_Maximum (45 deg x (max of)7 = 315)
UNIT(1), 0x14, // Unit (Eng Rot:Angular Pos)
REPORT_SIZE(1), 0x04,
REPORT_COUNT(1), 0x01,
