mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 23:32:58 +02:00
Modify gracefulControls SPACE key to be toggle
This commit is contained in:
parent
efe72e1b85
commit
f0e58fea9a
1 changed files with 16 additions and 8 deletions
|
@ -45,8 +45,9 @@ var KEY_LEFT = "a";
|
|||
var KEY_RIGHT = "d";
|
||||
var KEY_UP = "e";
|
||||
var KEY_DOWN = "c";
|
||||
var KEY_ENABLE = "SPACE";
|
||||
var CAPTURED_KEYS = [KEY_BRAKE, KEY_FORWARD, KEY_BACKWARD, KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_ENABLE];
|
||||
var KEY_TOGGLE= "SPACE";
|
||||
var KEY_DISABLE = "ESC";
|
||||
var CAPTURED_KEYS = [KEY_BRAKE, KEY_FORWARD, KEY_BACKWARD, KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_TOGGLE];
|
||||
|
||||
// Global Variables
|
||||
var keys = {};
|
||||
|
@ -63,12 +64,10 @@ var yawSpeed = 0;
|
|||
var pitchSpeed = 0;
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.text == "ESC") {
|
||||
if (event.text == KEY_DISABLE) {
|
||||
disable();
|
||||
} else if (event.text == KEY_ENABLE) {
|
||||
if (Window.hasFocus()) {
|
||||
enable();
|
||||
}
|
||||
} else if (event.text == KEY_TOGGLE) {
|
||||
toggleEnabled();
|
||||
} else if (event.text == KEY_BRAKE) {
|
||||
movementParameters = BRAKE_PARAMETERS;
|
||||
}
|
||||
|
@ -178,8 +177,17 @@ function resetCursorPosition() {
|
|||
lastY = newY;
|
||||
}
|
||||
|
||||
|
||||
function toggleEnabled() {
|
||||
if (enabled) {
|
||||
disable();
|
||||
} else {
|
||||
enable();
|
||||
}
|
||||
}
|
||||
|
||||
function enable() {
|
||||
if (!enabled) {
|
||||
if (!enabled && Window.hasFocus()) {
|
||||
enabled = true;
|
||||
|
||||
resetCursorPosition();
|
||||
|
|
Loading…
Reference in a new issue