Created
December 1, 2018 16:55
-
-
Save Beuc/0805dda9083f0cecf3f5b8e6e4f8ea93 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
#ifdef __EMSCRIPTEN__ | |
#include <emscripten.h> | |
#endif | |
#include "SDL.h" | |
static int run = 1; | |
void loop() | |
{ | |
SDL_Event event; | |
while (SDL_PollEvent(&event)) { | |
switch(event.type) { | |
case SDL_MOUSEMOTION: | |
SDL_Log("mousemotion %i\n", event.motion.which); | |
break; | |
case SDL_MOUSEBUTTONDOWN: | |
SDL_Log("mousebuttondown %i\n", event.button.which); | |
break; | |
case SDL_MOUSEBUTTONUP: | |
SDL_Log("mousebuttonup %i\n", event.button.which); | |
break; | |
case SDL_FINGERMOTION: | |
SDL_Log("fingermotion %lli\n", event.tfinger.touchId); | |
break; | |
case SDL_FINGERDOWN: | |
SDL_Log("fingerdown %lli\n", event.tfinger.touchId); | |
break; | |
case SDL_FINGERUP: | |
SDL_Log("fingerup %lli\n", event.tfinger.touchId); | |
break; | |
case SDL_QUIT: | |
run = 0; | |
break; | |
} | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
SDL_Window *window; | |
if (SDL_Init(SDL_INIT_VIDEO) < 0) { | |
return (1); | |
} | |
window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); | |
SDL_EventState(SDL_FINGERDOWN, SDL_IGNORE); | |
SDL_EventState(SDL_FINGERUP, SDL_IGNORE); | |
SDL_EventState(SDL_FINGERMOTION, SDL_IGNORE); | |
#ifdef __EMSCRIPTEN__ | |
emscripten_set_main_loop(loop, 0, 1); | |
#else | |
while (run) loop(); | |
#endif | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment