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); io.floatAudio(16000);
audioMoz = true; audioMoz = true;
} else { } else {
debug("Using audio elements");
audio2 = document.createElement("audio"); audio2 = document.createElement("audio");
} }
} }

View File

@ -71,25 +71,30 @@ function processGamepad(io) {
for (var idx = 0; idx < gamepad.buttons.length; idx++) { for (var idx = 0; idx < gamepad.buttons.length; idx++) {
val = gamepadMap[idx]; val = gamepadMap[idx];
if (val !== undefined) { if (val !== undefined) {
if (gamepad.buttons[idx]) { var old = gamepadState[idx];
if (!gamepadState[idx]) { var button = gamepad.buttons[idx];
if (val <= 0) { var pressed;
io.buttonDown(-val); if (typeof(button) == "object") {
} else { pressed = button.pressed;
io.keyDown(gamepadMap[idx]);
}
}
} else { } else {
if (gamepadState[idx]) { pressed = (button == 1.0);
if (val <= 0) { }
io.buttonUp(-val);
} else { if (pressed && !old) {
io.keyUp(); 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 -*- */ /* -*- 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 * Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
@ -146,7 +146,7 @@ function KeyBoard(io) {
[['!','"','#','$','%','&',"'",'(',')','0','*','=','RESET'], [['!','"','#','$','%','&',"'",'(',')','0','*','=','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','@','REPT','RETURN'], ['ESC','Q','W','E','R','T','Y','U','I','O','@','REPT','RETURN'],
['CTRL','A','S','D','F','BELL','H','J','K','L','+','&larr;','&rarr;'], ['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;']]]; ['POWER', '&nbsp;']]];
var shifted = false; var shifted = false;

View File

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