aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rwxr-xr-xemcc2
-rw-r--r--emscripten-version.txt2
-rwxr-xr-xemscripten.py41
-rw-r--r--src/embind/emval.js5
-rw-r--r--src/library_browser.js42
-rw-r--r--src/library_html5.js6
-rw-r--r--src/library_sdl.js372
-rw-r--r--src/preamble.js188
-rw-r--r--src/relooper/Relooper.cpp9
-rw-r--r--src/relooper/fuzzer.py6
-rw-r--r--src/relooper/test.cpp31
-rw-r--r--src/relooper/test.txt153
-rw-r--r--src/runtime.js9
-rw-r--r--src/shell.html11
-rw-r--r--src/shell_minimal.html11
-rw-r--r--src/struct_info.json18
-rw-r--r--system/include/emscripten/emscripten.h2
-rw-r--r--system/include/emscripten/html5.h6
-rw-r--r--system/include/emscripten/val.h6
-rw-r--r--tests/cases/i1tof_ta2.ll71
-rw-r--r--tests/cases/i1tof_ta2.txt3
-rw-r--r--tests/core/test_double_varargs.c34
-rw-r--r--tests/core/test_double_varargs.out2
-rw-r--r--tests/embind/embind.test.js10
-rw-r--r--tests/embind/embind_test.cpp8
-rw-r--r--tests/emscripten_fs_api_browser.cpp5
-rw-r--r--tests/fuzz/20.cpp977
-rw-r--r--tests/fuzz/20.cpp.txt1
-rw-r--r--tests/fuzz/21.c2332
-rw-r--r--tests/fuzz/21.c.txt1
-rw-r--r--tests/life.c2
-rw-r--r--tests/return64bit/test.c6
-rw-r--r--tests/return64bit/testbind.js18
-rw-r--r--tests/return64bit/testbindend.js2
-rw-r--r--tests/return64bit/testbindstart.js3
-rw-r--r--tests/sdl_audio_mix.c2
-rw-r--r--tests/sdl_audio_quickload.c44
-rw-r--r--tests/test_benchmark.py37
-rw-r--r--tests/test_browser.py2
-rw-r--r--tests/test_core.py34
-rw-r--r--tests/test_interactive.py6
-rw-r--r--tests/test_other.py25
-rw-r--r--tests/webidl/output.txt2
-rw-r--r--tests/webidl/post.js3
-rw-r--r--tests/webidl/test.h3
-rw-r--r--tests/webidl/test.idl3
-rw-r--r--third_party/WebIDL.py13
-rw-r--r--tools/bisect_pair_lines.py63
-rw-r--r--tools/eliminator/asm-eliminator-test-output.js79
-rw-r--r--tools/eliminator/asm-eliminator-test.js73
-rw-r--r--tools/js-optimizer.js203
-rw-r--r--tools/shared.py6
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js64
-rw-r--r--tools/test-js-optimizer-asm-pre.js66
-rw-r--r--tools/test-js-optimizer-asm-regs-harder-output.js5
-rw-r--r--tools/test-js-optimizer-asm-regs-harder.js8
-rw-r--r--tools/webidl_binder.py3
58 files changed, 4813 insertions, 329 deletions
diff --git a/AUTHORS b/AUTHORS
index 48a47f75..dc848d34 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -138,4 +138,7 @@ a license to everyone to use it as detailed in LICENSE.)
* Guillaume Blanc <guillaumeblanc.sc@gmail.com>
* Usagi Ito <usagi@WonderRabbitProject.net>
* Camilo Polymeris <cpolymeris@gmail.com>
+* Markus Henschel <markus.henschel@yager.de>
+* Ophir Lojkine <ophir.lojkine@eleves.ec-nantes.fr>
* Ryan Sturgell <ryan.sturgell@gmail.com> (copyright owned by Google, Inc.)
+
diff --git a/emcc b/emcc
index 7064d7d7..1a645965 100755
--- a/emcc
+++ b/emcc
@@ -1244,6 +1244,8 @@ try:
value = '"@' + os.path.abspath(value[1:]) + '"'
value = value.replace('\\\\', '/').replace('\\', '/') # Convert backslash paths to forward slashes on Windows as well, since the JS compiler otherwise needs the backslashes escaped (alternative is to escape all input paths passing to JS, which feels clumsier to read)
exec('shared.Settings.' + key + ' = ' + value)
+ if key == 'EXPORTED_FUNCTIONS':
+ shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS = shared.Settings.EXPORTED_FUNCTIONS[:] # used for warnings in emscripten.py
fastcomp = os.environ.get('EMCC_FAST_COMPILER') != '0'
diff --git a/emscripten-version.txt b/emscripten-version.txt
index f9505a5c..1992f2ad 100644
--- a/emscripten-version.txt
+++ b/emscripten-version.txt
@@ -1,2 +1,2 @@
-1.17.0
+1.18.2
diff --git a/emscripten.py b/emscripten.py
index 939ddbe8..d75214d5 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -477,7 +477,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
if '_rand' in exported_implemented_functions or '_srand' in exported_implemented_functions:
basic_vars += ['___rand_seed']
- asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)]
+ asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)] + ['getTempRet%d' % i for i in range(10)]
# function tables
function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']]
function_tables_impls = []
@@ -632,6 +632,10 @@ function setTempRet%d(value) {
value = value|0;
tempRet%d = value;
}
+''' % (i, i) for i in range(10)]) + ''.join(['''
+function getTempRet%d() {
+ return tempRet%d|0;
+}
''' % (i, i) for i in range(10)])] + [PostSets.js + '\n'] + funcs_js + ['''
%s
@@ -644,9 +648,11 @@ function setTempRet%d(value) {
if not settings.get('SIDE_MODULE'):
funcs_js.append('''
-Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
-Runtime.stackSave = function() { return asm['stackSave']() };
-Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+Runtime.stackAlloc = asm['stackAlloc'];
+Runtime.stackSave = asm['stackSave'];
+Runtime.stackRestore = asm['stackRestore'];
+Runtime.setTempRet0 = asm['setTempRet0'];
+Runtime.getTempRet0 = asm['getTempRet0'];
''')
# Set function table masks
@@ -889,10 +895,15 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
exported_implemented_functions = set(metadata['exports'])
export_bindings = settings['EXPORT_BINDINGS']
export_all = settings['EXPORT_ALL']
- for key in metadata['implementedFunctions'] + forwarded_json['Functions']['implementedFunctions'].keys(): # XXX perf
+ all_implemented = metadata['implementedFunctions'] + forwarded_json['Functions']['implementedFunctions'].keys() # XXX perf?
+ for key in all_implemented:
if key in all_exported_functions or export_all or (export_bindings and key.startswith('_emscripten_bind')):
exported_implemented_functions.add(key)
implemented_functions = set(metadata['implementedFunctions'])
+ if settings['ASSERTIONS'] and settings.get('ORIGINAL_EXPORTED_FUNCTIONS'):
+ for requested in settings['ORIGINAL_EXPORTED_FUNCTIONS']:
+ if requested not in all_implemented:
+ logging.warning('function requested to be exported, but not implemented: "%s"', requested)
# Add named globals
named_globals = '\n'.join(['var %s = %s;' % (k, v) for k, v in metadata['namedGlobals'].iteritems()])
@@ -1058,7 +1069,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
if '_rand' in exported_implemented_functions or '_srand' in exported_implemented_functions:
basic_vars += ['___rand_seed']
- asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)]
+ asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew', 'setTempRet0', 'getTempRet0']
# function tables
function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']]
function_tables_impls = []
@@ -1208,12 +1219,14 @@ function copyTempDouble(ptr) {
HEAP8[tempDoublePtr+6>>0] = HEAP8[ptr+6>>0];
HEAP8[tempDoublePtr+7>>0] = HEAP8[ptr+7>>0];
}
-''' + ''.join(['''
-function setTempRet%d(value) {
+function setTempRet0(value) {
value = value|0;
- tempRet%d = value;
+ tempRet0 = value;
+}
+function getTempRet0() {
+ return tempRet0|0;
}
-''' % (i, i) for i in range(10)])] + funcs_js + ['''
+'''] + funcs_js + ['''
%s
return %s;
@@ -1225,9 +1238,11 @@ function setTempRet%d(value) {
if not settings.get('SIDE_MODULE'):
funcs_js.append('''
-Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
-Runtime.stackSave = function() { return asm['stackSave']() };
-Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+Runtime.stackAlloc = asm['stackAlloc'];
+Runtime.stackSave = asm['stackSave'];
+Runtime.stackRestore = asm['stackRestore'];
+Runtime.setTempRet0 = asm['setTempRet0'];
+Runtime.getTempRet0 = asm['getTempRet0'];
''')
# Set function table masks
diff --git a/src/embind/emval.js b/src/embind/emval.js
index 4007701a..ebec3881 100644
--- a/src/embind/emval.js
+++ b/src/embind/emval.js
@@ -286,3 +286,8 @@ function __emval_has_function(handle, name) {
name = getStringOrSymbol(name);
return handle[name] instanceof Function;
}
+
+function __emval_typeof(handle) {
+ handle = requireHandle(handle);
+ return __emval_register(typeof handle);
+}
diff --git a/src/library_browser.js b/src/library_browser.js
index 44e8c473..4ef7c577 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -322,11 +322,6 @@ mergeInto(LibraryManager.library, {
#endif
// Set the background of the WebGL canvas to black
canvas.style.backgroundColor = "black";
-
- // Warn on context loss
- canvas.addEventListener('webglcontextlost', function(event) {
- alert('WebGL context lost. You will need to reload the page.');
- }, false);
}
if (setInModule) {
GLctx = Module.ctx = ctx;
@@ -478,7 +473,21 @@ mergeInto(LibraryManager.library, {
},
getMouseWheelDelta: function(event) {
- return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ var delta = 0;
+ switch (event.type) {
+ case 'DOMMouseScroll':
+ delta = event.detail;
+ break;
+ case 'mousewheel':
+ delta = -event.wheelDelta;
+ break;
+ case 'wheel':
+ delta = event.deltaY;
+ break;
+ default:
+ throw 'unrecognized mouse wheel event: ' + event.type;
+ }
+ return Math.max(-1, Math.min(1, delta));
},
mouseX: 0,
@@ -688,15 +697,22 @@ mergeInto(LibraryManager.library, {
emscripten_async_wget: function(url, file, onload, onerror) {
var _url = Pointer_stringify(url);
var _file = Pointer_stringify(file);
+ function doCallback(callback) {
+ if (callback) {
+ var stack = Runtime.stackSave();
+ Runtime.dynCall('vi', callback, [allocate(intArrayFromString(_file), 'i8', ALLOC_STACK)]);
+ Runtime.stackRestore(stack);
+ }
+ }
FS.createPreloadedFile(
PATH.dirname(_file),
PATH.basename(_file),
_url, true, true,
function() {
- if (onload) Runtime.dynCall('vi', onload, [file]);
+ doCallback(onload);
},
function() {
- if (onerror) Runtime.dynCall('vi', onerror, [file]);
+ doCallback(onerror);
}
);
},
@@ -727,7 +743,11 @@ mergeInto(LibraryManager.library, {
http.onload = function http_onload(e) {
if (http.status == 200) {
FS.createDataFile( _file.substr(0, index), _file.substr(index + 1), new Uint8Array(http.response), true, true);
- if (onload) Runtime.dynCall('vii', onload, [arg, file]);
+ if (onload) {
+ var stack = Runtime.stackSave();
+ Runtime.dynCall('vii', onload, [arg, allocate(intArrayFromString(_file), 'i8', ALLOC_STACK)]);
+ Runtime.stackRestore(stack);
+ }
} else {
if (onerror) Runtime.dynCall('vii', onerror, [arg, http.status]);
}
@@ -740,8 +760,8 @@ mergeInto(LibraryManager.library, {
// PROGRESS
http.onprogress = function http_onprogress(e) {
- if (e.lengthComputable || (e.lengthComputable === undefined && e.totalSize != 0)) {
- var percentComplete = (e.position / e.totalSize)*100;
+ if (e.lengthComputable || (e.lengthComputable === undefined && e.total != 0)) {
+ var percentComplete = (e.loaded / e.total)*100;
if (onprogress) Runtime.dynCall('vii', onprogress, [arg, percentComplete]);
}
};
diff --git a/src/library_html5.js b/src/library_html5.js
index d9376c2a..d5d0cd66 100644
--- a/src/library_html5.js
+++ b/src/library_html5.js
@@ -1307,6 +1307,12 @@ var LibraryJSEvents = {
JSEvents.registerWebGlEventCallback(target, userData, useCapture, callbackfunc, {{{ cDefine('EMSCRIPTEN_EVENT_WEBGLCONTEXTRESTORED') }}}, "webglcontextrestored");
return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
},
+
+ emscripten_is_webgl_context_lost: function(target) {
+ // TODO: In the future if multiple GL contexts are supported, use the 'target' parameter to find the canvas to query.
+ if (!Module['ctx']) return true; // No context ~> lost context.
+ return Module['ctx'].isContextLost();
+ }
};
autoAddDeps(LibraryJSEvents, '$JSEvents');
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 077f72eb..d9639907 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -430,6 +430,15 @@ var LibrarySDL = {
savedKeydown: null,
receiveEvent: function(event) {
+ function unpressAllPressedKeys() {
+ // Un-press all pressed keys: TODO
+ for (var code in SDL.keyboardMap) {
+ SDL.events.push({
+ type: 'keyup',
+ keyCode: SDL.keyboardMap[code]
+ });
+ }
+ };
switch(event.type) {
case 'touchstart': case 'touchmove': {
event.preventDefault();
@@ -532,7 +541,7 @@ var LibrarySDL = {
}
}
// fall through
- case 'keydown': case 'keyup': case 'keypress': case 'mousedown': case 'mouseup': case 'DOMMouseScroll': case 'mousewheel':
+ case 'keydown': case 'keyup': case 'keypress': case 'mousedown': case 'mouseup': case 'DOMMouseScroll': case 'mousewheel': case 'wheel':
// If we preventDefault on keydown events, the subsequent keypress events
// won't fire. However, it's fine (and in some cases necessary) to
// preventDefault for keys that don't generate a character. Otherwise,
@@ -541,21 +550,40 @@ var LibrarySDL = {
event.preventDefault();
}
- if (event.type == 'DOMMouseScroll' || event.type == 'mousewheel') {
+ if (event.type == 'DOMMouseScroll' || event.type == 'mousewheel' || event.type == 'wheel') {
+ // Simulate old-style SDL events representing mouse wheel input as buttons
var button = Browser.getMouseWheelDelta(event) > 0 ? 4 : 3;
- var event2 = {
+ var event1 = {
type: 'mousedown',
button: button,
pageX: event.pageX,
pageY: event.pageY
};
- SDL.events.push(event2);
- event = {
+ SDL.events.push(event1);
+ var event2 = {
type: 'mouseup',
button: button,
pageX: event.pageX,
pageY: event.pageY
};
+ SDL.events.push(event2);
+
+ // Convert DOMMouseScroll events to wheel events for new style SDL events.
+ if (event.type == 'DOMMouseScroll') {
+ SDL.events.push({
+ type: 'wheel',
+ deltaX: 0,
+ deltaY: -event.detail,
+ });
+ break;
+ } else if (event.type == 'mousewheel') {
+ SDL.events.push({
+ type: 'wheel',
+ deltaX: 0,
+ deltaY: event.wheelDelta,
+ });
+ break;
+ }
} else if (event.type == 'mousedown') {
SDL.DOMButtons[event.button] = 1;
SDL.events.push({
@@ -635,18 +663,23 @@ var LibrarySDL = {
}
event.preventDefault();
break;
+ case 'focus':
+ SDL.events.push(event);
+ event.preventDefault();
+ break;
case 'blur':
- case 'visibilitychange': {
- // Un-press all pressed keys: TODO
- for (var code in SDL.keyboardMap) {
- SDL.events.push({
- type: 'keyup',
- keyCode: SDL.keyboardMap[code]
- });
- }
+ SDL.events.push(event);
+ unpressAllPressedKeys();
+ event.preventDefault();
+ break;
+ case 'visibilitychange':
+ SDL.events.push({
+ type: 'visibilitychange',
+ visible: !document.hidden
+ });
+ unpressAllPressedKeys();
event.preventDefault();
break;
- }
case 'unload':
if (Browser.mainLoop.runner) {
SDL.events.push(event);
@@ -787,8 +820,15 @@ var LibrarySDL = {
}
break;
}
+ case 'wheel': {
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_MouseWheelEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_MouseWheelEvent.x, 'event.deltaX', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_MouseWheelEvent.y, 'event.deltaY', 'i32') }}};
+ break;
+ }
case 'touchstart': case 'touchend': case 'touchmove': {
var touch = event.touch;
+ if (!Browser.touches[touch.identifier]) break;
var w = Module['canvas'].width;
var h = Module['canvas'].height;
var x = Browser.touches[touch.identifier].x / w;
@@ -839,6 +879,29 @@ var LibrarySDL = {
{{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyAxisEvent.value, 'SDL.joystickAxisValueConversion(event.value)', 'i32') }}};
break;
}
+ case 'focus': {
+ var SDL_WINDOWEVENT_FOCUS_GAINED = 12 /* SDL_WINDOWEVENT_FOCUS_GAINED */;
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.windowID, '0', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.event, 'SDL_WINDOWEVENT_FOCUS_GAINED', 'i8') }}};
+ break;
+ }
+ case 'blur': {
+ var SDL_WINDOWEVENT_FOCUS_LOST = 13 /* SDL_WINDOWEVENT_FOCUS_LOST */;
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.windowID, '0', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.event, 'SDL_WINDOWEVENT_FOCUS_LOST', 'i8') }}};
+ break;
+ }
+ case 'visibilitychange': {
+ var SDL_WINDOWEVENT_SHOWN = 1 /* SDL_WINDOWEVENT_SHOWN */;
+ var SDL_WINDOWEVENT_HIDDEN = 2 /* SDL_WINDOWEVENT_HIDDEN */;
+ var visibilityEventID = event.visible ? SDL_WINDOWEVENT_SHOWN : SDL_WINDOWEVENT_HIDDEN;
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.windowID, 0, 'i32') }}};
+ {{{ makeSetValue('ptr', C_STRUCTS.SDL_WindowEvent.event, 'visibilityEventID' , 'i8') }}};
+ break;
+ }
default: throw 'Unhandled SDL event: ' + event.type;
}
},
@@ -880,11 +943,67 @@ var LibrarySDL = {
var ret = info.volume * 128; // MIX_MAX_VOLUME
if (volume != -1) {
info.volume = volume / 128;
- if (info.audio) info.audio.volume = info.volume;
+ if (info.audio) {
+ info.audio.volume = info.volume; // For <audio> element
+ if (info.audio.webAudioGainNode) info.audio.webAudioGainNode['gain']['value'] = info.volume; // For WebAudio playback
+ }
}
return ret;
},
+ // Plays out an SDL audio resource that was loaded with the Mix_Load APIs, when using Web Audio..
+ playWebAudio: function(audio) {
+ if (!audio) return;
+ if (audio.webAudioNode) return; // This instance is already playing, don't start again.
+ if (!SDL.webAudioAvailable()) return;
+ var webAudio = audio.resource.webAudio;
+ audio.paused = false;
+ if (!webAudio.decodedBuffer) {
+ if (webAudio.onDecodeComplete === undefined) abort("Cannot play back audio object that was not loaded");
+ webAudio.onDecodeComplete.push(function() { if (!audio.paused) SDL.playWebAudio(audio); });
+ return;
+ }
+ audio.webAudioNode = SDL.audioContext['createBufferSource']();
+ audio.webAudioNode['buffer'] = webAudio.decodedBuffer;
+ audio.webAudioNode['loop'] = audio.loop;
+ audio.webAudioNode['onended'] = function() { audio.onended(); } // For <media> element compatibility, route the onended signal to the instance.
+
+ // Add an intermediate gain node to control volume.
+ audio.webAudioGainNode = SDL.audioContext['createGain']();
+ audio.webAudioGainNode['gain']['value'] = audio.volume;
+ audio.webAudioNode['connect'](audio.webAudioGainNode);
+ audio.webAudioGainNode['connect'](SDL.audioContext['destination']);
+ audio.webAudioNode['start'](0, audio.currentPosition);
+ audio.startTime = SDL.audioContext['currentTime'] - audio.currentPosition;
+ },
+
+ // Pausea an SDL audio resource that was played with Web Audio..
+ pauseWebAudio: function(audio) {
+ if (!audio) return;
+ if (audio.webAudioNode) {
+ // Remember where we left off, so that if/when we resume, we can restart the playback at a proper place.
+ audio.currentPosition = (SDL.audioContext['currentTime'] - audio.startTime) % audio.resource.webAudio.decodedBuffer.duration;
+ // Important: When we reach here, the audio playback is stopped by the user. But when calling .stop() below, the Web Audio
+ // graph will send the onended signal, but we don't want to process that, since pausing should not clear/destroy the audio
+ // channel.
+ audio.webAudioNode['onended'] = undefined;
+ audio.webAudioNode.stop();
+ audio.webAudioNode = undefined;
+ }
+ audio.paused = true;
+ },
+
+ openAudioContext: function() {
+ // 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) !== 'undefined') SDL.audioContext = new AudioContext();
+ else if (typeof(webkitAudioContext) !== 'undefined') SDL.audioContext = new webkitAudioContext();
+ }
+ },
+
+ webAudioAvailable: function() { return !!SDL.audioContext; },
+
fillWebAudioBufferFromHeap: function(heapPtr, sizeSamplesPerChannel, dstAudioBuffer) {
// The input audio data is interleaved across the channels, i.e. [L, R, L, R, L, R, ...] and is either 8-bit or 16-bit as
// supported by the SDL API. The output audio wave data for Web Audio API must be in planar buffers of [-1,1]-normalized Float32 data,
@@ -1042,6 +1161,7 @@ var LibrarySDL = {
document.addEventListener("keydown", SDL.receiveEvent);
document.addEventListener("keyup", SDL.receiveEvent);
document.addEventListener("keypress", SDL.receiveEvent);
+ window.addEventListener("focus", SDL.receiveEvent);
window.addEventL