From 5c75a9e125ca636dbc29767805b2279a80deb8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Mon, 26 Nov 2018 15:39:51 +0100 Subject: Bugfixes to 360 algorithm, added cooldown for gamepad control Joystick produce change events very rapidly and continuously, so a cooldown time is needed so that the cursor wont jump over multiple items --- DemoApplication/pages/Page4.qml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'DemoApplication/pages') diff --git a/DemoApplication/pages/Page4.qml b/DemoApplication/pages/Page4.qml index f879d04..a8f3e68 100644 --- a/DemoApplication/pages/Page4.qml +++ b/DemoApplication/pages/Page4.qml @@ -4,16 +4,23 @@ import QtGamepad 1.0 import "../controls" Item { - CursorNavigation.acceptsCursor: true + //CursorNavigation.acceptsCursor: true + + Timer { + id: cooldownTimer + interval: 500 + repeat: false + } Gamepad { deviceId: GamepadManager.connectedGamepads.length > 0 ? GamepadManager.connectedGamepads[0] : -1 function handleMove() { var v = Qt.vector2d(axisLeftX, axisLeftY) - if (v.length() >= 1) { + if (v.length() >= 0.99 && !cooldownTimer.running) { //console.log("handle joystick move, v=" + v) - parent.CursorNavigation.move(Qt.vector2d(axisLeftX, axisLeftY)) + parent.CursorNavigation.move(Qt.vector2d(axisLeftX, axisLeftY), 10) + cooldownTimer.start() } } -- cgit v1.2.3