Sometimes its the little things..
[qzeecontrol] / btconnector.h
index 0c5683d..cbbf002 100644 (file)
@@ -29,6 +29,13 @@ class BtConnector : public QObject
 {
     Q_OBJECT
 
+    Q_PROPERTY(int threshold READ threshold NOTIFY thresholdChanged WRITE setThreshold)
+
+    Q_PROPERTY(bool up READ up NOTIFY upChanged)
+    Q_PROPERTY(bool down READ down NOTIFY downChanged)
+    Q_PROPERTY(bool left READ left NOTIFY leftChanged)
+    Q_PROPERTY(bool right READ right NOTIFY rightChanged)
+
     Q_PROPERTY(bool a READ a NOTIFY aChanged)
     Q_PROPERTY(bool b READ b NOTIFY bChanged)
     Q_PROPERTY(bool c READ c NOTIFY cChanged)
@@ -46,6 +53,17 @@ public:
 
     Q_INVOKABLE void connect(QString address, int port);
 
+    int threshold(void){return _threshold;}
+    void setThreshold(int val){
+        _threshold = val;
+        thresholdChanged(_threshold);
+    }
+
+    bool up(){return _up;}
+    bool down(){return _down;}
+    bool left(){return _left;}
+    bool right(){return _right;}
+
     bool a(){return _a;}
     bool b(){return _b;}
     bool c(){return _c;}
@@ -55,16 +73,7 @@ public:
     int y(){return _y;}
 
 public slots:
-    void disconnect(){
-        if(!socket)
-            return;
-
-        if(socket->isOpen())
-            socket->close();
-
-        delete socket;
-        socket = 0;
-    }
+    void disconnect();
 
 signals:
     void connected();
@@ -74,6 +83,13 @@ signals:
     void stickMoved(int x, int y);
     void buttonsChanged(bool a, bool b, bool c, bool d);
 
+    void thresholdChanged(int val);
+
+    void upChanged(bool val);
+    void downChanged(bool val);
+    void leftChanged(bool val);
+    void rightChanged(bool val);
+
     void aChanged(bool val);
     void bChanged(bool val);
     void cChanged(bool val);
@@ -88,6 +104,13 @@ private slots:
 private:
     QBluetoothSocket *socket;
 
+    int _threshold;
+
+    bool _up;
+    bool _down;
+    bool _left;
+    bool _right;
+
     bool _a;
     bool _b;
     bool _c;
@@ -95,7 +118,52 @@ private:
 
     int _x;
     int _y;
+
     char oldButtonMap;
+
+    void setA(bool val){
+        _a = val;
+        aChanged(_a);
+    }
+    void setB(bool val){
+        _b = val;
+        bChanged(_b);
+    }
+    void setC(bool val){
+        _c = val;
+        cChanged(_c);
+    }
+    void setD(bool val){
+        _d = val;
+        dChanged(_d);
+    }
+
+    void setX(int val){
+        _x = val;
+        xChanged(_x);
+    }
+    void setY(int val){
+        _y = val;
+        yChanged(_y);
+    }
+
+    void setUp(bool val){
+        _up = val;
+        upChanged(_up);
+    }
+    void setDown(bool val){
+        _down = val;
+        downChanged(_down);
+    }
+    void setLeft(bool val){
+        _left = val;
+        leftChanged(_left);
+    }
+    void setRight(bool val){
+        _right = val;
+        rightChanged(_right);
+    }
+
 };
 
 #endif // BTCONNECTOR_H