From c9a97de34ca56d4cab671beeeb6d27a66ac3da4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Tue, 13 Nov 2018 15:40:13 +0100 Subject: Add 360 algorithm Add algorithm that allows navigation to any direction. Works somewhat well now. Example app has a page with a gamepad/stick support. --- DemoApplication/main.qml | 6 ++++ DemoApplication/pages/Page4.qml | 80 +++++++++++++++++++++++++++++++++++++++++ DemoApplication/qml.qrc | 12 +++++++ 3 files changed, 98 insertions(+) create mode 100644 DemoApplication/pages/Page4.qml create mode 100644 DemoApplication/qml.qrc (limited to 'DemoApplication') diff --git a/DemoApplication/main.qml b/DemoApplication/main.qml index 6ea81f1..32829d9 100644 --- a/DemoApplication/main.qml +++ b/DemoApplication/main.qml @@ -24,6 +24,11 @@ ApplicationWindow { } CNTabButton { text: qsTr("Page 3") + + } + CNTabButton { + text: qsTr("Page 4") + } } @@ -33,5 +38,6 @@ ApplicationWindow { Page1 { } Page2 { } Page3 { } + Page4 { } } } diff --git a/DemoApplication/pages/Page4.qml b/DemoApplication/pages/Page4.qml new file mode 100644 index 0000000..f879d04 --- /dev/null +++ b/DemoApplication/pages/Page4.qml @@ -0,0 +1,80 @@ +import QtQuick 2.0 +import CursorNavigation 1.0 +import QtGamepad 1.0 +import "../controls" + +Item { + CursorNavigation.acceptsCursor: true + + Gamepad { + deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 + + function handleMove() { + var v = Qt.vector2d(axisLeftX, axisLeftY) + if (v.length() >= 1) { + //console.log("handle joystick move, v=" + v) + parent.CursorNavigation.move(Qt.vector2d(axisLeftX, axisLeftY)) + } + } + + onAxisLeftXChanged: handleMove() + onAxisLeftYChanged: handleMove() + } + + CNButton { + id: cNButton + x: 20 + y: 20 + } + + CNButton { + id: cNButton1 + x: 20 + y: 120 + } + + CNButton { + id: cNButton2 + x: 20 + y: 220 + } + + CNButton { + id: cNButton3 + x: 150 + y: 20 + } + + CNButton { + id: cNButton4 + x: 150 + y: 120 + } + + CNButton { + id: cNButton5 + x: 150 + y: 220 + focus: true + } + + CNButton { + id: cNButton6 + x: 280 + y: 20 + } + + CNButton { + id: cNButton7 + x: 280 + y: 120 + } + + CNButton { + id: cNButton8 + x: 280 + y: 220 + } + +} + diff --git a/DemoApplication/qml.qrc b/DemoApplication/qml.qrc new file mode 100644 index 0000000..a726151 --- /dev/null +++ b/DemoApplication/qml.qrc @@ -0,0 +1,12 @@ + + + main.qml + HomeForm.qml + Page1Form.qml + Page2Form.qml + qtquickcontrols2.conf + CNButton.qml + Page3Form.qml + Page4Form.qml + + -- cgit v1.2.3