aboutsummaryrefslogtreecommitdiff
path: root/src/library_sdl.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r--src/library_sdl.js36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index b50073be..2606bafc 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -91,13 +91,20 @@ var LibrarySDL = {
33: 1099, // pagedup
34: 1102, // pagedown
-
+
+ 35: 1101, // end
+ 36: 1098, // home
+
+ 45: 1097, // insert
+
17: 1248, // control (right, or left)
18: 1250, // alt
173: 45, // minus
16: 1249, // shift
- 96: 88 | 1<<10, // keypad 0
+ 20: 301, // caps lock
+
+ 96: 98 | 1<<10, // keypad 0
97: 89 | 1<<10, // keypad 1
98: 90 | 1<<10, // keypad 2
99: 91 | 1<<10, // keypad 3
@@ -107,6 +114,15 @@ var LibrarySDL = {
103: 95 | 1<<10, // keypad 7
104: 96 | 1<<10, // keypad 8
105: 97 | 1<<10, // keypad 9
+
+ 106: 85 | 1<<10, // keypad multiply
+ 107: 87 | 1<<10, // keypad plus
+ 109: 86 | 1<<10, // keypad minus
+ 111: 84 | 1<<10, // keypad divide
+
+ 110: 99 | 1<<10, // keypad decimal point
+
+ 144: 83 | 1<<10, // keypad num lock
112: 58 | 1<<10, // F1
113: 59 | 1<<10, // F2
@@ -168,16 +184,19 @@ var LibrarySDL = {
27: 41, // escape
8: 42, // backspace
9: 43, // tab
+ 301: 57, // caps lock
32: 44, // space
61: 46, // equals
91: 47, // left bracket
93: 48, // right bracket
92: 49, // backslash
+ 96: 43, // grave
59: 51, // ;
96: 52, // apostrophe
44: 54, // comma
46: 55, // period
47: 56, // slash
+ 127: 76, // delete
305: 224, // ctrl
308: 226, // alt
},
@@ -1746,9 +1765,9 @@ var LibrarySDL = {
// Initialize Web Audio API if we haven't done so yet. Note: Only initialize Web Audio context ever once on the web page,
// since initializing multiple times fails on Chrome saying 'audio resources have been exhausted'.
if (!SDL.audioContext) {
- if (typeof(AudioContext) === 'function') {
+ if (typeof(AudioContext) !== 'undefined') {
SDL.audioContext = new AudioContext();
- } else if (typeof(webkitAudioContext) === 'function') {
+ } else if (typeof(webkitAudioContext) !== 'undefined') {
SDL.audioContext = new webkitAudioContext();
} else {
throw 'Web Audio API is not available!';
@@ -1791,7 +1810,12 @@ var LibrarySDL = {
}
#endif
var playtime = Math.max(curtime, SDL.audio.nextPlayTime);
- SDL.audio.soundSource[SDL.audio.nextSoundSource]['start'](playtime);
+ var ss = SDL.audio.soundSource[SDL.audio.nextSoundSource];
+ if (typeof ss['start'] !== 'undefined') {
+ ss['start'](playtime);
+ } else if (typeof ss['noteOn'] !== 'undefined') {
+ ss['noteOn'](playtime);
+ }
var buffer_duration = sizeSamplesPerChannel / SDL.audio.freq;
SDL.audio.nextPlayTime = playtime + buffer_duration;
// Timer will be scheduled before the buffer completed playing.
@@ -1864,7 +1888,7 @@ var LibrarySDL = {
} else if (!SDL.audio.timer && !SDL.audio.scriptProcessorNode) {
// If we are using the same sampling frequency as the native sampling rate of the Web Audio graph is using, we can feed our buffers via
// Web Audio ScriptProcessorNode, which is a pull-mode API that calls back to our code to get audio data.
- if (SDL.audioContext !== undefined && SDL.audio.freq == SDL.audioContext['sampleRate']) {
+ if (SDL.audioContext !== undefined && SDL.audio.freq == SDL.audioContext['sampleRate'] && typeof SDL.audioContext['createScriptProcessor'] !== 'undefined') {
var sizeSamplesPerChannel = SDL.audio.bufferSize / SDL.audio.bytesPerSample / SDL.audio.channels; // How many samples per a single channel fit in the cb buffer?
SDL.audio.scriptProcessorNode = SDL.audioContext['createScriptProcessor'](sizeSamplesPerChannel, 0, SDL.audio.channels);
SDL.audio.scriptProcessorNode['onaudioprocess'] = function (e) {