diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-03 15:15:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-03 15:15:20 -0700 |
commit | 089df624ec353c27df3806298b0a2f7f85c8b208 (patch) | |
tree | 18e6ba8be13e9f39c520be2fa92a71ef06364391 | |
parent | 6eaed6d3c913dfee339c5448e4ef998b1eeac357 (diff) |
SDL_GetModState
-rw-r--r-- | src/library_sdl.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 154cf67d..57360052 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -92,6 +92,10 @@ var LibrarySDL = { fonts: [null], keyboardState: null, + shiftKey: false, + ctrlKey: false, + altKey: false, + startTime: null, mouseX: 0, mouseY: 0, @@ -419,6 +423,10 @@ var LibrarySDL = { {{{ makeSetValue('SDL.keyboardState', 'SDL.keyCodes[event.keyCode] || event.keyCode', 'event.type == "keydown"', 'i8') }}}; + SDL.shiftKey = event.shiftKey; + SDL.ctrlKey = event.ctrlKey; + SDL.altKey = event.altKey; + break; } case 'mousedown': case 'mouseup': case 'mousemove': { @@ -656,6 +664,13 @@ var LibrarySDL = { return SDL.keyboardState; }, + SDL_GetModState: function() { + // TODO: numlock, capslock, etc. + return (SDL.shiftKey ? 0x0001 & 0x0002 : 0) | // KMOD_LSHIFT & KMOD_RSHIFT + (SDL.ctrlKey ? 0x0040 & 0x0080 : 0) | // KMOD_LCTRL & KMOD_RCTRL + (SDL.altKey ? 0x0100 & 0x0200 : 0); // KMOD_LALT & KMOD_RALT + }, + SDL_GetMouseState: function(x, y) { if (x) {{{ makeSetValue('x', '0', 'SDL.mouseX', 'i32') }}}; if (y) {{{ makeSetValue('y', '0', 'SDL.mouseY', 'i32') }}}; |