diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-12-06 13:28:24 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-12-07 19:07:25 +0000 |
commit | c807454297e171abc822e56dc5940d61a3d9abd3 (patch) | |
tree | 3fb36a0aadc22713352a1ea8aedbc300f71615d7 /examples | |
parent | a48bf6131e07efc178d4175df7eee9704ca97826 (diff) |
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 <paul.lemire@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qt3d/simple-qml/CameraController.qml | 28 |
1 files changed, 28 insertions, 0 deletions
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; } } |