summaryrefslogtreecommitdiff
path: root/src/stylus.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-01-13 11:29:11 +0100
committerJavier <dev.git@javispedro.com>2015-01-13 11:29:11 +0100
commit1e327a6d6d5eac09f5692d9091043e87ea688e5d (patch)
tree90173c457e7c07426d7f7267b68b69d4f9c3e2c8 /src/stylus.h
downloadfinesketch-1e327a6d6d5eac09f5692d9091043e87ea688e5d.tar.gz
finesketch-1e327a6d6d5eac09f5692d9091043e87ea688e5d.zip
initial importHEADmaster
Diffstat (limited to 'src/stylus.h')
-rw-r--r--src/stylus.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/stylus.h b/src/stylus.h
new file mode 100644
index 0000000..9b845b9
--- /dev/null
+++ b/src/stylus.h
@@ -0,0 +1,59 @@
+#ifndef STYLUS_H
+#define STYLUS_H
+
+#include <QObject>
+#include <gato/gatocentralmanager.h>
+#include <gato/gatoperipheral.h>
+
+class Stylus : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+
+public:
+ explicit Stylus(QObject *parent = 0);
+ ~Stylus();
+
+ qreal pressure() const;
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+
+signals:
+ void autoUpdateChanged();
+ void pressureChanged();
+ void xChanged();
+ void yChanged();
+ void zChanged();
+
+public slots:
+ void connectToAnyDevice();
+ void connectDevice(const QString &addr);
+ void disconnectDevice();
+
+private:
+ void connectToPeripheral(GatoPeripheral *peripheral);
+
+private slots:
+ void handleDiscoveredPeripheral(GatoPeripheral *peripheral, int rssi);
+ void handleConnected();
+ void handleDisconnected();
+ void handleServices();
+ void handleCharacteristics(const GatoService &service);
+ void handleValueUpdated(const GatoCharacteristic &characteristic, const QByteArray &value);
+ void handleReport(int p, int x, int y, int z);
+
+private:
+ GatoCentralManager *_manager;
+ GatoPeripheral *_peripheral;
+
+ qreal _p;
+ qreal _x;
+ qreal _y;
+ qreal _z;
+};
+
+#endif // STYLUS_H