Initial for Condor Simulator

Dependents:   USBJoystick_2 USBJoystick_NEW

Fork of USBJoystick by Wim Huiskamp

Files at this revision

API Documentation at this revision

Comitter:
Cirrus01
Date:
Sun Oct 07 14:37:43 2018 +0000
Parent:
4:71835900760f
Child:
6:cefcdf03ca0e
Commit message:
Slider Input values changed from uint to int

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	Sat Sep 29 09:27:44 2018 +0000
+++ b/USBJoystick.cpp	Sun Oct 07 14:37:43 2018 +0000
@@ -27,7 +27,7 @@
 #include "stdint.h"
 #include "USBJoystick.h"
 
-bool USBJoystick::update(uint16_t x, uint16_t y, uint16_t b, uint16_t f, uint16_t r, uint16_t t, uint8_t hat, uint32_t buttons)
+bool USBJoystick::update(int16_t x, int16_t y, int16_t b, int16_t f, int16_t r, int16_t t, uint8_t hat, uint32_t buttons)
 {
 
     _x = x;
@@ -96,32 +96,32 @@
     return send(&report);
 }
 
-bool USBJoystick::move(uint16_t x, uint16_t y)
+bool USBJoystick::move(int16_t x, int16_t y)
 {
     _x = x;
     _y = y;
     return update();
 }
 
-bool USBJoystick::diveBreak(uint16_t b)
+bool USBJoystick::diveBreak(int16_t b)
 {
     _b = b;
     return update();
 }
 
-bool USBJoystick::flaps(uint16_t f)
+bool USBJoystick::flaps(int16_t f)
 {
     _f = f;
     return update();
 }
 
-bool USBJoystick::rudder(uint16_t r)
+bool USBJoystick::rudder(int16_t r)
 {
     _r = r;
     return update();
 }
 
-bool USBJoystick::throttle(uint16_t t)
+bool USBJoystick::throttle(int16_t t)
 {
     _t = t;
     return update();
@@ -173,8 +173,8 @@
 //                USAGE(1), 0x34,               // Ry
 //                USAGE(1), 0x35,               // Rz (Rudder on Usage Page 0x02)
 //                USAGE(1), 0x36                // Slider (Throttle on Usage Page 0x02)
-                LOGICAL_MINIMUM(1), 0x00,       // 0
-                LOGICAL_MAXIMUM(2), 0xff, 0xff, // 65536
+                LOGICAL_MINIMUM(2), 0x01, 0x80, // -32767 ; war 0, 0x00
+                LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767 ; war 65536, 0xff 0xff
                 REPORT_SIZE(1), 0x10,
                 REPORT_COUNT(1), 0x04,
                 INPUT(1), 0x02,                 // Data, Variable, Absolute        
--- a/USBJoystick.h	Sat Sep 29 09:27:44 2018 +0000
+++ b/USBJoystick.h	Sun Oct 07 14:37:43 2018 +0000
@@ -160,7 +160,7 @@
       */
 //     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 = 0x0604, uint16_t product_release = 0x0001, int waitForConnect = true):    // 32 buttons, no padding on buttons
+    USBJoystick(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0500, uint16_t product_release = 0x0005, int waitForConnect = true):    // 32 buttons, no padding on buttons
         USBHID(0, 0, vendor_id, product_id, product_release, false) {
         _init();
         connect(waitForConnect);
@@ -179,7 +179,7 @@
       * @param buttons buttons state
       * @returns true if there is no error, false otherwise
       */
-    bool update(uint16_t x, uint16_t y, uint16_t b, uint16_t f, uint16_t r, uint16_t t, uint8_t hat, uint32_t buttons);
+    bool update(int16_t x, int16_t y, int16_t b, int16_t f, int16_t r, int16_t t, uint8_t hat, uint32_t buttons);
 
     /**
       * Write state of the joystick
@@ -194,7 +194,7 @@
       * @param t throttle position
       * @returns true if there is no error, false otherwise
       */
-    bool throttle(uint16_t t);
+    bool throttle(int16_t t);
 
     /**
       * Move the rudder position
@@ -202,7 +202,7 @@
       * @param r rudder position
       * @returns true if there is no error, false otherwise
       */
-    bool rudder(uint16_t r);
+    bool rudder(int16_t r);
 
     /**
       * Move the dive break position
@@ -210,7 +210,7 @@
       * @param b  break position
       * @returns true if there is no error, false otherwise
       */
-    bool diveBreak(uint16_t b);
+    bool diveBreak(int16_t b);
     
      /**
        * Move the flaps position
@@ -218,7 +218,7 @@
        * @param f flaps position
        * @returns true if there is no error, false otherwise
        */        
-     bool flaps(uint16_t f);         
+     bool flaps(int16_t f);         
 
 
     /**
@@ -228,7 +228,7 @@
       * @param y-axis position
       * @returns true if there is no error, false otherwise
       */
-    bool move(uint16_t x, uint16_t y);
+    bool move(int16_t x, int16_t y);
 
     /**
       * Press one or several buttons
@@ -254,12 +254,12 @@
     virtual uint8_t * reportDesc();
 
 private:
-    uint16_t _x;
-    uint16_t _y;
-    uint16_t _b;
-    uint16_t _f;
-    uint16_t _r;
-    uint16_t _t;
+    int16_t _x;
+    int16_t _y;
+    int16_t _b;
+    int16_t _f;
+    int16_t _r;
+    int16_t _t;
     uint8_t _hat;
     uint32_t _buttons;