[Gridflow-cvs] [svn] commit: r4931 - /trunk/src/sdl.cxx

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Jan 25 15:35:31 EST 2010


Author: matju
Date: Mon Jan 25 15:35:31 2010
New Revision: 4931

Log:
make custom symbol for unknown key instead of crashing

Modified:
    trunk/src/sdl.cxx

Modified: trunk/src/sdl.cxx
==============================================================================
--- trunk/src/sdl.cxx (original)
+++ trunk/src/sdl.cxx Mon Jan 25 15:35:31 2010
@@ -101,7 +101,10 @@
 			SETFLOAT(at+0,mousey);
 			SETFLOAT(at+1,mousex);
 			SETFLOAT(at+2,mousem);
-			SETSYMBOL(at+3,keyboard[event.key.keysym.sym]);
+			int k = event.key.keysym.sym;
+			if (k>=0 && k<SDLK_LAST)
+				SETSYMBOL(at+3,keyboard[k] ? keyboard[k] : symprintf("unknown_%d",k));
+			else RAISE("impossible key number %d, SDLK_LAST = %d",k,SDLK_LAST);
 			outlet_anything(instance->outlets[0],sel,4,at);
 		    } break;
 		    case SDL_MOUSEBUTTONDOWN: SDL_MOUSEBUTTONUP: {
@@ -171,8 +174,7 @@
 void FormatSDL::resize_window (int sx, int sy) {
 	dim = new Dim(sy,sx,3);
 	screen = SDL_SetVideoMode(sx,sy,0,SDL_SWSURFACE);
-	if (!screen)
-		RAISE("Can't switch to (%d,%d,%dbpp): %s", sy,sx,24, SDL_GetError());
+	if (!screen) RAISE("Can't switch to (%d,%d,%dbpp): %s", sy,sx,24, SDL_GetError());
 }
 
 GRID_INLET(0) {



More information about the Gridflow-cvs mailing list