diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-11-13 15:40:13 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:33:53 +0100 |
commit | c9a97de34ca56d4cab671beeeb6d27a66ac3da4e (patch) | |
tree | 652a2fc55284fa22506795eccb2e043aa18446b5 /DemoApplication | |
parent | 67dd94b0daecc445bbd3af7b5956ddcbdbdb5f39 (diff) |
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.
Diffstat (limited to 'DemoApplication')
-rw-r--r-- | DemoApplication/main.qml | 6 | ||||
-rw-r--r-- | DemoApplication/pages/Page4.qml | 80 | ||||
-rw-r--r-- | DemoApplication/qml.qrc | 12 |
3 files changed, 98 insertions, 0 deletions
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 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>HomeForm.qml</file> + <file>Page1Form.qml</file> + <file>Page2Form.qml</file> + <file>qtquickcontrols2.conf</file> + <file>CNButton.qml</file> + <file>Page3Form.qml</file> + <file>Page4Form.qml</file> + </qresource> +</RCC> |