From c807454297e171abc822e56dc5940d61a3d9abd3 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Sun, 6 Dec 2015 13:28:24 +0000 Subject: Add sensitivity property to QMouseController The sensitivity is defined as the recipricol of the number of pixels the mouse is required to move to obtain the extreme axis value (-1 or +1). That is if you set it to 0.1 you need to move the mouse 10 pixels to get an axis value of magnitude 1. If it is 0.01, 100 pixels gives an axis value of magnitude 1. The user is responsible for applying any additional transformations in a suitable handler. Change-Id: I51cd28a17d4fc0b8461ac3e49efb26b2c66081b3 Reviewed-by: Paul Lemire --- examples/qt3d/simple-qml/CameraController.qml | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'examples/qt3d/simple-qml') diff --git a/examples/qt3d/simple-qml/CameraController.qml b/examples/qt3d/simple-qml/CameraController.qml index bbdc3037f..f3d1b5739 100644 --- a/examples/qt3d/simple-qml/CameraController.qml +++ b/examples/qt3d/simple-qml/CameraController.qml @@ -58,6 +58,7 @@ Entity { property real vz: 0; property real dx: 0 property real dy: 0 + property bool fineMotion: false } KeyboardController { @@ -66,6 +67,7 @@ Entity { MouseController { id: mouseSourceDevice + sensitivity: d.fineMotion ? 0.01 : 0.1 } LogicalDevice { @@ -89,7 +91,17 @@ Entity { keys: [MouseController.Right] } ] + }, + Action { + name: "fineMotion" + inputs: [ + ActionInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Shift] + } + ] } + ] // actions axes: [ @@ -204,10 +216,18 @@ Entity { case "LMB": { d.leftMouseButtonPressed = true; + break; } case "RMB": { d.rightMouseButtonPressed = true; + break; + } + + case "fineMotion": { + console.log("fineMotion started") + d.fineMotion = true; + break; } } @@ -220,10 +240,18 @@ Entity { case "LMB": { d.leftMouseButtonPressed = false; + break; } case "RMB": { d.rightMouseButtonPressed = false; + break; + } + + case "fineMotion": { + console.log("fineMotion finished") + d.fineMotion = false; + break; } } -- cgit v1.2.3