Created
June 4, 2013 22:22
-
-
Save jorgenpt/5710142 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SDL.h> | |
int PollEvents() | |
{ | |
SDL_Event event; | |
while (SDL_PollEvent(&event)) | |
{ | |
switch (event.type) | |
{ | |
case SDL_QUIT: | |
return 1; | |
case SDL_WINDOWEVENT: | |
if (event.window.event == SDL_WINDOWEVENT_ENTER) | |
printf("Mouse focus gained\n"); | |
else if (event.window.event == SDL_WINDOWEVENT_LEAVE) | |
printf("Mouse focus lost\n"); | |
break; | |
case SDL_MOUSEMOTION: | |
printf("relative mm: %d, %d\n", event.motion.xrel, event.motion.yrel); | |
break; | |
default: | |
break; | |
} | |
} | |
return 0; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
SDL_Init(SDL_INIT_VIDEO); | |
SDL_Window *win = SDL_CreateWindow("Test", | |
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, | |
800, 600, 0 | |
); | |
SDL_ShowCursor(SDL_FALSE); | |
while (1) | |
{ | |
if (PollEvents()) | |
break; | |
} | |
SDL_DestroyWindow(win); | |
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment