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: addressRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
36 btDiscovery.discovery = true
43 anchors{bottom: infoText.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
47 text: "No device found yet."
50 connectButton.enabled = true
51 infoText.text = "Press \"Connect\" to connect to the device."
58 validator: IntValidator{}
64 anchors{bottom: connectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
67 text: "Please scan for a device first."
68 horizontalAlignment: Text.AlignHCenter
69 wrapMode: Text.WordWrap
74 anchors{bottom: disconnectButton.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
81 btConn.connect(addressField.text, parseInt(portField.text))
87 anchors{bottom: buttonRow.top; bottomMargin: 10; horizontalCenter: parent.horizontalCenter}
99 anchors.centerIn: parent
105 color: btConn.a ? "red" : "blue"
110 color: btConn.b ? "red" : "blue"
115 color: btConn.c ? "red" : "blue"
120 color: btConn.d ? "red" : "blue"
126 anchors{top: buttonRow.bottom; topMargin: 10; horizontalCenter: parent.horizontalCenter}
139 x: moveArea.x + (moveArea.width * 0.5) + btConn.x - (cursorRectangle.width * 0.5)
140 y: moveArea.y + (moveArea.height * 0.5) + btConn.y - (cursorRectangle.height * 0.5)
143 BluetoothDiscoveryModel{
147 minimalDiscovery: true
149 onDiscoveryChanged: {
151 infoText.text = "Scanning for devices..."
152 scanButton.enabled = false
153 connectButton.enabled = false
154 disconnectButton.enabled = false
156 scanButton.enabled = true
157 disconnectButton.enabled = false
161 onNewServiceDiscovered: {
162 console.log("Service " + service.serviceName + " found on "
163 + service.deviceName + " at address " + service.deviceAddress
164 + " on port " + service.servicePort + ".")
165 if(service.serviceName === "Zeemote"){
166 addressField.text = service.deviceAddress
167 portField.text = service.servicePort
175 property int joystickThreshold: 50
178 disconnectButton.enabled = true
179 infoText.text = "Connected. Have fun."
183 connectButton.enabled = true
184 disconnectButton.enabled = false
185 infoText.text = "Press \"Connect\" to connect to the device."
189 // console.log("Stick moved. x: " + x + " y: " + y)
192 // onButtonsChanged: {
193 // console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d)
197 // console.log("A changed to: " + val)
198 xtstAdapter.sendKey("a", val);
201 // console.log("B changed to: " + val)
202 xtstAdapter.sendKey("b", val);
205 // console.log("C changed to: " + val)
206 xtstAdapter.sendKey("c", val);
209 // console.log("D changed to: " + val)
210 xtstAdapter.sendKey("d", val);
214 if(val > joystickThreshold){
215 xtstAdapter.sendKey("Right", true);
216 }else if(val < -joystickThreshold){
217 xtstAdapter.sendKey("Left", true);
219 xtstAdapter.sendKey("Right", false);
220 xtstAdapter.sendKey("Left", false);
225 if(val > joystickThreshold){
226 xtstAdapter.sendKey("Down", true);
227 }else if(val < -joystickThreshold){
228 xtstAdapter.sendKey("Up", true);
230 xtstAdapter.sendKey("Down", false);
231 xtstAdapter.sendKey("Up", false);