All pastes #337918 Raw Edit

umouse.c

public c v1 · immutable
·published 2007-02-03 01:23 UTC
rendered paste body
/* * This program will unlock your pointer if it won't move anymore. This *  usually happens when a program crashes while the mouse was grabbed. * * Link with SDL.  (http://www.libsdl.org/) * *   gcc -o umouse umouse.c `sdl-config --cflags` `sdl-config --libs` * *  written by Ryan C. Gordon (icculus@lokigames.com) */#include <stdio.h>#include <stdlib.h>#include "SDL.h"void adjust_gamma(int argc, char **argv){    int i;    double gamma;    for (i = 0; i < argc - 1; i++)    {        if (strcasecmp(argv[i], "--gamma") == 0)        {            gamma = atof(argv[i + 1]);            if (gamma == 0.0)                fprintf(stderr, "Cowardly refusing to set gamma to 0.0...\n");            else            {                if (SDL_SetGamma(gamma,  gamma, gamma) == -1)                    fprintf(stderr, "SDL_SetGamma() failed.\n");            } // else        } // if    } // for} // adjust_gammaint main(int argc, char **argv){    SDL_Event event;    SDL_Init(SDL_INIT_VIDEO);    SDL_SetVideoMode(640, 480, 16, 0);    SDL_ShowCursor(0);    SDL_WM_GrabInput(SDL_GRAB_ON);    adjust_gamma(argc, argv);    SDL_PumpEvents();    SDL_WM_GrabInput(SDL_GRAB_OFF);    SDL_ShowCursor(1);    SDL_Quit();    return(0);} // main// end of umouse.c ...