Mercurial > sdl-ios-xcode
annotate test/testerror.c @ 1282:217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
From: jimrandomh
Subject: [SDL] Re: Modifier keys pressed during initialization stick
I wrote a simple test program which initializes SDL, prints the SDL
version number, then prints any keydown and keyup events with their
modifiers. (Source code below). Compilation was done using Visual
Studio 6, release mode.
My test sequence was:
Start a command prompt. Type the name of the test program.
shift down
enter down (program starts)
Wait for window to appear
enter up
shift up
spacebar down
spacebar up
Under Windows 98, the output was correct:
SDL 1.2.8
left shift down
shift-return down
shift-return up
left shift up
space down
space up
Under Windows 2000 and under Windows XP, the output was:
SDL 1.2.8
shift-space down
shift-space up
Since shift was not held at the time space was pressed, this is
incorrect. Similar results were observed with launching in different
ways (including double-clicking in Windows Explorer), so it does not
depend on the launching terminal.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 29 Jan 2006 07:57:13 +0000 |
parents | be9c9c8f6d53 |
children | 14717b52abc0 |
rev | line source |
---|---|
0 | 1 |
2 /* Simple test of the SDL threading code and error handling */ | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <signal.h> | |
7 | |
8 #include "SDL.h" | |
9 #include "SDL_thread.h" | |
10 | |
11 static int alive = 0; | |
12 | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
13 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
14 static void quit(int rc) |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
15 { |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
16 SDL_Quit(); |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
17 exit(rc); |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
18 } |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
19 |
0 | 20 int ThreadFunc(void *data) |
21 { | |
22 /* Set the child thread error string */ | |
23 SDL_SetError("Thread %s (%d) had a problem: %s", | |
24 (char *)data, SDL_ThreadID(), "nevermind"); | |
25 while ( alive ) { | |
26 printf("Thread '%s' is alive!\n", (char *)data); | |
27 SDL_Delay(1*1000); | |
28 } | |
29 printf("Child thread error string: %s\n", SDL_GetError()); | |
30 return(0); | |
31 } | |
32 | |
33 int main(int argc, char *argv[]) | |
34 { | |
35 SDL_Thread *thread; | |
36 | |
37 /* Load the SDL library */ | |
38 if ( SDL_Init(0) < 0 ) { | |
39 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
40 return(1); |
0 | 41 } |
42 | |
43 /* Set the error value for the main thread */ | |
44 SDL_SetError("No worries"); | |
45 | |
46 alive = 1; | |
47 thread = SDL_CreateThread(ThreadFunc, "#1"); | |
48 if ( thread == NULL ) { | |
49 fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
50 quit(1); |
0 | 51 } |
52 SDL_Delay(5*1000); | |
53 printf("Waiting for thread #1\n"); | |
54 alive = 0; | |
55 SDL_WaitThread(thread, NULL); | |
56 | |
57 printf("Main thread error string: %s\n", SDL_GetError()); | |
58 | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
59 SDL_Quit(); |
0 | 60 return(0); |
61 } |