make gamepads and A (select key) and B (delete character) button function

This commit is contained in:
Thijs Wenker 2015-01-08 02:22:08 +01:00
parent 40b4a17ba8
commit c791422fab
2 changed files with 16 additions and 2 deletions

View file

@ -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});

View file

@ -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);