EVENTS: Use the keymapper for some previously hard-coded key bindings
This commit is contained in:
parent
7617723ab5
commit
c131e8f5b9
3 changed files with 44 additions and 62 deletions
|
@ -324,16 +324,30 @@ Common::Keymap *DefaultEventManager::getGlobalKeymap() {
|
||||||
act->setKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
|
act->setKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
|
||||||
globalKeymap->addAction(act);
|
globalKeymap->addAction(act);
|
||||||
|
|
||||||
act = new Action("LCLK", _("Left Click"));
|
act = new Action("MUTE", _("Toggle mute"));
|
||||||
act->setLeftClickEvent();
|
act->addDefaultInputMapping("C+u");
|
||||||
|
act->setEvent(EVENT_MUTE);
|
||||||
globalKeymap->addAction(act);
|
globalKeymap->addAction(act);
|
||||||
|
|
||||||
act = new Action("MCLK", _("Middle Click"));
|
act = new Action("QUIT", _("Quit"));
|
||||||
act->setMiddleClickEvent();
|
act->setEvent(EVENT_QUIT);
|
||||||
globalKeymap->addAction(act);
|
|
||||||
|
#if defined(MACOSX)
|
||||||
|
// On Macintosh, Cmd-Q quits
|
||||||
|
act->addDefaultInputMapping("M+q");
|
||||||
|
#elif defined(POSIX)
|
||||||
|
// On other *nix systems, Control-Q quits
|
||||||
|
act->addDefaultInputMapping("C+q");
|
||||||
|
#else
|
||||||
|
// Ctrl-z quits
|
||||||
|
act->addDefaultInputMapping("C+z");
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// On Windows, also use the default Alt-F4 quit combination
|
||||||
|
act->addDefaultInputMapping("A+F4");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
act = new Action("RCLK", _("Right Click"));
|
|
||||||
act->setRightClickEvent();
|
|
||||||
globalKeymap->addAction(act);
|
globalKeymap->addAction(act);
|
||||||
|
|
||||||
return globalKeymap;
|
return globalKeymap;
|
||||||
|
|
|
@ -761,40 +761,6 @@ bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MACOSX)
|
|
||||||
// On Macintosh, Cmd-Q quits
|
|
||||||
if ((ev.key.keysym.mod & KMOD_META) && sdlKeycode == 'q') {
|
|
||||||
event.type = Common::EVENT_QUIT;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#elif defined(POSIX)
|
|
||||||
// On other *nix systems, Control-Q quits
|
|
||||||
if ((ev.key.keysym.mod & KMOD_CTRL) && sdlKeycode == 'q') {
|
|
||||||
event.type = Common::EVENT_QUIT;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Ctrl-z quits
|
|
||||||
if ((event.kbd.hasFlags(Common::KBD_CTRL) && sdlKeycode == 'z')) {
|
|
||||||
event.type = Common::EVENT_QUIT;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
// On Windows, also use the default Alt-F4 quit combination
|
|
||||||
if ((ev.key.keysym.mod & KMOD_ALT) && sdlKeycode == SDLK_F4) {
|
|
||||||
event.type = Common::EVENT_QUIT;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Ctrl-u toggles mute
|
|
||||||
if ((ev.key.keysym.mod & KMOD_CTRL) && sdlKeycode == 'u') {
|
|
||||||
event.type = Common::EVENT_MUTE;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remapKey(ev, event))
|
if (remapKey(ev, event))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -821,24 +787,10 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
|
||||||
// Check if the Ctrl key is down, so that we can trap cases where the
|
// Check if the Ctrl key is down, so that we can trap cases where the
|
||||||
// user has the Ctrl key down, and has just released a special key
|
// user has the Ctrl key down, and has just released a special key
|
||||||
if (mod & KMOD_CTRL) {
|
if (mod & KMOD_CTRL) {
|
||||||
if (sdlKeycode == 'm' || // Ctrl-m toggles mouse capture
|
if (sdlKeycode == 'm') // Ctrl-m toggles mouse capture
|
||||||
#if defined(MACOSX)
|
|
||||||
// Meta - Q, handled below
|
|
||||||
#elif defined(POSIX)
|
|
||||||
sdlKeycode == 'q' || // On other *nix systems, Control-Q quits
|
|
||||||
#else
|
|
||||||
sdlKeycode == 'z' || // Ctrl-z quit
|
|
||||||
#endif
|
|
||||||
sdlKeycode == 'u') // Ctrl-u toggles mute
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same for other keys (Meta and Alt)
|
|
||||||
#if defined(MACOSX)
|
|
||||||
if ((mod & KMOD_META) && sdlKeycode == 'q')
|
|
||||||
return false; // On Macintosh, Cmd-Q quits
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If we reached here, this isn't an event handled by handleKeyDown(), thus
|
// If we reached here, this isn't an event handled by handleKeyDown(), thus
|
||||||
// continue normally
|
// continue normally
|
||||||
|
|
||||||
|
|
|
@ -48,23 +48,39 @@ const char *MetaEngine::getSavegamePattern(const char *target) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Keymap *MetaEngine::initKeymap(const char *target) const {
|
Common::Keymap *MetaEngine::initKeymap(const char *target) const {
|
||||||
Common::Keymap *const engineKeyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame, "engine-default");
|
using namespace Common;
|
||||||
|
|
||||||
|
Keymap *const engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "engine-default");
|
||||||
|
|
||||||
// Since the game has multiple built-in keys for each of these anyway,
|
// Since the game has multiple built-in keys for each of these anyway,
|
||||||
// this just attempts to remap one of them.
|
// this just attempts to remap one of them.
|
||||||
const Common::KeyActionEntry keyActionEntries[] = {
|
const KeyActionEntry keyActionEntries[] = {
|
||||||
{ "PAUS", Common::KeyState(Common::KEYCODE_SPACE, ' ', 0), "SPACE", _("Pause") },
|
{ "PAUS", KeyState(KEYCODE_SPACE, ' ', 0), "SPACE", _("Pause") },
|
||||||
{ "SKCT", Common::KeyState(Common::KEYCODE_ESCAPE, Common::ASCII_ESCAPE, 0), "ESCAPE", _("Skip") },
|
{ "SKCT", KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0), "ESCAPE", _("Skip") },
|
||||||
{ "SKLI", Common::KeyState(Common::KEYCODE_PERIOD, '.', 0), "PERIOD", _("Skip line") }
|
{ "SKLI", KeyState(KEYCODE_PERIOD, '.', 0), "PERIOD", _("Skip line") }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint i = 0; i < ARRAYSIZE(keyActionEntries); i++) {
|
for (uint i = 0; i < ARRAYSIZE(keyActionEntries); i++) {
|
||||||
Common::Action *const act = new Common::Action(keyActionEntries[i].id, keyActionEntries[i].description);
|
Action *const act = new Action(keyActionEntries[i].id, keyActionEntries[i].description);
|
||||||
act->setKeyEvent(keyActionEntries[i].ks);
|
act->setKeyEvent(keyActionEntries[i].ks);
|
||||||
act->addDefaultInputMapping(keyActionEntries[i].defaultHwId);
|
act->addDefaultInputMapping(keyActionEntries[i].defaultHwId);
|
||||||
engineKeyMap->addAction(act);
|
engineKeyMap->addAction(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action *act;
|
||||||
|
|
||||||
|
act = new Action("LCLK", _("Left Click"));
|
||||||
|
act->setLeftClickEvent();
|
||||||
|
engineKeyMap->addAction(act);
|
||||||
|
|
||||||
|
act = new Action("MCLK", _("Middle Click"));
|
||||||
|
act->setMiddleClickEvent();
|
||||||
|
engineKeyMap->addAction(act);
|
||||||
|
|
||||||
|
act = new Action("RCLK", _("Right Click"));
|
||||||
|
act->setRightClickEvent();
|
||||||
|
engineKeyMap->addAction(act);
|
||||||
|
|
||||||
return engineKeyMap;
|
return engineKeyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue