test/testwm.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 03 Jun 2011 16:03:10 -0400
changeset 5547 4ccecd0901e2
parent 5535 96594ac5fd1a
permissions -rw-r--r--
Assert code's stdio interface was reading from the wrong variable.

Thanks to Frank Zago for the catch.
slouken@5535
     1
/*
slouken@5535
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@0
    12
slouken@0
    13
/* Test out the window manager interaction functions */
slouken@0
    14
slouken@0
    15
#include <stdio.h>
slouken@0
    16
#include <stdlib.h>
slouken@0
    17
#include <string.h>
slouken@0
    18
slouken@0
    19
#include "SDL.h"
slouken@0
    20
slouken@0
    21
/* Is the cursor visible? */
slouken@0
    22
static int visible = 1;
slouken@0
    23
slouken@1895
    24
static Uint8 video_bpp;
slouken@826
    25
static Uint32 video_flags;
slouken@826
    26
icculus@1151
    27
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
slouken@1895
    28
static void
slouken@1895
    29
quit(int rc)
icculus@1151
    30
{
slouken@1895
    31
    SDL_Quit();
slouken@1895
    32
    exit(rc);
icculus@1151
    33
}
icculus@1151
    34
slouken@1895
    35
int
slouken@1895
    36
SetVideoMode(int w, int h)
slouken@826
    37
{
slouken@1895
    38
    SDL_Surface *screen;
slouken@1895
    39
    int i;
slouken@1895
    40
    Uint8 *buffer;
slouken@1895
    41
    SDL_Color palette[256];
slouken@826
    42
slouken@1895
    43
    screen = SDL_SetVideoMode(w, h, video_bpp, video_flags);
slouken@1895
    44
    if (screen == NULL) {
slouken@1895
    45
        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
slouken@1895
    46
                w, h, video_bpp, SDL_GetError());
slouken@1895
    47
        return (-1);
slouken@1895
    48
    }
slouken@1895
    49
    printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
slouken@1895
    50
           "fullscreen" : "windowed");
slouken@826
    51
slouken@1895
    52
    /* Set the surface pixels and refresh! */
slouken@1895
    53
    for (i = 0; i < 256; ++i) {
slouken@1895
    54
        palette[i].r = 255 - i;
slouken@1895
    55
        palette[i].g = 255 - i;
slouken@1895
    56
        palette[i].b = 255 - i;
slouken@1895
    57
    }
slouken@1895
    58
    SDL_SetColors(screen, palette, 0, 256);
slouken@1895
    59
    if (SDL_LockSurface(screen) < 0) {
slouken@1895
    60
        fprintf(stderr, "Couldn't lock display surface: %s\n",
slouken@1895
    61
                SDL_GetError());
slouken@1895
    62
        return (-1);
slouken@1895
    63
    }
slouken@1895
    64
    buffer = (Uint8 *) screen->pixels;
slouken@1895
    65
    for (i = 0; i < screen->h; ++i) {
slouken@1895
    66
        memset(buffer, (i * 255) / screen->h,
slouken@1895
    67
               screen->w * screen->format->BytesPerPixel);
slouken@1895
    68
        buffer += screen->pitch;
slouken@1895
    69
    }
slouken@1895
    70
    SDL_UnlockSurface(screen);
slouken@1895
    71
    SDL_UpdateRect(screen, 0, 0, 0, 0);
slouken@826
    72
slouken@1895
    73
    return (0);
slouken@826
    74
}
slouken@826
    75
slouken@1895
    76
SDL_Surface *
slouken@1895
    77
