mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 06:03:26 +02:00
make gamepads and A (select key) and B (delete character) button function
This commit is contained in:
parent
40b4a17ba8
commit
c791422fab
2 changed files with 16 additions and 2 deletions
|
@ -123,12 +123,14 @@ function scriptEnding() {
|
|||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (button == Joysticks.BUTTON_FACE_LEFT) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,6 +138,11 @@ function addJoystick(gamepad) {
|
|||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: RETURN_CHARCODE});
|
||||
Controller.captureKeyEvents({key: ENTER_CHARCODE});
|
||||
|
|
|
@ -154,12 +154,14 @@ function scriptEnding() {
|
|||
}
|
||||
|
||||
function reportButtonValue(button, newValue, oldValue) {
|
||||
if (button == Joysticks.BUTTON_FACE_LEFT) {
|
||||
if (button == Joysticks.BUTTON_FACE_BOTTOM) {
|
||||
if (newValue) {
|
||||
keyboard.pressFocussedKey();
|
||||
} else {
|
||||
keyboard.releaseKeys();
|
||||
}
|
||||
} else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) {
|
||||
deleteChar();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,6 +169,11 @@ function addJoystick(gamepad) {
|
|||
gamepad.buttonStateChanged.connect(reportButtonValue);
|
||||
}
|
||||
|
||||
var allJoysticks = Joysticks.getAllJoysticks();
|
||||
for (var i = 0; i < allJoysticks.length; i++) {
|
||||
addJoystick(allJoysticks[i]);
|
||||
}
|
||||
|
||||
Joysticks.joystickAdded.connect(addJoystick);
|
||||
Controller.captureKeyEvents({key: SPACEBAR_CHARCODE});
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
|
Loading…
Reference in a new issue