aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-22 18:17:16 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-22 18:17:16 -0700
commit5659fe6a94782fc590603024cd513dbc12234c98 (patch)
treebb00d53871435c6e8d3eb1725f3ed89dc878aa02
parent019463d05070f2945f84a4bf57bd37e613c58cd7 (diff)
more sdl keys
-rw-r--r--src/library_sdl.js24
-rw-r--r--tests/sdl_key.c17
2 files changed, 23 insertions, 18 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 034195e8..4377c107 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -146,21 +146,25 @@ var LibrarySDL = {
120: 27,
121: 28,
122: 29, // Z
- 48: 30, // 0
- 49: 31,
- 50: 32,
- 51: 33,
- 52: 34,
- 53: 35,
- 54: 36,
- 55: 37,
- 56: 38,
- 57: 39, // 9
+ 49: 30, // 1
+ 50: 31,
+ 51: 32,
+ 52: 33,
+ 53: 34,
+ 54: 35,
+ 55: 36,
+ 56: 37,
+ 57: 38, // 9
+ 48: 39, // 0
13: 40, // return
9: 43, // tab
+ 27: 41, // escape
32: 44, // space
92: 49, // backslash
47: 56, // slash
+ 305: 224, // ctrl
+ 308: 226, // alt
+ 1113: 89, // keypad 1
1106: 82, // up arrow
1105: 81, // down arrow
1104: 80, // left arrow
diff --git a/tests/sdl_key.c b/tests/sdl_key.c
index f82f8e72..3747977e 100644
--- a/tests/sdl_key.c
+++ b/tests/sdl_key.c
@@ -25,7 +25,8 @@ void one() {
}
printf("unknown key: sym %d scancode %d\n", event.key.keysym.sym, event.key.keysym.scancode);
REPORT_RESULT();
- emscripten_run_script("throw 'done'");
+ emscripten_run_script("throw 'done'"); // comment this out to leave event handling active. Use the following to log DOM keys:
+ // addEventListener('keyup', function(event) { console.log(event.keyCode) }, true)
}
}
break;
@@ -39,13 +40,13 @@ int main(int argc, char **argv) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
- emscripten_run_script("simulateKeyEvent(38)");
- emscripten_run_script("simulateKeyEvent(40)");
- emscripten_run_script("simulateKeyEvent(37)");
- emscripten_run_script("simulateKeyEvent(39)");
- emscripten_run_script("simulateKeyEvent(32)");
- emscripten_run_script("simulateKeyEvent(97)");
- emscripten_run_script("simulateKeyEvent(98)");
+ emscripten_run_script("simulateKeyEvent(38)"); // up
+ emscripten_run_script("simulateKeyEvent(40)"); // down
+ emscripten_run_script("simulateKeyEvent(37)"); // left
+ emscripten_run_script("simulateKeyEvent(39)"); // right
+ emscripten_run_script("simulateKeyEvent(32)"); // space
+ emscripten_run_script("simulateKeyEvent(97)"); // a
+ emscripten_run_script("simulateKeyEvent(98)"); // b
emscripten_run_script("simulateKeyEvent(100)"); // trigger the end
if (argc == 1337) one(); // keep it alive