LoadIconSurface(char *file, Uint8 ** maskp)
slouken@0
    78
{
slouken@1895
    79
    SDL_Surface *icon;
slouken@1895
    80
    Uint8 *pixels;
slouken@1895
    81
    Uint8 *mask;
slouken@1895
    82
    int mlen, i, j;
slouken@0
    83
slouken@1895
    84
    *maskp = NULL;
slouken@0
    85
slouken@1895
    86
    /* Load the icon surface */
slouken@1895
    87
    icon = SDL_LoadBMP(file);
slouken@1895
    88
    if (icon == NULL) {
slouken@1895
    89
        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
slouken@1895
    90
        return (NULL);
slouken@1895
    91
    }
slouken@0
    92
slouken@1895
    93
    /* Check width and height 
slouken@1895
    94
       if ( (icon->w%8) != 0 ) {
slouken@1895
    95
       fprintf(stderr, "Icon width must be a multiple of 8!\n");
slouken@1895
    96
       SDL_FreeSurface(icon);
slouken@1895
    97
       return(NULL);
slouken@1895
    98
       }
slouken@1895
    99
     */
slouken@0
   100
slouken@0
   101
slouken@1895
   102
    if (icon->format->palette == NULL) {
slouken@1895
   103
        fprintf(stderr, "Icon must have a palette!\n");
slouken@1895
   104
        SDL_FreeSurface(icon);
slouken@1895
   105
        return (NULL);
slouken@1895
   106
    }
slouken@1895
   107
slouken@1895
   108
    /* Set the colorkey */
slouken@1895
   109
    SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels));
slouken@1895
   110
slouken@1895
   111
    /* Create the mask */
slouken@1895
   112
    pixels = (Uint8 *) icon->pixels;
slouken@1895
   113
    printf("Transparent pixel: (%d,%d,%d)\n",
slouken@1895
   114
           icon->format->palette->colors[*pixels].r,
slouken@1895
   115
           icon->format->palette->colors[*pixels].g,
slouken@1895
   116
           icon->format->palette->colors[*pixels].b);
slouken@1895
   117
    mlen = (icon->w * icon->h + 7) / 8;
slouken@1895
   118
    mask = (Uint8 *) malloc(mlen);
slouken@1895
   119
    if (mask == NULL) {
slouken@1895
   120
        fprintf(stderr, "Out of memory!\n");
slouken@1895
   121
        SDL_FreeSurface(icon);
slouken@1895
   122
        return (NULL);
slouken@1895
   123
    }
slouken@1895
   124
    memset(mask, 0, mlen);
slouken@1895
   125
    for (i = 0; i < icon->h; i++)
slouken@1895
   126
        for (j = 0; j < icon->w; j++) {
slouken@591
   127
            int pindex = i * icon->pitch + j;
slouken@591
   128
            int mindex = i * icon->w + j;
slouken@1895
   129
            if (pixels[pindex] != *pixels)
slouken@1895
   130
                mask[mindex >> 3] |= 1 << (7 - (mindex & 7));
slouken@591
   131
        }
slouken@1895
   132
    *maskp = mask;
slouken@1895
   133
    return (icon);
slouken@0
   134
}
slouken@0
   135
slouken@1895
   136
void
slouken@1895
   137
