Minor fixes

This commit is contained in:
Will Scullin 2014-07-30 12:07:21 -07:00
parent 0a1127f541
commit 8a761be9a9
4 changed files with 26 additions and 18 deletions

View File

@ -83,6 +83,7 @@ function initAudio() {
io.floatAudio(16000);
audioMoz = true;
} else {
debug("Using audio elements");
audio2 = document.createElement("audio");
}
}

View File

@ -71,25 +71,30 @@ function processGamepad(io) {
for (var idx = 0; idx < gamepad.buttons.length; idx++) {
val = gamepadMap[idx];
if (val !== undefined) {
if (gamepad.buttons[idx]) {
if (!gamepadState[idx]) {
if (val <= 0) {
io.buttonDown(-val);
} else {
io.keyDown(gamepadMap[idx]);
}
}
var old = gamepadState[idx];
var button = gamepad.buttons[idx];
var pressed;
if (typeof(button) == "object") {
pressed = button.pressed;
} else {
if (gamepadState[idx]) {
if (val <= 0) {
io.buttonUp(-val);
} else {
io.keyUp();
}
pressed = (button == 1.0);
}
if (pressed && !old) {
if (val <= 0) {
io.buttonDown(-val);
} else {
io.keyDown(gamepadMap[idx]);
}
} else if (!pressed && old) {
if (val <= 0) {
io.buttonUp(-val);
} else {
io.keyUp();
}
}
gamepadState[idx] = pressed;
}
gamepadState[idx] = gamepad.buttons[idx];
}
}
}

View File

@ -1,5 +1,5 @@
/* -*- mode: JavaScript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Copyright 2010 Will Scullin <scullin@scullinsteel.com>
/* Copyright 2010-2013 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@ -146,7 +146,7 @@ function KeyBoard(io) {
[['!','"','#','$','%','&',"'",'(',')','0','*','=','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','@','REPT','RETURN'],
['CTRL','A','S','D','F','BELL','H','J','K','L','+','&larr;','&rarr;'],
['SHIFT','Z','X','C','V','B','^','M','<','>','?','SHIFT'],
['SHIFT','Z','X','C','V','B','^',']','<','>','?','SHIFT'],
['POWER', '&nbsp;']]];
var shifted = false;

View File

@ -1,5 +1,5 @@
/* -*- mode: JavaScript; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Copyright 2010 Will Scullin <scullin@scullinsteel.com>
/* Copyright 2010-2013 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@ -374,7 +374,9 @@ function KeyBoard(io) {
row.append(key);
}
row.append('<div class="clear" />');
}
kb.append('<div class="clear" />');
}
};
}