Initial for Condor Simulator
Dependents: USBJoystick_2 USBJoystick_NEW
Fork of USBJoystick by
Revision 1:92574cf6e9af, committed 2018-07-22
- Comitter:
- Cirrus01
- Date:
- Sun Jul 22 10:34:23 2018 +0000
- Parent:
- 0:e086541742c3
- Child:
- 2:265e03bf82af
- Commit message:
- Initial
Changed in this revision
| USBJoystick.cpp | Show annotated file Show diff for this revision Revisions of this file |
| USBJoystick.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBJoystick.cpp Thu Jan 05 14:22:02 2017 +0000
+++ b/USBJoystick.cpp Sun Jul 22 10:34:23 2018 +0000
@@ -2,7 +2,7 @@
* Copyright (c) 2012, v01: Initial version, WH,
* Modified USBMouse code ARM Limited.
* (c) 2010-2011 mbed.org, MIT License
- * 2016, v02: Updated USBDevice Lib, Added waitForConnect, Updated 32 bits button
+ * 2016, v02: Updated USBDevice Lib, Added waitForConnect, Updated 32 bits button
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,226 +27,248 @@
#include "stdint.h"
#include "USBJoystick.h"
-bool USBJoystick::update(int16_t t, int16_t r, int16_t x, int16_t y, uint32_t buttons, uint8_t hat) {
+bool USBJoystick::update(int16_t t, int16_t r, int16_t d, int16_t w, int16_t x, int16_t y, uint32_t buttons, uint8_t hat)
+{
- _t = t;
- _r = r;
- _x = x;
- _y = y;
- _buttons = buttons;
- _hat = hat;
+ _t = t;
+ _r = r;
+ _d = d;
+ _w = w;
+ _x = x;
+ _y = y;
+ _buttons = buttons;
+ _hat = hat;
- return update();
+ return update();
}
-
-bool USBJoystick::update() {
- HID_REPORT report;
+
+bool USBJoystick::update()
+{
+ HID_REPORT report;
- // Fill the report according to the Joystick Descriptor
- report.data[0] = _t & 0xff;
- report.data[1] = _r & 0xff;
- report.data[2] = _x & 0xff;
- report.data[3] = _y & 0xff;
+ // Fill the report according to the Joystick Descriptor
+ report.data[0] = _t & 0xff;
+ report.data[1] = _r & 0xff;
+ report.data[2] = _d & 0xff;
+ report.data[3] = _w & 0xff;
+ report.data[4] = _x & 0xff;
+ report.data[5] = _y & 0xff;
+#if (HAT4 == 1)
+//Use 4 bit padding for hat4 or hat8
+ report.data[6] = (_hat & 0x0f) ;
+#endif
-#if (BUTTONS4 == 1)
-//Hat and 4 Buttons
-// report.data[4] = ((_buttons & 0x0f) << 4) | (_hat & 0x0f) ;
-// report.length = 5;
-
+#if (HAT8 == 1)
+//Use 4 bit padding for hat4 or hat8
+ report.data[6] = (_hat & 0xff) ;
+#endif
-//Use 4 bit padding for hat4 or hat8
- report.data[4] = (_hat & 0x0f) ;
+#if (BUTTONS4 == 1)
+//Use 4 bit padding for buttons
+ report.data[7] = (_buttons & 0x0f) ;
+ report.length = 8;
+#endif
-//Use 4 bit padding for buttons
- report.data[5] = (_buttons & 0x0f) ;
- report.length = 6;
+#if (BUTTONS8 == 1)
+//Use 8 bits for buttons
+ report.data[7] = (_buttons & 0xff) ;
+ report.length = 8;
#endif
-#if (BUTTONS8 == 1)
-//Hat and first 4 Buttons
-// report.data[4] = ((_buttons & 0x0f) << 4) | (_hat & 0x0f) ;
-//
-//Use bit padding for last 4 Buttons
-// report.data[5] = (_buttons & 0xf0) >> 4;
-// report.length = 6;
-
-//Use 4 bit padding for hat4 or hat8
- report.data[4] = (_hat & 0x0f) ;
-
-//Use 8 bits for buttons
- report.data[5] = (_buttons & 0xff) ;
- report.length = 6;
+#if (BUTTONS32 == 1)
+//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;
#endif
-#if (BUTTONS32 == 1)
-//Use 4 bit padding for hat4 or hat8
- report.data[4] = (_hat & 0x0f) ;
+ return send(&report);
+}
-//No bit padding for 32 buttons
- report.data[5] = (_buttons >> 0) & 0xff;
- report.data[6] = (_buttons >> 8) & 0xff;
- report.data[7] = (_buttons >> 16) & 0xff;
- report.data[8] = (_buttons >> 24) & 0xff;
- report.length = 9;
-#endif
-
- return send(&report);
+bool USBJoystick::throttle(int16_t t)
+{
+ _t = t;
+ return update();
}
-bool USBJoystick::throttle(int16_t t) {
- _t = t;
- return update();
+bool USBJoystick::rudder(int16_t r)
+{
+ _r = r;
+ return update();
+}
+
+bool USBJoystick::diveBreak(int16_t d)
+{
+ _d = d;
+ return update();
}
-bool USBJoystick::rudder(int16_t r) {
- _r = r;
- return update();
+bool USBJoystick::flaps(int16_t w)
+{
+ _w = w;
+ return update();
}
-bool USBJoystick::move(int16_t x, int16_t y) {
- _x = x;
- _y = y;
- return update();
+bool USBJoystick::move(int16_t x, int16_t y)
+{
+ _x = x;
+ _y = y;
+ return update();
}
-bool USBJoystick::buttons(uint32_t buttons) {
- _buttons = buttons;
- return update();
+bool USBJoystick::buttons(uint32_t buttons)
+{
+ _buttons = buttons;
+ return update();
}
-bool USBJoystick::hat(uint8_t hat) {
- _hat = hat;
- return update();
+bool USBJoystick::hat(uint8_t hat)
+{
+ _hat = hat;
+ return update();
}
-void USBJoystick::_init() {
- _t = -127;
- _r = -127;
- _x = 0;
- _y = 0;
- _buttons = 0x00000000;
- _hat = 0x00;
+void USBJoystick::_init()
+{
+ _t = -127;
+ _r = -127;
+ _d = -127;
+ _w = -127;
+ _x = 0;
+ _y = 0;
+ _buttons = 0x00000000;
+ _hat = 0x00;
}
-uint8_t * USBJoystick::reportDesc() {
- static uint8_t reportDescriptor[] = {
+uint8_t * USBJoystick::reportDesc()
+{
+ static uint8_t reportDescriptor[] = {
- USAGE_PAGE(1), 0x01, // Generic Desktop
- LOGICAL_MINIMUM(1), 0x00, // Logical_Minimum (0)
- USAGE(1), 0x04, // Usage (Joystick)
- COLLECTION(1), 0x01, // Application
- USAGE_PAGE(1), 0x02, // Simulation Controls
- USAGE(1), 0xBB, // Throttle
- USAGE(1), 0xBA, // Rudder
- LOGICAL_MINIMUM(1), 0x81, // -127
- LOGICAL_MAXIMUM(1), 0x7f, // 127
- REPORT_SIZE(1), 0x08,
- REPORT_COUNT(1), 0x02,
- INPUT(1), 0x02, // Data, Variable, Absolute
- USAGE_PAGE(1), 0x01, // Generic Desktop
- USAGE(1), 0x01, // Usage (Pointer)
- COLLECTION(1), 0x00, // Physical
- USAGE(1), 0x30, // X
- USAGE(1), 0x31, // Y
+ USAGE_PAGE(1), 0x01, // Generic Desktop
+ LOGICAL_MINIMUM(1), 0x00, // Logical_Minimum (0)
+ USAGE(1), 0x04, // Usage (Joystick)
+ COLLECTION(1), 0x01, // Application
+ USAGE_PAGE(1), 0x02, // Simulation Controls
+ USAGE(1), 0xBB, // Throttle
+ USAGE(1), 0xBA, // Rudder
+ LOGICAL_MINIMUM(1), 0x81, // -127
+ LOGICAL_MAXIMUM(1), 0x7f, // 127
+ REPORT_SIZE(1), 0x08,
+ REPORT_COUNT(1), 0x02,
+ INPUT(1), 0x02, // Data, Variable, Absolute
+ USAGE(1), 0xB6, // Dive Breaks
+ USAGE(1), 0xC3, // Wing Flaps
+ LOGICAL_MINIMUM(1), 0x81, // -127
+ LOGICAL_MAXIMUM(1), 0x7f, // 127
+ REPORT_SIZE(1), 0x08,
+ REPORT_COUNT(1), 0x02,
+ INPUT(1), 0x02, // Data, Variable, Absolute
+ USAGE_PAGE(1), 0x01, // Generic Desktop
+ USAGE(1), 0x01, // Usage (Pointer)
+ COLLECTION(1), 0x00, // Physical
+ USAGE(1), 0x30, // X
+ USAGE(1), 0x31, // Y
// 8 bit values
- LOGICAL_MINIMUM(1), 0x81, // -127
- LOGICAL_MAXIMUM(1), 0x7f, // 127
- REPORT_SIZE(1), 0x08,
- REPORT_COUNT(1), 0x02,
- INPUT(1), 0x02, // Data, Variable, Absolute
+ LOGICAL_MINIMUM(1), 0x81, // -127
+ LOGICAL_MAXIMUM(1), 0x7f, // 127
+ REPORT_SIZE(1), 0x08,
+ REPORT_COUNT(1), 0x02,
+ INPUT(1), 0x02, // Data, Variable, Absolute
// 16 bit values
// LOGICAL_MINIMUM(1), 0x00, // 0
// LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767
// REPORT_SIZE(1), 0x10,
// REPORT_COUNT(1), 0x02,
-// INPUT(1), 0x02, // Data, Variable, Absolute
+// INPUT(1), 0x02, // Data, Variable, Absolute
- END_COLLECTION(0),
+ END_COLLECTION(0),
#if (HAT4 == 1)
// 4 Position Hat Switch
- USAGE(1), 0x39, // Usage (Hat switch)
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x03, // 3
- PHYSICAL_MINIMUM(1), 0x00, // Physical_Minimum (0)
- PHYSICAL_MAXIMUM(2), 0x0E, 0x01, // Physical_Maximum (270)
- 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), 0x03, // 3
+ PHYSICAL_MINIMUM(1), 0x00, // Physical_Minimum (0)
+ PHYSICAL_MAXIMUM(2), 0x0E, 0x01, // Physical_Maximum (270)
+ UNIT(1), 0x14, // Unit (Eng Rot:Angular Pos)
+ REPORT_SIZE(1), 0x04,
+ REPORT_COUNT(1), 0x01,
+ INPUT(1), 0x02, // Data, Variable, Absolute
#endif
#if (HAT8 == 1)
// 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
#endif
// Padding 4 bits
- REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x04,
- INPUT(1), 0x01, // Constant
+ REPORT_SIZE(1), 0x01,
+ REPORT_COUNT(1), 0x04,
+ INPUT(1), 0x01, // Constant
#if (BUTTONS4 == 1)
// 4 Buttons
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01, // 1
- USAGE_MAXIMUM(1), 0x04, // 4
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x01, // 1
- REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x04,
- UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
- UNIT(1), 0x00, // Unit (None)
- INPUT(1), 0x02, // Data, Variable, Absolute
+ USAGE_PAGE(1), 0x09, // Buttons
+ USAGE_MINIMUM(1), 0x01, // 1
+ USAGE_MAXIMUM(1), 0x04, // 4
+ LOGICAL_MINIMUM(1), 0x00, // 0
+ LOGICAL_MAXIMUM(1), 0x01, // 1
+ REPORT_SIZE(1), 0x01,
+ REPORT_COUNT(1), 0x04,
+ UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
+ UNIT(1), 0x00, // Unit (None)
+ INPUT(1), 0x02, // Data, Variable, Absolute
// Padding 4 bits
- REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x04,
- INPUT(1), 0x01, // Constant
+ REPORT_SIZE(1), 0x01,
+ REPORT_COUNT(1), 0x04,
+ INPUT(1), 0x01, // Constant
#endif
#if (BUTTONS8 == 1)
// 8 Buttons
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01, // 1
- USAGE_MAXIMUM(1), 0x08, // 8
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x01, // 1
- REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x08,
- UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
- UNIT(1), 0x00, // Unit (None)
- INPUT(1), 0x02, // Data, Variable, Absolute
+ USAGE_PAGE(1), 0x09, // Buttons
+ USAGE_MINIMUM(1), 0x01, // 1
+ USAGE_MAXIMUM(1), 0x08, // 8
+ LOGICAL_MINIMUM(1), 0x00, // 0
+ LOGICAL_MAXIMUM(1), 0x01, // 1
+ REPORT_SIZE(1), 0x01,
+ REPORT_COUNT(1), 0x08,
+ UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
+ UNIT(1), 0x00, // Unit (None)
+ INPUT(1), 0x02, // Data, Variable, Absolute
#endif
#if (BUTTONS32 == 1)
// 32 Buttons
- USAGE_PAGE(1), 0x09, // Buttons
- USAGE_MINIMUM(1), 0x01, // 1
- USAGE_MAXIMUM(1), 0x20, // 32
- LOGICAL_MINIMUM(1), 0x00, // 0
- LOGICAL_MAXIMUM(1), 0x01, // 1
- REPORT_SIZE(1), 0x01,
- REPORT_COUNT(1), 0x20,
- UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
- UNIT(1), 0x00, // Unit (None)
- INPUT(1), 0x02, // Data, Variable, Absolute
+ USAGE_PAGE(1), 0x09, // Buttons
+ USAGE_MINIMUM(1), 0x01, // 1
+ USAGE_MAXIMUM(1), 0x20, // 32
+ LOGICAL_MINIMUM(1), 0x00, // 0
+ LOGICAL_MAXIMUM(1), 0x01, // 1
+ REPORT_SIZE(1), 0x01,
+ REPORT_COUNT(1), 0x20,
+ UNIT_EXPONENT(1), 0x00, // Unit_Exponent (0)
+ UNIT(1), 0x00, // Unit (None)
+ INPUT(1), 0x02, // Data, Variable, Absolute
#endif
- END_COLLECTION(0)
- };
+ END_COLLECTION(0)
+ };
- reportLength = sizeof(reportDescriptor);
- return reportDescriptor;
+ reportLength = sizeof(reportDescriptor);
+ return reportDescriptor;
}
--- a/USBJoystick.h Thu Jan 05 14:22:02 2017 +0000
+++ b/USBJoystick.h Sun Jul 22 10:34:23 2018 +0000
@@ -2,7 +2,7 @@
* Copyright (c) 2012, v01: Initial version, WH,
* Modified USBMouse code ARM Limited.
* (c) 2010-2011 mbed.org, MIT License
- * 2016, v02: Updated USBDevice Lib, Added waitForConnect, Updated 32 bits button
+ * 2016, v02: Updated USBDevice Lib, Added waitForConnect, Updated 32 bits button
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +31,8 @@
#define REPORT_ID_JOYSTICK 4
//Configure Joystick
-#define HAT4 0
-#define HAT8 1
+#define HAT4 1
+#define HAT8 0
#define BUTTONS4 0
#define BUTTONS8 0
@@ -41,32 +41,32 @@
/* Common usage */
enum JOY_BUTTON {
- JOY_B0 = 1,
- JOY_B1 = 2,
- JOY_B2 = 4,
- JOY_B3 = 8,
+ JOY_B0 = 1,
+ JOY_B1 = 2,
+ JOY_B2 = 4,
+ JOY_B3 = 8,
};
#if (HAT4 == 1)
enum JOY_HAT {
- JOY_HAT_UP = 0,
- JOY_HAT_RIGHT = 1,
- JOY_HAT_DOWN = 2,
- JOY_HAT_LEFT = 3,
- JOY_HAT_NEUTRAL = 4,
+ JOY_HAT_UP = 0,
+ JOY_HAT_RIGHT = 1,
+ JOY_HAT_DOWN = 2,
+ JOY_HAT_LEFT = 3,
+ JOY_HAT_NEUTRAL = 4,
};
#endif
#if (HAT8 == 1)
enum JOY_HAT {
- JOY_HAT_UP = 0,
- JOY_HAT_UP_RIGHT = 1,
- JOY_HAT_RIGHT = 2,
- JOY_HAT_RIGHT_DOWN = 3,
- JOY_HAT_DOWN = 4,
- JOY_HAT_DOWN_LEFT = 5,
- JOY_HAT_LEFT = 6,
- JOY_HAT_LEFT_UP = 7,
- JOY_HAT_NEUTRAL = 8,
+ JOY_HAT_UP = 0,
+ JOY_HAT_UP_RIGHT = 1,
+ JOY_HAT_RIGHT = 2,
+ JOY_HAT_RIGHT_DOWN = 3,
+ JOY_HAT_DOWN = 4,
+ JOY_HAT_DOWN_LEFT = 5,
+ JOY_HAT_LEFT = 6,
+ JOY_HAT_LEFT_UP = 7,
+ JOY_HAT_NEUTRAL = 8,
};
#endif
@@ -110,25 +110,25 @@
* int main(void) {
* uint16_t i = 0;
* int16_t throttle = 0;
- * int16_t rudder = 0;
+ * int16_t rudder = 0;
* int16_t x = 0;
* int16_t y = 0;
* int32_t radius = 120;
* int32_t angle = 0;
- * uint32_t buttons = 0;
- * uint8_t hat = 0;
- *
+ * uint32_t buttons = 0;
+ * uint8_t hat = 0;
+ *
* while (1) {
* // Basic Joystick
* throttle = (i >> 8) & 0xFF; // value -127 .. 128
- * rudder = (i >> 8) & 0xFF; // value -127 .. 128
- * buttons = (i >> 8) & 0x0F; // value 0 .. 15, one bit per button
- * hat = (i >> 8) & 0x07; // value 0 .. 7 or 8 for neutral
- * i++;
- *
+ * rudder = (i >> 8) & 0xFF; // value -127 .. 128
+ * buttons = (i >> 8) & 0x0F; // value 0 .. 15, one bit per button
+ * hat = (i >> 8) & 0x07; // value 0 .. 7 or 8 for neutral
+ * i++;
+ *
* x = cos((double)angle*3.14/180.0)*radius; // value -127 .. 128
* y = sin((double)angle*3.14/180.0)*radius; // value -127 .. 128
- * angle += 3;
+ * angle += 3;
*
* joystick.update(throttle, rudder, x, y, buttons, hat);
*
@@ -139,101 +139,121 @@
*/
-class USBJoystick: public USBHID {
- public:
+class USBJoystick: public USBHID
+{
+public:
- /**
- * Constructor
- *
- * @param vendor_id Your vendor_id (default: 0x1234)
- * @param product_id Your product_id (default: 0x0002)
- * @param product_release Your product_release (default: 0x0001)
- */
+ /**
+ * Constructor
+ *
+ * @param vendor_id Your vendor_id (default: 0x1234)
+ * @param product_id Your product_id (default: 0x0002)
+ * @param product_release Your product_release (default: 0x0001)
+ */
// USBJoystick(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0100, uint16_t product_release = 0x0001, int waitForConnect = true): // 4 buttons, no padding on buttons
// USBJoystick(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0500, uint16_t product_release = 0x0001, int waitForConnect = true): // 8 buttons, no padding on buttons
- USBJoystick(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0600, uint16_t product_release = 0x0001, int waitForConnect = true): // 32 buttons, no padding on buttons
- USBHID(0, 0, vendor_id, product_id, product_release, false) {
- _init();
- connect(waitForConnect);
- };
-
- /**
- * Write state of the joystick
- *
- * @param t throttle position
- * @param r rudder position
- * @param x x-axis position
- * @param y y-axis position
- * @param buttons buttons state
- * @param hat hat state 0 (up), 1 (right, 2 (down), 3 (left) or 4 (neutral)
- * @returns true if there is no error, false otherwise
- */
- bool update(int16_t t, int16_t r, int16_t x, int16_t y, uint32_t buttons, uint8_t hat);
+ USBJoystick(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0604, uint16_t product_release = 0x0001, int waitForConnect = true): // 32 buttons, no padding on buttons
+ USBHID(0, 0, vendor_id, product_id, product_release, false) {
+ _init();
+ connect(waitForConnect);
+ };
+
+ /**
+ * Write state of the joystick
+ *
+ * @param t throttle position
+ * @param r rudder position
+ * @param x x-axis position
+ * @param y y-axis position
+ * @param buttons buttons state
+ * @param hat hat state 0 (up), 1 (right, 2 (down), 3 (left) or 4 (neutral)
+ * @returns true if there is no error, false otherwise
+ */
+ bool update(int16_t t, int16_t r, int16_t d, int16_t w, int16_t x, int16_t y, uint32_t buttons, uint8_t hat);
+
+ /**
+ * Write state of the joystick
+ *
+ * @returns true if there is no error, false otherwise
+ */
+ bool update();
+ /**
+ * Move the throttle position
+ *
+ * @param t throttle position
+ * @returns true if there is no error, false otherwise
+ */
+ bool throttle(int16_t t);
+
+ /**
+ * Move the rudder position
+ *
+ * @param r rudder position
+ * @returns true if there is no error, false otherwise
+ */
+ bool rudder(int16_t r);
+
+ /**
+ * Move the dive break position
+ *
+ * @param d dive break position
+ * @returns true if there is no error, false otherwise
+ */
+ bool diveBreak(int16_t d);
+
/**
- * Write state of the joystick
- *
- * @returns true if there is no error, false otherwise
- */
- bool update();
-
- /**
- * Move the throttle position
+ * Move the flaps position
*
- * @param t throttle position
- * @returns true if there is no error, false otherwise
- */
- bool throttle(int16_t t);
-
- /**
- * Move the rudder position
- *
- * @param r rudder position
+ * @param w wing flaps position
* @returns true if there is no error, false otherwise
*/
- bool rudder(int16_t r);
+ bool flaps(int16_t w);
+
+
+ /**
+ * Move the cursor to (x, y)
+ *
+ * @param x-axis position
+ * @param y-axis position
+ * @returns true if there is no error, false otherwise
+ */
+ bool move(int16_t x, int16_t y);
+
+ /**
+ * Press one or several buttons
+ *
+ * @param buttons buttons state
+ * @returns true if there is no error, false otherwise
+ */
+ bool buttons(uint32_t buttons);
- /**
- * Move the cursor to (x, y)
- *
- * @param x-axis position
- * @param y-axis position
- * @returns true if there is no error, false otherwise
- */
- bool move(int16_t x, int16_t y);
-
- /**
- * Press one or several buttons
- *
- * @param buttons buttons state
- * @returns true if there is no error, false otherwise
- */
- bool buttons(uint32_t buttons);
-
- /**
- * Press hat
- *
- * @param hat hat state
- * @returns true if there is no error, false otherwise
- */
- bool hat(uint8_t hat);
-
- /**
- * To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
- *
- * @returns pointer to the report descriptor
- */
- virtual uint8_t * reportDesc();
+ /**
+ * Press hat
+ *
+ * @param hat hat state
+ * @returns true if there is no error, false otherwise
+ */
+ bool hat(uint8_t hat);
- private:
- int8_t _t;
- int8_t _r;
- int8_t _x;
- int8_t _y;
- uint32_t _buttons;
- uint8_t _hat;
-
- void _init();
+ /**
+ * To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
+ *
+ * @returns pointer to the report descriptor
+ */
+ virtual uint8_t * reportDesc();
+
+private:
+ int8_t _t;
+ int8_t _r;
+ int8_t _d;
+ int8_t _w;
+ int8_t _x;
+ int8_t _y;
+ uint32_t _buttons;
+ uint8_t _hat;
+
+ void _init();
};
#endif
\ No newline at end of file
