function loadKeyBindings(){
console.log("Loading key bindings.")
- btConn.keyBindingA = SettingsStorage.getSetting("A")
- btConn.keyBindingB = SettingsStorage.getSetting("B")
- btConn.keyBindingC = SettingsStorage.getSetting("C")
- btConn.keyBindingD = SettingsStorage.getSetting("D")
-
- btConn.keyBindingUp = SettingsStorage.getSetting("Up")
- btConn.keyBindingDown = SettingsStorage.getSetting("Down")
- btConn.keyBindingLeft = SettingsStorage.getSetting("Left")
- btConn.keyBindingRight = SettingsStorage.getSetting("Right")
+ zeeRemoteControl.keyBindingA = SettingsStorage.getSetting("A")
+ zeeRemoteControl.keyBindingB = SettingsStorage.getSetting("B")
+ zeeRemoteControl.keyBindingC = SettingsStorage.getSetting("C")
+ zeeRemoteControl.keyBindingD = SettingsStorage.getSetting("D")
+
+ zeeRemoteControl.keyBindingUp = SettingsStorage.getSetting("Up")
+ zeeRemoteControl.keyBindingDown = SettingsStorage.getSetting("Down")
+ zeeRemoteControl.keyBindingLeft = SettingsStorage.getSetting("Left")
+ zeeRemoteControl.keyBindingRight = SettingsStorage.getSetting("Right")
}
function updateConnectAndScanButton(){
addressField.enabled = true
portField.enabled = true
- connectButton.enabled = (addressField.text !== "No device found yet.")
- infoText.text = (addressField.text !== "No device found yet.") ?
+ connectButton.enabled = (addressField.text !== "No Zeemote found yet.")
+ infoText.text = (addressField.text !== "No Zeemote found yet.") ?
"To enable remote control please press \"Connect\" when ready." :
"Please scan for a Zeemote first."
-
}
states: [
name: "active"
PropertyChanges {
target: cursorRectangle
- x: moveArea.x + (moveArea.width * 0.5) + btConn.x - (cursorRectangle.width * 0.5)
- y: moveArea.y + (moveArea.height * 0.5) + btConn.y - (cursorRectangle.height * 0.5)
+ x: moveArea.x + (moveArea.width * 0.5) + zeeRemoteControl.x - (cursorRectangle.width * 0.5)
+ y: moveArea.y + (moveArea.height * 0.5) + zeeRemoteControl.y - (cursorRectangle.height * 0.5)
}
PropertyChanges {
target: labelA
- color: btConn.a ? "red" : "blue"
+ color: zeeRemoteControl.a ? "red" : "blue"
}
PropertyChanges {
target: labelB
- color: btConn.b ? "red" : "blue"
+ color: zeeRemoteControl.b ? "red" : "blue"
}
PropertyChanges {
target: labelC
- color: btConn.c ? "red" : "blue"
+ color: zeeRemoteControl.c ? "red" : "blue"
}
PropertyChanges {
target: labelD
- color: btConn.d ? "red" : "blue"
+ color: zeeRemoteControl.d ? "red" : "blue"
}
},
State {
}
PropertyChanges {
target: infoText
- text: "Press \"Connect\" to connect to the device."
+ text: "To enable remote control please press \"Connect\" when ready."
}
}
]
TextField{
id: addressField
- text: "No device found yet."
+ text: "No Zeemote found yet."
+ width: 280
onTextChanged: {
if(mainPage.initializing)
return
- if(text === "No device found yet.")
+ if(text === "No Zeemote found yet.")
return
updateConnectAndScanButton();
onClicked: {
mainPage.state = "connecting"
- btConn.connect(addressField.text, parseInt(portField.text))
+ zeeRemoteControl.connect(addressField.text, parseInt(portField.text))
}
}
text: "Disconnect"
onClicked: {
- btConn.disconnect()
+ zeeRemoteControl.disconnect()
}
}
Label{
id: labelA
text: "A"
- color: btConn.a ? "red" : "blue"
+ color: zeeRemoteControl.a ? "red" : "blue"
}
Label{
id: labelB
text: "B"
- color: btConn.b ? "red" : "blue"
+ color: zeeRemoteControl.b ? "red" : "blue"
}
Label{
id: labelC
text: "C"
- color: btConn.c ? "red" : "blue"
+ color: zeeRemoteControl.c ? "red" : "blue"
}
Label{
id: labelD
text: "D"
- color: btConn.d ? "red" : "blue"
+ color: zeeRemoteControl.d ? "red" : "blue"
}
}
height: 10
color: "red"
- x: moveArea.x + (moveArea.width * 0.5) + btConn.x - (cursorRectangle.width * 0.5)
- y: moveArea.y + (moveArea.height * 0.5) + btConn.y - (cursorRectangle.height * 0.5)
+ x: moveArea.x + (moveArea.width * 0.5) + zeeRemoteControl.x - (cursorRectangle.width * 0.5)
+ y: moveArea.y + (moveArea.height * 0.5) + zeeRemoteControl.y - (cursorRectangle.height * 0.5)
}
}
}
minimalDiscovery: true
onDiscoveryChanged: {
+ if(initializing)
+ return
+
if(discovery){
- infoText.text = "Scanning for a device..."
+ infoText.text = "Scanning for a Zeemote..."
scanButton.enabled = false
connectButton.enabled = false
disconnectButton.enabled = false
addressField.enabled = true
portField.enabled = true
- if(addressField.text !== "No device found yet." && portField.text !== "na"){
- infoText.text = "Device found. You can now connect."
+ if(addressField.text !== "No Zeemote found yet." && portField.text !== "na"){
+ infoText.text = "Zeemote found. To enable remote control please press \"Connect\" when ready."
connectButton.enabled = true
}
}
addressField.text = service.deviceAddress
portField.text = service.servicePort
discovery = false
- console.log("Found device. Stopped further discovery.")
+ console.log("Found Zeemote. Stopped further discovery.")
}
}
}
- BtConnector{
- id: btConn
+ ZeeRemoteControl{
+ id: zeeRemoteControl
threshold: 50
- property string keyBindingA
- property string keyBindingB
- property string keyBindingC
- property string keyBindingD
-
- property string keyBindingUp
- property string keyBindingDown
- property string keyBindingLeft
- property string keyBindingRight
-
onConnected: {
disconnectButton.enabled = true
infoText.text = "Connected. Have fun."
}
-
- onDisconnected: {
- mainPage.state = "disconnected"
- }
-
- // onStickMoved: {
- // console.log("Stick moved. x: " + x + " y: " + y)
- // }
-
- // onButtonsChanged: {
- // console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d)
- // }
-
- onAChanged: {
- // console.log("A changed to: " + val)
- xtstAdapter.sendKey(keyBindingA, val);
- }
- onBChanged: {
- // console.log("B changed to: " + val)
- xtstAdapter.sendKey(keyBindingB, val);
- }
- onCChanged: {
- // console.log("C changed to: " + val)
- xtstAdapter.sendKey(keyBindingC, val);
- }
- onDChanged: {
- // console.log("D changed to: " + val)
- xtstAdapter.sendKey(keyBindingD, val);
- }
-
- onUpChanged: xtstAdapter.sendKey(keyBindingUp, val)
- onDownChanged: xtstAdapter.sendKey(keyBindingDown, val)
- onLeftChanged: xtstAdapter.sendKey(keyBindingLeft, val)
- onRightChanged: xtstAdapter.sendKey(keyBindingRight, val)
-
- // onXChanged: {
- // if(val > joystickThreshold){
- // xtstAdapter.sendKey("Right", true);
- // }else if(val < -joystickThreshold){
- // xtstAdapter.sendKey("Left", true);
- // }else{
- // xtstAdapter.sendKey("Right", false);
- // xtstAdapter.sendKey("Left", false);
- // }
- // }
-
- // onYChanged: {
- // if(val > joystickThreshold){
- // xtstAdapter.sendKey("Down", true);
- // }else if(val < -joystickThreshold){
- // xtstAdapter.sendKey("Up", true);
- // }else{
- // xtstAdapter.sendKey("Down", false);
- // xtstAdapter.sendKey("Up", false);
- // }
- // }
+ onDisconnected: mainPage.state = "disconnected"
}
XtstAdapter{