diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-11-26 15:39:51 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:33:53 +0100 |
commit | 5c75a9e125ca636dbc29767805b2279a80deb8ff (patch) | |
tree | e1ec59e5bdd5bdbb16a159837066497916e4f235 /DemoApplication/pages | |
parent | c9a97de34ca56d4cab671beeeb6d27a66ac3da4e (diff) |
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
Diffstat (limited to 'DemoApplication/pages')
-rw-r--r-- | DemoApplication/pages/Page4.qml | 13 |
1 files changed, 10 insertions, 3 deletions
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() } } |