aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-07-21 16:34:58 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-07-21 16:34:58 -0700
commit9bfaac29b03a44a14a3c8e3a27bf8fbad77cbe46 (patch)
treed5531d930d85c7fd717ea17e9a433ea5640b6dc8
parent266923db9dbee14b768e98618073c346c84f0f97 (diff)
parent27c3a3e2837f0830bba9a7aae3b0f60ae82eceaf (diff)
Merge pull request #517 from caiiiycuk/SDL_GetMod
Fix sdl_getmod
-rw-r--r--src/library_sdl.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 662620d6..5bd954c8 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -45,6 +45,7 @@ var LibrarySDL = {
DOMEventToSDLEvent: {},
keyCodes: { // DOM code ==> SDL code. See https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/KeyboardEvent and SDL_keycode.h
+ 46: 127, // SDLK_DEL == '\177'
38: 1106, // up arrow
40: 1105, // down arrow
37: 1104, // left arrow
@@ -430,9 +431,13 @@ 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;
+ if (event.keyCode == 16) { //shift
+ SDL.shiftKey = event.type == "keydown";
+ } else if (event.keyCode == 17) { //control
+ SDL.ctrlKey = event.type == "keydown";
+ } else if (event.keyCode == 18) { //alt
+ SDL.altKey = event.type == "keydown";
+ }
break;
}
@@ -798,9 +803,9 @@ var LibrarySDL = {
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
+ 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) {