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.
Dependencies: USBDevice mbed-rtos mbed
Fork of JoyStick by
Diff: USBJoystick.cpp
- Revision:
- 2:ae7a31a3c618
- Parent:
- 0:33bc88c4ab31
- Child:
- 4:2cc58c173de8
--- a/USBJoystick.cpp Wed Aug 28 13:12:39 2013 +0000
+++ b/USBJoystick.cpp Fri Aug 30 01:37:49 2013 +0000
@@ -20,14 +20,13 @@
#include "stdint.h"
#include "USBJoystick.h"
-bool USBJoystick::update(int16_t t, int16_t r, int16_t x, int16_t y, uint8_t button, uint8_t hat) {
+bool USBJoystick::update(int16_t t, int16_t r, int16_t x, int16_t y, uint8_t button) {
HID_REPORT report;
_t = t;
_r = r;
_x = x;
_y = y;
_button = button;
- _hat = hat;
// Fill the report according to the Joystick Descriptor
report.data[0] = _t & 0xff;
@@ -38,7 +37,7 @@
report.data[5] = (_x >> 8) & 0xff;
report.data[6] = _y & 0xff;
report.data[7] = (_y >> 8) & 0xff;
- report.data[8] = ((_button & 0x0f) << 4) | (_hat & 0x0f) ;
+ report.data[8] = (_button & 0xff);
report.length = 9;
return send(&report);
@@ -56,7 +55,7 @@
report.data[5] = (_x >> 8) & 0xff;
report.data[6] = _y & 0xff;
report.data[7] = (_y >> 8) & 0xff;
- report.data[8] = ((_button & 0x0f) << 4) | (_hat & 0x0f) ;
+ report.data[8] = (_button & 0xff);
report.length = 9;
return send(&report);
@@ -83,11 +82,6 @@
return update();
}
-bool USBJoystick::hat(uint8_t hat) {
- _hat = hat;
- return update();
-}
-
void USBJoystick::_init() {
@@ -96,7 +90,6 @@
_x = 0;
_y = 0;
_button = 0x00;
- _hat = 0x00;
}
@@ -148,23 +141,24 @@
// REPORT_COUNT(1), 0x01,
// INPUT(1), 0x02, // Data, Variable, Absolute
// 8 Position Hat Switch
- USAGE(1), 0x39, // Usage (Hat switch)
- 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)
- UNIT(1), 0x14, // Unit (Eng Rot:Angular Pos)
- REPORT_SIZE(1), 0x04,
- REPORT_COUNT(1), 0x01,
- INPUT(1), 0x02, // Data, Variable, Absolute
-//
+// USAGE(1), 0x39, // Usage (Hat switch)
+// 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)
+// UNIT(1), 0x14, // Unit (Eng Rot:Angular Pos)
+// REPORT_SIZE(1), 0x04,
+// REPORT_COUNT(1), 0x01,
+// INPUT(1), 0x02, // Data, Variable, Absolute
+
+// Buttons
USAGE_PAGE(1), 0x09, // Buttons
USAGE_MINIMUM(1), 0x01, // 1
- USAGE_MAXIMUM(1), 0x04, // 4
+ USAGE_MAXIMUM(1), 0x08, // 4
LOGICAL_MINIMUM(1), 0x00, // 0
LOGICAL_MAXIMUM(1), 0x01, // 1
REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x04,
+ REPORT_COUNT(1), 0x08,
UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
UNIT(1), 0x00, // Unit (None)
INPUT(1), 0x02, // Data, Variable, Absolute
