Label{
id: labelA
text: "A"
- color: "blue"
+ color: btConn.a ? "red" : "blue"
}
Label{
id: labelB
text: "B"
- color: "blue"
+ color: btConn.b ? "red" : "blue"
}
Label{
id: labelC
text: "C"
- color: "blue"
+ color: btConn.c ? "red" : "blue"
}
Label{
id: labelD
text: "D"
- color: "blue"
+ color: btConn.d ? "red" : "blue"
}
}
BtConnector{
id: btConn
+ property int joystickThreshold: 50
+
onConnected: {
connectButton.enabled = false
disconnectButton.enabled = true
onButtonsChanged: {
console.log("Buttons changed. A: " + a + " B: " + b + " C: " + c + " D: " + d)
- labelA.color = a ? "red" : "blue"
- labelB.color = b ? "red" : "blue"
- labelC.color = c ? "red" : "blue"
- labelD.color = d ? "red" : "blue"
}
+
+ onAChanged: {
+ console.log("A changed to: " + val)
+ xtstAdapter.sendKey("a", val);
+ }
+ onBChanged: {
+ console.log("B changed to: " + val)
+ xtstAdapter.sendKey("b", val);
+ }
+ onCChanged: {
+ console.log("C changed to: " + val)
+ xtstAdapter.sendKey("c", val);
+ }
+ onDChanged: {
+ console.log("D changed to: " + val)
+ xtstAdapter.sendKey("d", 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);
+ }
+ }
+ }
+
+ XtstAdapter{
+ id: xtstAdapter
}
}