Mercurial > sdl-ios-xcode
annotate test/testwm2.c @ 2268:4baee598306d
Date: Thu, 05 Jul 2007 14:02:33 -0700
From: Sam Lantinga
Subject: SDL 1.3 keyboard plan
After lots of discussion with Christian, this is what we came up with:
> So, to sum up...
> SDLK_* become the physical keys, starting at > (1<<21)
> We create a macro SDLK_INDEX(X)
> We have two functions SDL_GetLayoutKey(SDLKey) and SDL_GetKeyName()
> SDL_GetLayoutKey maps to UCS4 for printable characters, and SDLK* for
non-printable characters
> and does so based on the OS's current keyboard layout
> SDL_GetKeyName() handles both SDLK_* and UCS4, converting UCS4 to UTF-8 and
converting SDLK_* into our names, which are UTF-8 for printable characters.
> WASD folks use SDLK_*, and 'I' folks use SDL_GetLayoutKey(SDLK_*)
Here is the patch he came up with, and his e-mail about it:
Date: Fri, 17 Aug 2007 19:50:28 +0200
From: Christian Walther
Subject: Re: SDL 1.3 keyboard plan
> Sounds great, go ahead and send me a patch.
Here goes! Thanks for having a look. Don't hesitate to comment if
anything does not conform to your ideas.
One caveat: Committing this now may break compilability of some video
drivers - specifically, if they use any of the SDLK_* codes that were
obsoleted and moved into SDL_compat.h. I only tried Cocoa (which did
break, but is already fixed) and X11 (which didn't, but then its key
handling is #iffed out). If that's a problem, it may need to go into
a branch.
-Christian
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 19 Aug 2007 14:52:52 +0000 |
parents | 8055185ae4ed |
children | 9de326b3099c |
rev | line source |
---|---|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
2 #include <stdlib.h> |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
3 #include <stdio.h> |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
5 #include "common.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
7 static CommonState *state; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 quit(int rc) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 { |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
13 CommonQuit(state); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 exit(rc); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 main(int argc, char *argv[]) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 int i, done; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 SDL_Event event; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
23 /* Initialize test framework */ |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
24 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
25 if (!state) { |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
26 return 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 } |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
28 state->skip_renderer = SDL_TRUE; |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
29 for (i = 1; i < argc;) { |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
30 int consumed; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
32 consumed = CommonArg(state, i); |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
33 if (consumed == 0) { |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
34 consumed = -1; |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
35 } |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
36 if (consumed < 0) { |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
37 fprintf(stderr, "Usage: %s %s\n", argv[0], CommonUsage(state)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 quit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 } |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
40 i += consumed; |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
41 } |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
42 if (!CommonInit(state)) { |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
43 quit(2); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
46 /* Main render loop */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 done = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 while (!done) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 /* Check for events */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 while (SDL_PollEvent(&event)) { |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
51 CommonEvent(state, &event, &done); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 quit(0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 /* vi: set ts=4 sw=4 expandtab: */ |