Added some code to toggle fullscreen and input grab for testing... --ryan.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 20 Dec 2002 03:37:28 +0000
changeset 562cb40b26523a5
parent 561 4bcf7dd06c47
child 563 04dcaf3da918
Added some code to toggle fullscreen and input grab for testing... --ryan.
test/threadwin.c
     1.1 --- a/test/threadwin.c	Sun Dec 15 09:09:31 2002 +0000
     1.2 +++ b/test/threadwin.c	Fri Dec 20 03:37:28 2002 +0000
     1.3 @@ -172,14 +172,37 @@
     1.4  			    /* We want to toggle visibility on buttonpress */
     1.5  			    case SDL_KEYDOWN:
     1.6  			    case SDL_KEYUP:
     1.7 +			    	printf("Key '%c' has been %s\n",
     1.8 +						events[i].key.keysym.unicode,
     1.9 +					(events[i].key.state == SDL_PRESSED) ?
    1.10 +						"pressed" : "released");
    1.11 +
    1.12  			    	/* Allow hitting <ESC> to quit the app */
    1.13  			    	if ( events[i].key.keysym.sym == SDLK_ESCAPE ) {
    1.14  			    		done = 1;
    1.15  			    	}
    1.16 -			    	printf("Key '%c' has been %s\n",
    1.17 -						events[i].key.keysym.unicode,
    1.18 -					(events[i].key.state == SDL_PRESSED) ?
    1.19 -						"pressed" : "released");
    1.20 +
    1.21 +					/* skip events now that aren't KEYUPs... */
    1.22 +					if (events[i].key.state == SDL_PRESSED)
    1.23 +						break;
    1.24 +
    1.25 +			    	if ( events[i].key.keysym.sym == SDLK_f ) {
    1.26 +						int rc = 0;
    1.27 +						printf("attempting to toggle fullscreen...\n");
    1.28 +						rc = SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
    1.29 +                        printf("SDL_WM_ToggleFullScreen returned %d.\n", rc);
    1.30 +			    	}
    1.31 +
    1.32 +			    	if ( events[i].key.keysym.sym == SDLK_g ) {
    1.33 +						SDL_GrabMode m;
    1.34 +						m = SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON ?
    1.35 +								SDL_GRAB_OFF : SDL_GRAB_ON;
    1.36 +						printf("attempting to toggle input grab to %s...\n",
    1.37 +                                m == SDL_GRAB_ON ? "ON" : "OFF");
    1.38 +                        SDL_WM_GrabInput(m);
    1.39 +						printf("attempt finished.\n");
    1.40 +			    	}
    1.41 +
    1.42  			    	break;
    1.43  			}
    1.44  		}