aboutsummaryrefslogtreecommitdiff
path: root/backends/sdl
diff options
context:
space:
mode:
authorLars Persson2005-07-05 20:22:56 +0000
committerLars Persson2005-07-05 20:22:56 +0000
commitd4716a1fb525540f3395262d236df51ef70874f1 (patch)
tree7e5ddbbd1b7cfb28df2c25f041bf07d487bed662 /backends/sdl
parent57858a8757a5b3d96958ec856862886184082652 (diff)
downloadscummvm-rg350-d4716a1fb525540f3395262d236df51ef70874f1.tar.gz
scummvm-rg350-d4716a1fb525540f3395262d236df51ef70874f1.tar.bz2
scummvm-rg350-d4716a1fb525540f3395262d236df51ef70874f1.zip
* Start of generic key configuration support for ScummVM
* Moved KeyConfigDialog, key from WinCE to gui * Updated wince code to inherit and use new GUI::Keys and launch new dialog * New definition SMALL_SCREEN_DEVICE when keysdialog should be inittialized from options.cpp * Added new function to SDL\Events that handles key remapping. LINUPY & QTOPIA remapping moved to that function. SymbianOs.cpp overrides this function to enable key remapping to events * Compiled VC6++ project. This with warnings and errors, but NOT in the changed code. (SAGA,KYRA) * Compiled using WCE tools 3 for X86 target and running Scummvm in emulator to test * Compiled with UIQ target. The rest Symbian platforms might require further configuration to operate properly * Actor.h in Saga now compiles for default VC6 setting. * Aspect.cpp does not compile in VC6/WCE due to template problems with the kFastAndNiceAspectMode setting. * Changed order of creation of gamedetector and mainsystem in Main.cpp * If anything does not compile, or is totally out of order, please revert changes. svn-id: r18498
Diffstat (limited to 'backends/sdl')
-rw-r--r--backends/sdl/events.cpp147
-rw-r--r--backends/sdl/sdl-common.h2
2 files changed, 82 insertions, 67 deletions
diff --git a/backends/sdl/events.cpp b/backends/sdl/events.cpp
index cdc803409c..f195b11e86 100644
--- a/backends/sdl/events.cpp
+++ b/backends/sdl/events.cpp
@@ -189,7 +189,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
while(SDL_PollEvent(&ev)) {
switch(ev.type) {
- case SDL_KEYDOWN:
+ case SDL_KEYDOWN:{
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
// Alt-Return and Alt-Enter toggle full screen mode
@@ -331,78 +331,24 @@ bool OSystem_SDL::pollEvent(Event &event) {
}
break;
}
-
-#ifdef LINUPY
- // On Yopy map the End button to quit
- if ((ev.key.keysym.sym == 293)) {
- event.type = EVENT_QUIT;
- return true;
- }
- // Map menu key to f5 (scumm menu)
- if (ev.key.keysym.sym == 306) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_F5;
- event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
- return true;
- }
- // Map action key to action
- if (ev.key.keysym.sym == 291) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_TAB;
- event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
- return true;
- }
- // Map OK key to skip cinematic
- if (ev.key.keysym.sym == 292) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_ESCAPE;
- event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ const bool event_complete= remapKey(ev,event);
+
+ if(event_complete)
return true;
- }
-#endif
-#ifdef QTOPIA
- // quit on fn+backspace on zaurus
- if (ev.key.keysym.sym == 127) {
- event.type = EVENT_QUIT;
- return true;
- }
-
- // map menu key (f11) to f5 (scumm menu)
- if (ev.key.keysym.sym == SDLK_F11) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_F5;
- event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
- }
- // map center (space) to tab (default action )
- // I wanted to map the calendar button but the calendar comes up
- //
- else if (ev.key.keysym.sym == SDLK_SPACE) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_TAB;
- event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
- }
- // since we stole space (pause) above we'll rebind it to the tab key on the keyboard
- else if (ev.key.keysym.sym == SDLK_TAB) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_SPACE;
- event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
- } else {
- // let the events fall through if we didn't change them, this may not be the best way to
- // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though.
- // and yes i have an huge terminal size so i dont wrap soon enough.
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = ev.key.keysym.sym;
- event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
- }
-#else
event.type = EVENT_KEYDOWN;
event.kbd.keycode = ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
-#endif
+
return true;
-
+ }
case SDL_KEYUP:
+ {
+ const bool event_complete= remapKey(ev,event);
+
+ if(event_complete)
+ return true;
+
event.type = EVENT_KEYUP;
event.kbd.keycode = ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
@@ -415,7 +361,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
}
return true;
-
+ }
case SDL_MOUSEMOTION:
event.type = EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
@@ -571,4 +517,71 @@ bool OSystem_SDL::pollEvent(Event &event) {
return false;
}
+bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event){
+#ifdef LINUPY
+ // On Yopy map the End button to quit
+ if ((ev.key.keysym.sym == 293)) {
+ event.type = EVENT_QUIT;
+ return true;
+ }
+ // Map menu key to f5 (scumm menu)
+ if (ev.key.keysym.sym == 306) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ return true;
+ }
+ // Map action key to action
+ if (ev.key.keysym.sym == 291) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_TAB;
+ event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
+ return true;
+ }
+ // Map OK key to skip cinematic
+ if (ev.key.keysym.sym == 292) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ return true;
+ }
+#endif
+
+#ifdef QTOPIA
+ // quit on fn+backspace on zaurus
+ if (ev.key.keysym.sym == 127) {
+ event.type = EVENT_QUIT;
+ return true;
+ }
+
+ // map menu key (f11) to f5 (scumm menu)
+ if (ev.key.keysym.sym == SDLK_F11) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ // map center (space) to tab (default action )
+ // I wanted to map the calendar button but the calendar comes up
+ //
+ else if (ev.key.keysym.sym == SDLK_SPACE) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_TAB;
+ event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
+ }
+ // since we stole space (pause) above we'll rebind it to the tab key on the keyboard
+ else if (ev.key.keysym.sym == SDLK_TAB) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ } else {
+ // let the events fall through if we didn't change them, this may not be the best way to
+ // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though.
+ // and yes i have an huge terminal size so i dont wrap soon enough.
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+ }
+#endif
+ return false;
+}
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index 036a63fd05..87e2eb3a34 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -196,6 +196,8 @@ public:
#endif
protected:
+ virtual bool remapKey(SDL_Event &ev, Event &event);
+
bool _inited;
#ifdef USE_OSD