#include int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen; // initial video setup screen = SDL_SetVideoMode (640, 480, 0, 0); // resize screen in y direction screen = SDL_SetVideoMode(640, 640, 0, 0); // color the test area, created on the 2nd SDL_SetVideoMode Uint32 blue_col = SDL_MapRGB(screen->format, 0, 0, 255); SDL_Rect test_area; test_area.x = 0; test_area.y = 480; test_area.w = 639; test_area.h = 159; SDL_FillRect(screen, &test_area, blue_col); SDL_Flip(screen); int mouse_x; int mouse_y; int mouse_x_new; int mouse_y_new; SDL_Event event; int quit = 0; while(!quit) { SDL_GetMouseState(&mouse_x_new, &mouse_y_new); // if the mouse has moved, write the position to stdout if (mouse_x_new != mouse_x || mouse_y_new != mouse_y) { mouse_x = mouse_x_new; mouse_y = mouse_y_new; fprintf(stdout, "%d,%d\n", mouse_x, mouse_y); } // use windowed X to quit the test while (SDL_PollEvent (&event)) { if (event.type == SDL_QUIT) { quit = 1; } } } SDL_Quit(); return 0; }