That's super-useful for input handling and reacting to display resizing (I need to discard and create a couple offscreen render targets). With this I'll be able to ditch 90% of the glut code (which I didn't like anyway).
Thanks! -Floh. Am Montag, 27. Januar 2014 12:25:19 UTC+1 schrieb jj: > > Hi, > > last week, something very interesting landed to emscripten incoming: a new > set of C callback APIs for receiving various HTML5 events. See here > https://github.com/kripken/emscripten/blob/incoming/system/include/emscripten/html5.h > > The task that it accomplishes is somewhat simple - the code provides a C > interface for accessing different HTML5 apis. Naturally not all the > different HTML5 specs are there, but the scope is placed on those events > that native codebases typically need, which include input events (keyboard, > mouse, gamepad, touch), "application lifecycle events" (visible, hidden, > unloaded), windowing events (resize, scroll, fullscreen, pointerlock, > webglcontext), device events (motion, orientation, acceleration) and a few > others. > > The idea for these is to enable a quick 1:1 access to the most common web > apis that are provided in HTML5, without requiring that users need to learn > the low-level C <-> JS interop machinery first, or how to write and > integrate.js libraries to projects. As a quick example, reading keyboard > events through this library would look like this: > > #include <emscripten/html5.h> > > EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void > *userData) > { > printf("You pressed key %lu\n", e->which) > } > > int main() > { > emscripten_set_keypress_callback(0, 0, 1, key_callback); > > // Proceed to setting up game loop with emscripten_set_main_loop(...); > } > > For more code that uses these apis, refer to the unit tests for now at > https://github.com/kripken/emscripten/blob/incoming/tests/test_html5.c > > Using html5 directly has the advantage that developers can directly refer > to the HTML5 specifications for documentation. For example, the > documentation for keyboard events can be found here: > > https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys > > The events library has so far been tested on Firefox, Chrome and Internet > Explorer 11. Let us know if e.g. Safari or mobile browsers have any issues, > so that we can hide the cross-browser quirks inside the library. > > Jukka > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
