test/testcursor.c
changeset 5405 64fa8526e1ce
parent 3111 14d32495a502
child 5420 180640c1ae53
equal deleted inserted replaced
5404:6717e01acbe0 5405:64fa8526e1ce
   145 int
   145 int
   146 main(int argc, char *argv[])
   146 main(int argc, char *argv[])
   147 {
   147 {
   148     SDL_Surface *screen;
   148     SDL_Surface *screen;
   149     SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
   149     SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
   150     SDL_Cursor *cursor[3];
   150     SDL_Cursor *cursor[4];
   151     int current;
   151     int current;
   152 
   152 
   153     /* Load the SDL library */
   153     /* Load the SDL library */
   154     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   154     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   155         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   155         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   187         fprintf(stderr, "Couldn't initialize test cursor: %s\n",
   187         fprintf(stderr, "Couldn't initialize test cursor: %s\n",
   188                 SDL_GetError());
   188                 SDL_GetError());
   189         SDL_Quit();
   189         SDL_Quit();
   190         return (1);
   190         return (1);
   191     }
   191     }
       
   192     cursor[3] = SDL_GetCursor();
   192 
   193 
   193     current = 0;
   194     current = 0;
   194     SDL_SetCursor(cursor[current]);
   195     SDL_SetCursor(cursor[current]);
   195 
   196 
   196     while (!quit) {
   197     while (!quit) {
   197         SDL_Event event;
   198         SDL_Event event;
   198         while (SDL_PollEvent(&event)) {
   199         while (SDL_PollEvent(&event)) {
   199             switch (event.type) {
   200             switch (event.type) {
   200             case SDL_MOUSEBUTTONDOWN:
   201             case SDL_MOUSEBUTTONDOWN:
   201                 current = (current + 1) % 3;
   202                 current = (current + 1) % SDL_arraysize(cursor);
   202                 SDL_SetCursor(cursor[current]);
   203                 SDL_SetCursor(cursor[current]);
   203                 break;
   204                 break;
   204             case SDL_KEYDOWN:
   205             case SDL_KEYDOWN:
   205                 if (event.key.keysym.sym == SDLK_ESCAPE) {
   206                 if (event.key.keysym.sym == SDLK_ESCAPE) {
   206                     quit = SDL_TRUE;
   207                     quit = SDL_TRUE;
   220     SDL_FreeCursor(cursor[2]);
   221     SDL_FreeCursor(cursor[2]);
   221 
   222 
   222     SDL_Quit();
   223     SDL_Quit();
   223     return (0);
   224     return (0);
   224 }
   225 }
       
   226 
       
   227 /* vi: set ts=4 sw=4 expandtab: */