diff options
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/events.cpp | 30 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 8 |
2 files changed, 18 insertions, 20 deletions
diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index 1f287bf092..4731ae59c9 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -533,6 +533,7 @@ void OSystem_SDL::setupKeymapper() { mapper->registerHardwareKeySet(keySet); Keymap *global = new Keymap("global"); + Keymap *specific = new Keymap("specific"); Action *act; Event evt; @@ -549,33 +550,28 @@ void OSystem_SDL::setupKeymapper() { ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); global->addAction(act); - - act = new Action('QUIY', "Quit", kGenericActionCategory, kQuitAction); - ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); + act = new Action('MENQ', "Menu", kGenericActionCategory, kMenuAction); + ADD_KEYDOWN_EVENT(KEYCODE_F5, ASCII_F5, 0) global->addAction(act); - - act = new Action('QUIU', "Quit", kGenericActionCategory, kQuitAction); + act = new Action('QUIQ', "Quit", kGenericActionCategory, kQuitAction); ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); global->addAction(act); + act = new Action('JUMP', "Jump"); + ADD_KEYDOWN_EVENT(KEYCODE_j, 'j', 0); + specific->addAction(act); - act = new Action('QUII', "Quit", kGenericActionCategory, kQuitAction); - ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); - global->addAction(act); - - - act = new Action('QUIG', "Quit", kGenericActionCategory, kQuitAction); - ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); - global->addAction(act); - - act = new Action('QUIH', "Quit", kGenericActionCategory, kQuitAction); - ADD_KEYDOWN_EVENT(KEYCODE_ESCAPE, ASCII_ESCAPE, 0); - global->addAction(act); + act = new Action('DUCK', "Duck"); + ADD_KEYDOWN_EVENT(KEYCODE_d, 'd', 0); + specific->addAction(act); #undef ADD_KEYDOWN_EVENT mapper->addGlobalKeymap(global); + mapper->addGlobalKeymap(specific); + mapper->pushKeymap("global"); + mapper->pushKeymap("specific", true); } diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 14668dac11..a8655ef5fd 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -134,6 +134,11 @@ void OSystem_SDL::initBackend() { setupMixer(); } + // Setup the keymapper with backend's set of keys + // NOTE: must be done before creating TimerManager + // to avoid race conditions in creating EventManager + setupKeymapper(); + // Create and hook up the timer manager, if none exists yet (we check for // this to allow subclasses to provide their own). if (_timer == 0) { @@ -148,9 +153,6 @@ void OSystem_SDL::initBackend() { _timerID = SDL_AddTimer(10, &timer_handler, _timer); } - // Provide the keymapper with backend's set of keys - setupKeymapper(); - // Invoke parent implementation of this method OSystem::initBackend(); |