2 * Copyright 2012 Ruediger Gad
4 * This file is part of QZeeControl.
6 * QZeeControl is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * QZeeControl is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with QZeeControl. If not, see <http://www.gnu.org/licenses/>.
21 import com.nokia.meego 1.0
22 import QtMobility.connectivity 1.2
23 import qzeecontrol 1.0
30 anchors{bottom: connectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
32 text: "Press to connect."
37 anchors{bottom: disconnectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
42 btDiscovery.discovery = true
48 anchors{bottom: buttonRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
59 anchors.centerIn: parent
65 color: btConn.a ? "red" : "blue"
70 color: btConn.b ? "red" : "blue"
75 color: btConn.c ? "red" : "blue"
80 color: btConn.d ? "red" : "blue"
86 anchors{top: buttonRow.bottom; topMargin: 10; horizontalCenter: parent.horizontalCenter}
99 x: moveArea.x + (moveArea.width * 0.5) + btConn.x - (cursorRectangle.width * 0.5)
100 y: moveArea.y + (moveArea.height * 0.5) + btConn.y - (cursorRectangle.height * 0.5)
103 BluetoothDiscoveryModel{
107 minimalDiscovery: true
109 onDiscoveryChanged: {
111 label.text = "Scanning for devices..."
112 connectButton.enabled = false
113 disconnectButton.enabled = false
115 connectButton.enabled = true
116 disconnectButton.enabled = false
120 onNewServiceDiscovered: {
121 console.log("Service " + service.serviceName + " found on " + service.deviceName + " at address " + service.deviceAddress + " on port " + service.servicePort + ".")
122 //btSocket.service = service
123 btConn.connect(service.deviceAddress, service.servicePort)
132 console.log("Data available: " + stringData.charCodeAt(0) + data)
136 console.log("Service changed. Connecting...")
140 onConnectedChanged: {
141 console.log("Connected.")
148 property int joystickThreshold: 50
151 connectButton.enabled = false
152 disconnectButton.enabled = true
153 label.text = "Connected."
157 connectButton.enabled = true
158 disconnectButton.enabled = false
159 label.text = "Press to connect."
163 console.log("Stick moved. x: " + x + " y: " + y)
167 console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d)
171 console.log("A changed to: " + val)
173 xtstAdapter.sendKeyPress("a");
177 console.log("B changed to: " + val)
179 xtstAdapter.sendKeyPress("b");
183 console.log("C changed to: " + val)
185 xtstAdapter.sendKeyPress("c");
189 console.log("D changed to: " + val)
191 xtstAdapter.sendKeyPress("d");
196 if(val > joystickThreshold){
197 xtstAdapter.sendKeyPress("Right");
198 }else if(val < -joystickThreshold){
199 xtstAdapter.sendKeyPress("Left");
204 if(val > joystickThreshold){
205 xtstAdapter.sendKeyPress("Down");
206 }else if(val < -joystickThreshold){
207 xtstAdapter.sendKeyPress("Up");