Skip to content

Instantly share code, notes, and snippets.

@yashi
Created September 3, 2014 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashi/dba19aa01b8919ce533a to your computer and use it in GitHub Desktop.
Save yashi/dba19aa01b8919ce533a to your computer and use it in GitHub Desktop.
#include <SDL.h>
int main()
{
int ret;
SDL_Window *w;
SDL_Event e;
int done = 0;
ret = SDL_Init(SDL_INIT_VIDEO);
if (ret < 0) {
printf("error: %s\n", SDL_GetError());
}
w = SDL_CreateWindow("SDL Test Window",
100, 100, 200, 100,
SDL_WINDOW_RESIZABLE);
if (!w) {
printf("error: window creation failed\n");
return -1;
}
while (!done) {
ret = SDL_WaitEvent(&e);
if (ret) {
printf("ev: %d: ", e.type);
switch (e.type) {
case SDL_QUIT:
done = 1;
break;
case SDL_MOUSEBUTTONDOWN:
printf("wheel: id:%u, w:%u, b:%u, s:%u, c:%u, x:%d, y%d",
e.button.windowID,
e.button.which,
e.button.button,
e.button.state,
e.button.clicks,
e.button.x,
e.button.y);
break;
case SDL_MOUSEBUTTONUP:
break;
case SDL_MOUSEWHEEL:
printf("wheel: id:%u, w:%u, x:%d, y%d",
e.wheel.windowID,
e.wheel.which,
e.wheel.x,
e.wheel.y);
break;
default:
break;
}
printf("\n");
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment