Update AboutDialog.
[qzeecontrol] / btconnector.cpp
index bfa75b8..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
         /*
@@ -94,8 +125,8 @@ void BtConnector::readData(){
         emit(buttonsChanged(buttonMap & 0x01, buttonMap & 0x02, buttonMap & 0x04, buttonMap & 0x08));
 
         for(int i = 0; i <= 3; i++){
-            if(buttonMap | (oldButtonMap << i)){
-                bool val = (buttonMap ^ (1 << i));
+            if(((buttonMap | oldButtonMap) & (1 << i)) > 0){
+                bool val = (buttonMap & (1 << i)) > 0;
                 switch (i){
                 case 0:
                     _a = val;