aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Vilk <jvilk@cs.umass.edu>2013-11-19 21:16:52 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-11-19 18:22:45 -0800
commit814083f84a250a69ce66cf16ca38d0d7d425eee2 (patch)
tree17ef5ee1ec5fb9f87be2df036ee3e81b250d5459
parent4a54aa90277cebaf544f42cc9e0f2f4401e7ece4 (diff)
[SDL] SDL_JoystickEventState should default to SDL_ENABLE, not SDL_DISABLE.
-rw-r--r--src/library_sdl.js2
-rw-r--r--tests/sdl_joystick.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index eb8eea97..8fd06a43 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -715,7 +715,7 @@ var LibrarySDL = {
// Joystick helper methods and state
- joystickEventState: 0,
+ joystickEventState: 1, // SDL_ENABLE
lastJoystickState: {}, // Map from SDL_Joystick* to their last known state. Required to determine if a change has occurred.
// Maps Joystick names to pointers. Allows us to avoid reallocating memory for
// joystick names each time this function is called.
diff --git a/tests/sdl_joystick.c b/tests/sdl_joystick.c
index 50802c31..bdb621ab 100644
--- a/tests/sdl_joystick.c
+++ b/tests/sdl_joystick.c
@@ -72,6 +72,10 @@ void main_2(void* arg) {
assert(SDL_JoystickNumAxes(pad1) == 4);
assert(SDL_JoystickNumButtons(pad1) == 16);
+ // By default, SDL will automatically process events. Test this behavior, and then disable it.
+ assert(SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE);
+ SDL_JoystickEventState(SDL_DISABLE);
+ assert(SDL_JoystickEventState(SDL_QUERY) == SDL_DISABLE);
// Button events.
emscripten_run_script("window.simulateGamepadButtonDown(0, 1)");
// We didn't tell SDL to automatically update this joystick's state.