test/testkeys.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 07:32:26 +0000
branchSDL-1.2
changeset 4209 62e86ab81e3c
parent 1154 d93862a3d821
child 1662 782fd950bd46
child 1895 c121d94672cb
permissions -rw-r--r--
Fixed bug #570

SDL_SemWaitTimeout in src/thread/generic/SDL_syssem.c line 179 (SVN trunk):

--sem->count;

should be

if (retval == 0) {
--sem->count;
}

Without this, sem->count will underflow on timeout effectively breaking the
semaphore. It appears that the implementation has been wrong since the initial
revision.
slouken@0
     1
slouken@0
     2
/* Print out all the keysyms we have, just to verify them */
slouken@0
     3
slouken@0
     4
#include <stdio.h>
slouken@0
     5
#include <ctype.h>
icculus@1154
     6
#include <stdlib.h>
icculus@1154
     7
#include <string.h>
slouken@0
     8
slouken@0
     9
#include "SDL.h"
slouken@0
    10
slouken@0
    11
int main(int argc, char *argv[])
slouken@0
    12
{
slouken@0
    13
	SDLKey key;
slouken@0
    14
slouken@0
    15
	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
slouken@0
    16
		fprintf(stderr, "Couldn't initialize SDL: %s\n",
slouken@0
    17
							SDL_GetError());
slouken@0
    18
		exit(1);
slouken@0
    19
	}
slouken@0
    20
	for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
slouken@0
    21
		printf("Key #%d, \"%s\"\n", key, SDL_GetKeyName(key));
slouken@0
    22
	}
slouken@0
    23
	SDL_Quit();
slouken@0
    24
	return(0);
slouken@0
    25
}