aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2003-10-05 15:04:25 +0000
committerMax Horn2003-10-05 15:04:25 +0000
commit2e27e74fb42847c781e61f8acf29f6658a34f292 (patch)
tree32e5a82b34056e955ee2681464cb81176e9f8726 /backends
parent16e489753174c27a5d38cde52922b920bd215e42 (diff)
downloadscummvm-rg350-2e27e74fb42847c781e61f8acf29f6658a34f292.tar.gz
scummvm-rg350-2e27e74fb42847c781e61f8acf29f6658a34f292.tar.bz2
scummvm-rg350-2e27e74fb42847c781e61f8acf29f6658a34f292.zip
implemented new 'nice' scaler hotkeys
svn-id: r10613
Diffstat (limited to 'backends')
-rw-r--r--backends/sdl/sdl-common.cpp89
1 files changed, 67 insertions, 22 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index 71ba2d07fc..576c803b0d 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -629,13 +629,13 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
#ifdef MACOSX
// On Macintosh', Cmd-Q quits
- if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym=='q') {
+ if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
event->event_code = EVENT_QUIT;
return true;
}
#else
// Ctrl-z and Alt-X quit
- if ((b == KBD_CTRL && ev.key.keysym.sym=='z') || (b == KBD_ALT && ev.key.keysym.sym=='x')) {
+ if ((b == KBD_CTRL && ev.key.keysym.sym == 'z') || (b == KBD_ALT && ev.key.keysym.sym == 'x')) {
event->event_code = EVENT_QUIT;
return true;
}
@@ -643,31 +643,76 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
// Ctr-Alt-<key> will change the GFX mode
if (b == (KBD_CTRL|KBD_ALT)) {
- const char keys[] = "1234567890cd";
- char *ptr;
+ static const int gfxModes[][4] = {
+ { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
+ { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 },
+ { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 },
+ { GFX_NORMAL, GFX_2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 },
+ { GFX_NORMAL, GFX_TV2X, -1, -1 },
+ { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }
+ };
+
+ // FIXME EVIL HACK: This shouldn't be a static int, rather it
+ // should be a member variable. Furthermore, it shouldn't be
+ // set in this code, rather it should be set by load_gfx_mode().
+ // But for now this quick&dirty hack works.
+ static int _scalerType = 0;
+ if (_mode != GFX_NORMAL) {
+ // Try to figure out which gfx mode "group" we are in
+ // This is just a temporary hack until the proper solution
+ // (i.e. code in load_gfx_mode()) is in effect.
+ for (int i = 0; i < ARRAYSIZE(gfxModes); i++) {
+ if (gfxModes[i][1] == _mode || gfxModes[i][2] == _mode) {
+ _scalerType = i;
+ break;
+ }
+ }
+ }
+
- ptr = strchr(keys, ev.key.keysym.sym);
- if (ptr != NULL) {
- Property prop;
+ Property prop;
+ int factor = _scaleFactor - 1;
- prop.gfx_mode = ptr - keys;
- property(PROP_SET_GFX_MODE, &prop);
+ // Ctr-Alt-a toggles aspect ratio correction
+ if (ev.key.keysym.sym == 'a') {
+ property(PROP_TOGGLE_ASPECT_RATIO, NULL);
break;
}
- }
- // Ctr-Alt-a will change aspect ratio
- if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='a') {
- property(PROP_TOGGLE_ASPECT_RATIO, NULL);
- break;
- }
-
- // Ctr-Alt-b will change bilinear filtering in OpenGL backend
- if (b == (KBD_CTRL|KBD_ALT) && ev.key.keysym.sym=='b') {
- Property prop;
- prop.gfx_mode = GFX_BILINEAR;
- property(PROP_SET_GFX_MODE, &prop);
- break;
+ // Ctr-Alt-b changes to bilinear filtering in the OpenGL backend
+ if (ev.key.keysym.sym == 'b') {
+ prop.gfx_mode = GFX_BILINEAR;
+ property(PROP_SET_GFX_MODE, &prop);
+ break;
+ }
+
+
+ // Increase/decrease the scale factor
+ // TODO: Shall we 'wrap around' here?
+ if (ev.key.keysym.sym == '+' || ev.key.keysym.sym == '-') {
+ factor += (ev.key.keysym.sym == '+' ? +1 : -1);
+ if (0 <= factor && factor < 4 && gfxModes[_scalerType][factor] >= 0) {
+ prop.gfx_mode = gfxModes[_scalerType][factor];
+ property(PROP_SET_GFX_MODE, &prop);
+ }
+ break;
+ }
+
+ if ('1' <= ev.key.keysym.sym && ev.key.keysym.sym <= '9') {
+ _scalerType = ev.key.keysym.sym - '1';
+ if (_scalerType >= ARRAYSIZE(gfxModes))
+ break;
+
+ while (gfxModes[_scalerType][factor] < 0) {
+ assert(factor > 0);
+ factor--;
+ }
+ prop.gfx_mode = gfxModes[_scalerType][factor];
+ property(PROP_SET_GFX_MODE, &prop);
+ break;
+ }
}
#ifdef QTOPIA