aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-06-10 03:16:05 +0300
committerJukka Jylänki <jujjyl@gmail.com>2014-06-10 03:16:05 +0300
commitc70f8f74816a13fbff827749a7c2594d2817e041 (patch)
treeac8521871b333515aa6aa62adcc1e57ee908e835
parentb71f0def47d8ffbbaffcdaccba20713db5f0f5d1 (diff)
Rename SDL_SetEventHandler from previous commit to emscripten_SDL_SetEventHandler to reflect that this is our extension, and add comments.
-rw-r--r--src/library_sdl.js14
-rw-r--r--system/include/SDL/SDL_events.h9
2 files changed, 13 insertions, 10 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 53adf8eb..0cd1d27d 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -755,10 +755,9 @@ var LibrarySDL = {
}
}
},
+
flushEventsToHandler: function() {
- if (!SDL.eventHandler) {
- return;
- }
+ if (!SDL.eventHandler) return;
// All SDLEvents take the same amount of memory
var sdlEventPtr = allocate({{{ C_STRUCTS.SDL_KeyboardEvent.__size__ }}}, "i8", ALLOC_STACK);
@@ -767,6 +766,7 @@ var LibrarySDL = {
Runtime.dynCall('iii', SDL.eventHandler, [SDL.eventHandlerContext, sdlEventPtr]);
}
},
+
pollEvent: function(ptr) {
if (SDL.initFlags & 0x200 && SDL.joystickEventState) {
// If SDL_INIT_JOYSTICK was supplied AND the joystick system is configured
@@ -1780,9 +1780,11 @@ var LibrarySDL = {
});
},
- SDL_SetEventHandler: function(_handler, _userdata){
- SDL.eventHandler = _handler;
- SDL.eventHandlerContext = _userdata;
+ // An Emscripten-specific extension to SDL: Some browser APIs require that they are called from within an event handler function.
+ // Allow recording a callback that will be called for each received event.
+ emscripten_SDL_SetEventHandler: function(handler, userdata) {
+ SDL.eventHandler = handler;
+ SDL.eventHandlerContext = userdata;
},
SDL_SetColors: function(surf, colors, firstColor, nColors) {
diff --git a/system/include/SDL/SDL_events.h b/system/include/SDL/SDL_events.h
index 971282db..66f5c82f 100644
--- a/system/include/SDL/SDL_events.h
+++ b/system/include/SDL/SDL_events.h
@@ -616,11 +616,12 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
void *userdata);
/**
- * Use instead of SDL_PollEvent. Your application will be called whenever there
- * are events available.
+ * An Emscripten-specific extension to SDL: Some browser APIs require that they are called from within an event handler function.
+ * Allow recording a callback that will be called for each received event. This is used in place of SDL_PollEvent.
+ * Your application will be called whenever there are events available.
*/
-extern DECLSPEC void SDLCALL SDL_SetEventHandler(SDL_EventFilter handler,
- void *userdata);
+extern DECLSPEC void SDLCALL emscripten_SDL_SetEventHandler(SDL_EventFilter handler,
+ void *userdata);
/*@{*/
#define SDL_QUERY -1