[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.93,1.94

Max Horn fingolfin at users.sourceforge.net
Sun Oct 5 08:05:10 CEST 2003


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv21387/backends/sdl

Modified Files:
	sdl-common.cpp 
Log Message:
implemented new 'nice' scaler hotkeys

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- sdl-common.cpp	4 Oct 2003 23:49:04 -0000	1.93
+++ sdl-common.cpp	5 Oct 2003 15:04:25 -0000	1.94
@@ -629,13 +629,13 @@
 
 #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 @@
 
 			// 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 }
+					};
 
-				ptr = strchr(keys, ev.key.keysym.sym);
-				if (ptr != NULL) {
-					Property prop;
+				// 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;
+						}
+					}
+				}
+				
 
-					prop.gfx_mode = ptr - keys;
-					property(PROP_SET_GFX_MODE, &prop);
+				Property prop;
+				int factor = _scaleFactor - 1;
+
+				// 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 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;
+				}
+				
 
-			// 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;
+				// 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





More information about the Scummvm-git-logs mailing list