HotKey_ToggleFullScreen(void)
slouken@0
   138
{
slouken@1895
   139
    SDL_Surface *screen;
slouken@0
   140
slouken@1895
   141
    screen = SDL_GetVideoSurface();
slouken@1895
   142
    if (SDL_WM_ToggleFullScreen(screen)) {
slouken@1895
   143
        printf("Toggled fullscreen mode - now %s\n",
slouken@1895
   144
               (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
slouken@1895
   145
    } else {
slouken@1895
   146
        printf("Unable to toggle fullscreen mode\n");
slouken@1895
   147
        video_flags ^= SDL_FULLSCREEN;
slouken@1895
   148
        SetVideoMode(screen->w, screen->h);
slouken@1895
   149
    }
slouken@0
   150
}
slouken@0
   151
slouken@1895
   152
void
slouken@1895
   153
HotKey_ToggleGrab(void)
slouken@0
   154
{
slouken@1895
   155
    SDL_GrabMode mode;
slouken@0
   156
slouken@1895
   157
    printf("Ctrl-G: toggling input grab!\n");
slouken@1895
   158
    mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
slouken@1895
   159
    if (mode == SDL_GRAB_ON) {
slouken@1895
   160
        printf("Grab was on\n");
slouken@1895
   161
    } else {
slouken@1895
   162
        printf("Grab was off\n");
slouken@1895
   163
    }
slouken@1895
   164
    mode = SDL_WM_GrabInput(mode ? SDL_GRAB_OFF : SDL_GRAB_ON);
slouken@1895
   165
    if (mode == SDL_GRAB_ON) {
slouken@1895
   166
        printf("Grab is now on\n");
slouken@1895
   167
    } else {
slouken@1895
   168
        printf("Grab is now off\n");
slouken@1895
   169
    }
slouken@0
   170
}
slouken@0
   171
slouken@1895
   172
void
slouken@1895
   173
HotKey_Iconify(void)
slouken@0
   174
{
slouken@1895
   175
    printf("Ctrl-Z: iconifying window!\n");
slouken@1895
   176
    SDL_WM_IconifyWindow();
slouken@0
   177
}
slouken@0
   178
slouken@1895
   179
void
slouken@1895
   180
HotKey_Quit(void)
slouken@0
   181
{
slouken@1895
   182
    SDL_Event event;
slouken@0
   183
slouken@1895
   184
    printf("Posting internal quit request\n");
slouken@1895
   185
    event.type = SDL_USEREVENT;
slouken@1895
   186
    SDL_PushEvent(&event);
slouken@0
   187
}
slouken@0
   188
icculus@3634
   189
icculus@3634
   190
static void
icculus@3634
   191
print_modifiers(void)
icculus@3634
   192
{
icculus@3634
   193
    int mod;
icculus@3634
   194
    printf(" modifiers:");
icculus@3634
   195
    mod = SDL_GetModState();
icculus@3634
   196
    if(!mod) {
icculus@3634
   197
        printf(" (none)");
icculus@3634
   198
        return;
icculus@3634
   199
    }
icculus@3634
   200
    if(mod & KMOD_LSHIFT)
icculus@3634
   201
        printf(" LSHIFT");
icculus@3634
   202
    if(mod & KMOD_RSHIFT)
icculus@3634
   203
        printf(" RSHIFT");
icculus@3634
   204
    if(mod & KMOD_LCTRL)
icculus@3634
   205
        printf(" LCTRL");
icculus@3634
   206
    if(mod & KMOD_RCTRL)
icculus@3634
   207
        printf(" RCTRL");
icculus@3634
   208
    if(mod & KMOD_LALT)
icculus@3634
   209
        printf(" LALT");
icculus@3634
   210
    if(mod & KMOD_RALT)
icculus@3634
   211
        printf(" RALT");
icculus@3634
   212
    if(mod & KMOD_LMETA)
icculus@3634
   213
        printf(" LMETA");
icculus@3634
   214
    if(mod & KMOD_RMETA)
icculus@3634
   215
        printf(" RMETA");
icculus@3634
   216
    if(mod & KMOD_NUM)
icculus@3634
   217
        printf(" NUM");
icculus@3634
   218
    if(mod & KMOD_CAPS)
icculus@3634
   219
        printf(" CAPS");
icculus@3634
   220
    if(mod & KMOD_MODE)
icculus@3634
   221
        printf(" MODE");
icculus@3634
   222
}
icculus@3634
   223
slouken@5218
   224
static void PrintKey(const SDL_Keysym *sym, int pressed)
icculus@3634
   225
{
icculus@3634
   226
    /* Print the keycode, name and state */
icculus@3634
   227
    if ( sym->sym ) {
icculus@3634
   228
        printf("Key %s:  %d-%s ", pressed ?  "pressed" : "released",
icculus@3634
   229
                    sym->sym, SDL_GetKeyName(sym->sym));
icculus@3634
   230
    } else {
icculus@3634
   231
        printf("Unknown Key (scancode = %d) %s ", sym->scancode,
icculus@3634
   232
                    pressed ?  "pressed" : "released");
icculus@3634
   233
    }
icculus@3634
   234
icculus@3634
   235
    /* Print the translated character, if one exists */
icculus@3634
   236
    if ( sym->unicode ) {
icculus@3634
   237
        /* Is it a control-character? */
icculus@3634
   238
        if ( sym->unicode < ' ' ) {
icculus@3634
   239
            printf(" (^%c)", sym->unicode+'@');
icculus@3634
   240
        } else {
icculus@3634
   241
#ifdef UNICODE
icculus@3634
   242
            printf(" (%c)", sym->unicode);
icculus@3634
   243
#else
icculus@3634
   244
            /* This is a Latin-1 program, so only show 8-bits */
icculus@3634
   245
            if ( !(sym->unicode & 0xFF00) )
icculus@3634
   246
                printf(" (%c)", sym->unicode);
icculus@3634
   247
            else
icculus@3634
   248
                printf(" (0x%X)", sym->unicode);
icculus@3634
   249
#endif
icculus@3634
   250
        }
icculus@3634
   251
    }
icculus@3634
   252
    print_modifiers();
icculus@3634
   253
    printf("\n");
icculus@3634
   254
}
icculus@3634
   255
icculus@3634
   256
bob@2185
   257
static int (SDLCALL * old_filterfunc) (void *, SDL_Event *);
slouken@1895
   258
static void *old_filterdata;
slouken@1895
   259
slouken@1895
   260
int SDLCALL
slouken@1895
   261
FilterEvents(void *userdata, SDL_Event * event)
slouken@0
   262
{
slouken@1895
   263
    static int reallyquit = 0;
slouken@0
   264
slouken@1895
   265
    if (old_filterfunc) {
slouken@1895
   266
        old_filterfunc(old_filterdata, event);
slouken@1895
   267
    }
slouken@0
   268
slouken@1895
   269
    switch (event->type) {
slouken@0
   270
slouken@1895
   271
    case SDL_ACTIVEEVENT:
slouken@1895
   272
        /* See what happened */
slouken@1895
   273
        printf("App %s ", event->active.gain ? "gained" : "lost");
slouken@1895
   274
        if (event->active.state & SDL_APPACTIVE)
slouken@1895
   275
            printf("active ");
slouken@1895
   276
        if (event->active.state & SDL_APPINPUTFOCUS)
slouken@1895
   277
            printf("input ");
slouken@1895
   278
        if (event->active.state & SDL_APPMOUSEFOCUS)
slouken@1895
   279
            printf("mouse ");
slouken@1895
   280
        printf("focus\n");
slouken@0
   281
slouken@1895
   282
        /* See if we are iconified or restored */
slouken@1895
   283
        if (event->active.state & SDL_APPACTIVE) {
slouken@1895
   284
            printf("App has been %s\n",
slouken@1895
   285
                   event->active.gain ? "restored" : "iconified");
slouken@1895
   286
        }
slouken@1895
   287
        return (0);
slouken@0
   288
slouken@1895
   289
        /* We want to toggle visibility on buttonpress */
slouken@1895
   290
    case SDL_MOUSEBUTTONDOWN:
slouken@1895
   291
    case SDL_MOUSEBUTTONUP:
slouken@1895
   292
        if (event->button.state == SDL_PRESSED) {
slouken@1895
   293
            visible = !visible;
slouken@1895
   294
            SDL_ShowCursor(visible);
slouken@1895
   295
        }
slouken@3545
   296
        printf("Mouse button %d has been %s at %d,%d\n",
slouken@1895
   297
               event->button.button,
slouken@3545
   298
               (event->button.state == SDL_PRESSED) ? "pressed" : "released",
slouken@3545
   299
               event->button.x, event->button.y);
slouken@1895
   300
        return (0);
slouken@1895
   301
slouken@1895
   302
        /* Show relative mouse motion */
slouken@1895
   303
    case SDL_MOUSEMOTION:
slouken@0
   304
#if 0
slouken@1895
   305
        printf("Mouse motion: {%d,%d} (%d,%d)\n",
slouken@1895
   306
               event->motion.x, event->motion.y,
slouken@1895
   307
               event->motion.xrel, event->motion.yrel);
slouken@0
   308
#endif
slouken@1895
   309
        return (0);
slouken@0
   310
slouken@1895
   311
    case SDL_KEYDOWN:
icculus@3634
   312
        PrintKey(&event->key.keysym, 1);
slouken@1895
   313
        if (event->key.keysym.sym == SDLK_ESCAPE) {
slouken@1895
   314
            HotKey_Quit();
slouken@1895
   315
        }
slouken@1895
   316
        if ((event->key.keysym.sym == SDLK_g) &&
slouken@1895
   317
            (event->key.keysym.mod & KMOD_CTRL)) {
slouken@1895
   318
            HotKey_ToggleGrab();
slouken@1895
   319
        }
slouken@1895
   320
        if ((event->key.keysym.sym == SDLK_z) &&
slouken@1895
   321
            (event->key.keysym.mod & KMOD_CTRL)) {
slouken@1895
   322
            HotKey_Iconify();
slouken@1895
   323
        }
slouken@1895
   324
        if ((event->key.keysym.sym == SDLK_RETURN) &&
slouken@4942
   325
            (event->key.keysym.mod & (KMOD_ALT|KMOD_META))) {
slouken@1895
   326
            HotKey_ToggleFullScreen();
slouken@1895
   327
        }
slouken@1895
   328
        return (0);
slouken@0
   329
icculus@3634
   330
	case SDL_KEYUP:
icculus@3634
   331
		PrintKey(&event->key.keysym, 0);
icculus@3634
   332
		return(0);
icculus@3634
   333
slouken@1895
   334
        /* Pass the video resize event through .. */
slouken@1895
   335
    case SDL_VIDEORESIZE:
slouken@1895
   336
        return (1);
slouken@0
   337
slouken@1895
   338
        /* This is important!  Queue it if we want to quit. */
slouken@1895
   339
    case SDL_QUIT:
slouken@1895
   340
        if (!reallyquit) {
slouken@1895
   341
            reallyquit = 1;
slouken@1895
   342
            printf("Quit requested\n");
slouken@1895
   343
            return (0);
slouken@1895
   344
        }
slouken@1895
   345
        printf("Quit demanded\n");
slouken@1895
   346
        return (1);
slouken@0
   347
slouken@1895
   348
        /* This will never happen because events queued directly
slouken@1895
   349
           to the event queue are not filtered.
slouken@1895
   350
         */
slouken@1895
   351
    case SDL_USEREVENT:
slouken@1895
   352
        return (1);
slouken@0
   353
slouken@1895
   354
        /* Drop all other events */
slouken@1895
   355
    default:
slouken@1895
   356
        return (0);
slouken@1895
   357
    }
slouken@0
   358
}
slouken@0
   359
slouken@1895
   360
int
slouken@1895
   361
main(int argc, char *argv[])
slouken@0
   362
{
slouken@1895
   363
    SDL_Event event;
slouken@2060
   364
    const char *title;
slouken@1895
   365
    SDL_Surface *icon;
slouken@1895
   366
    Uint8 *icon_mask;
slouken@1895
   367
    int parsed;
slouken@1895
   368
    int w, h;
slouken@0
   369
slouken@1895
   370
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
slouken@1895
   371
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
slouken@1895
   372
        return (1);
slouken@1895
   373
    }
slouken@0
   374
slouken@1895
   375
    /* Check command line arguments */
slouken@1895
   376
    w = 640;
slouken@1895
   377
    h = 480;
slouken@1895
   378
    video_bpp = 8;
slouken@1895
   379
    video_flags = SDL_SWSURFACE;
slouken@1895
   380
    parsed = 1;
slouken@1895
   381
    while (parsed) {
slouken@1895
   382
        if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) {
slouken@1895
   383
            video_flags |= SDL_FULLSCREEN;
slouken@1895
   384
            argc -= 1;
slouken@1895
   385
            argv += 1;
slouken@1895
   386
        } else if ((argc >= 2) && (strcmp(argv[1], "-resize") == 0)) {
slouken@1895
   387
            video_flags |= SDL_RESIZABLE;
slouken@1895
   388
            argc -= 1;
slouken@1895
   389
            argv += 1;
slouken@1895
   390
        } else if ((argc >= 2) && (strcmp(argv[1], "-noframe") == 0)) {
slouken@1895
   391
            video_flags |= SDL_NOFRAME;
slouken@1895
   392
            argc -= 1;
slouken@1895
   393
            argv += 1;
slouken@1895
   394
        } else if ((argc >= 3) && (strcmp(argv[1], "-width") == 0)) {
slouken@1895
   395
            w = atoi(argv[2]);
slouken@1895
   396
            argc -= 2;
slouken@1895
   397
            argv += 2;
slouken@1895
   398
        } else if ((argc >= 3) && (strcmp(argv[1], "-height") == 0)) {
slouken@1895
   399
            h = atoi(argv[2]);
slouken@1895
   400
            argc -= 2;
slouken@1895
   401
            argv += 2;
slouken@1895
   402
        } else if ((argc >= 3) && (strcmp(argv[1], "-bpp") == 0)) {
slouken@1895
   403
            video_bpp = atoi(argv[2]);
slouken@1895
   404
            argc -= 2;
slouken@1895
   405
            argv += 2;
slouken@1895
   406
        } else {
slouken@1895
   407
            parsed = 0;
slouken@1895
   408
        }
slouken@1895
   409
    }
slouken@0
   410
slouken@1895
   411
    /* Set the icon -- this must be done before the first mode set */
slouken@1895
   412
    icon = LoadIconSurface("icon.bmp", &icon_mask);
slouken@1895
   413
    if (icon != NULL) {
slouken@1895
   414
        SDL_WM_SetIcon(icon, icon_mask);
slouken@1895
   415
    }
slouken@1895
   416
    if (icon_mask != NULL)
slouken@1895
   417
        free(icon_mask);
slouken@0
   418
slouken@1895
   419
    /* Set the title bar */
slouken@1895
   420
    if (argv[1] == NULL)
slouken@1895
   421
        title = "Testing  1.. 2.. 3...";
slouken@1895
   422
    else
slouken@1895
   423
        title = argv[1];
slouken@1895
   424
    SDL_WM_SetCaption(title, "testwm");
slouken@0
   425
slouken@1895
   426
    /* See if it's really set */
slouken@1895
   427
    SDL_WM_GetCaption(&title, NULL);
slouken@1895
   428
    if (title)
slouken@1895
   429
        printf("Title was set to: %s\n", title);
slouken@1895
   430
    else
slouken@1895
   431
        printf("No window title was set!\n");
slouken@0
   432
slouken@1895
   433
    /* Initialize the display */
slouken@1895
   434
    if (SetVideoMode(w, h) < 0) {
slouken@1895
   435
        quit(1);
slouken@1895
   436
    }
slouken@0
   437
slouken@1895
   438
    /* Set an event filter that discards everything but QUIT */
slouken@1895
   439
    SDL_GetEventFilter(&old_filterfunc, &old_filterdata);
slouken@1895
   440
    SDL_SetEventFilter(FilterEvents, NULL);
slouken@0
   441
slouken@1895
   442
    /* Loop, waiting for QUIT */
slouken@1895
   443
    while (SDL_WaitEvent(&event)) {
slouken@1895
   444
        switch (event.type) {
slouken@1895
   445
        case SDL_VIDEORESIZE:
slouken@1895
   446
            printf("Got a resize event: %dx%d\n",
slouken@1895
   447
                   event.resize.w, event.resize.h);
slouken@1895
   448
            SetVideoMode(event.resize.w, event.resize.h);
slouken@1895
   449
            break;
slouken@1895
   450
        case SDL_USEREVENT:
slouken@1895
   451
            printf("Handling internal quit request\n");
slouken@1895
   452
            /* Fall through to the quit handler */
slouken@1895
   453
        case SDL_QUIT:
slouken@1895
   454
            printf("Bye bye..\n");
slouken@1895
   455
            quit(0);
slouken@1895
   456
        default:
slouken@1895
   457
            /* This should never happen */
slouken@1895
   458
            printf("Warning: Event %d wasn't filtered\n", event.type);
slouken@1895
   459
            break;
slouken@1895
   460
        }
slouken@1895
   461
    }
slouken@1895
   462
    printf("SDL_WaitEvent() error: %s\n", SDL_GetError());
slouken@1895
   463
    SDL_Quit();
slouken@1895
   464
    return (255);
slouken@0
   465
}