Add properties for joystick directions.
[qzeecontrol] / btconnector.cpp
index 48e7959..17f978f 100644 (file)
 
 BtConnector::BtConnector(QObject *parent)
     : QObject(parent){
+    _threshold = 50;
+
+    _up = false;
+    _down = false;
+    _left = false;
+    _right = false;
+
     _a = false;
     _b = false;
     _c = false;
@@ -73,6 +80,30 @@ void BtConnector::readData(){
         emit(xChanged(_x));
         emit(yChanged(_y));
         emit(stickMoved(_x, _y));
+
+        if(_up && (_y > -threshold())){
+            setUp(false);
+        }else if(!_up && (_y < -threshold())){
+            setUp(true);
+        }
+
+        if(_down && (_y < threshold())){
+            setDown(false);
+        }else if(!_down && (_y > threshold())){
+            setDown(true);
+        }
+
+        if(_left && (_x > -threshold())){
+            setLeft(false);
+        }else if(!_left && (_x < -threshold())){
+            setLeft(true);
+        }
+
+        if(_right && (_x < threshold())){
+            setRight(false);
+        }else if(!_right && (_x > threshold())){
+            setRight(true);
+        }
     }else if(data.at(0) == 8){
         // Button press
         /*