Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
2 /* Simple program: Loop, watching keystrokes
3 Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
4 pump the event loop and catch keystrokes.
13 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
22 print_modifiers (void)
25 printf (" modifiers:");
26 mod = SDL_GetModState ();
31 if (mod & KMOD_LSHIFT)
33 if (mod & KMOD_RSHIFT)
56 PrintKey (SDL_keysym * sym, int pressed)
58 /* Print the keycode, name and state */
60 printf ("Key %s: %d-%s ", pressed ? "pressed" : "released",
61 sym->sym, SDL_GetKeyName (sym->sym));
63 printf ("Unknown Key (scancode = %d) %s ", sym->scancode,
64 pressed ? "pressed" : "released");
67 /* Print the translated character, if one exists */
69 /* Is it a control-character? */
70 if (sym->unicode < ' ') {
71 printf (" (^%c)", sym->unicode + '@');
74 printf (" (%c)", sym->unicode);
76 /* This is a Latin-1 program, so only show 8-bits */
77 if (!(sym->unicode & 0xFF00))
78 printf (" (%c)", sym->unicode);
80 printf (" (0x%X)", sym->unicode);
89 main (int argc, char *argv[])
96 if (SDL_Init (SDL_INIT_VIDEO) < 0) {
97 fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
101 videoflags = SDL_SWSURFACE;
104 if (argv[argc] && !strcmp (argv[argc], "-fullscreen")) {
105 videoflags |= SDL_FULLSCREEN;
107 fprintf (stderr, "Usage: %s [-fullscreen]\n", argv[0]);
112 /* Set 640x480 video mode */
113 if (SDL_SetVideoMode (640, 480, 0, videoflags) == NULL) {
114 fprintf (stderr, "Couldn't set 640x480 video mode: %s\n",
119 /* Enable UNICODE translation for keyboard input */
120 SDL_EnableUNICODE (1);
122 /* Enable auto repeat for keyboard input */
123 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY,
124 SDL_DEFAULT_REPEAT_INTERVAL);
126 /* Watch keystrokes */
129 /* Check for events */
130 SDL_WaitEvent (&event);
131 switch (event.type) {
133 PrintKey (&event.key.keysym, 1);
136 PrintKey (&event.key.keysym, 0);
138 case SDL_MOUSEBUTTONDOWN:
139 /* Any button press quits the app... */