22 #include <emscripten/emscripten.h>
25 #ifndef SDL_JOYSTICK_DISABLED
28 #define SCREEN_WIDTH 320
29 #define SCREEN_HEIGHT 480
31 #define SCREEN_WIDTH 640
32 #define SCREEN_HEIGHT 480
51 SDL_Joystick *joystick = (SDL_Joystick *)arg;
66 SDL_Log(
"Joystick %d axis %d value: %d\n",
71 SDL_Log(
"Joystick %d hat %d value:",
86 SDL_Log(
"Joystick %d ball %d delta: (%d,%d)\n",
91 SDL_Log(
"Joystick %d button %d down\n",
99 SDL_Log(
"Joystick %d button %d up\n",
183 #ifdef __EMSCRIPTEN__
185 emscripten_cancel_main_loop();
203 if (window ==
NULL) {
209 if (screen ==
NULL) {
223 name ? name :
"Unknown Joystick");
224 SDL_Log(
"Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
229 #ifdef __EMSCRIPTEN__
230 emscripten_set_main_loop_arg(
loop, joystick, 0, 1);
248 SDL_Joystick *joystick;
265 SDL_Log(
"Joystick %d: %s\n", i, name ? name :
"Unknown Joystick");
267 if (joystick ==
NULL) {
274 guid,
sizeof (guid));
277 type =
"Game Controller";
283 type =
"Arcade Stick";
286 type =
"Flight Stick";
319 #if defined(__ANDROID__) || defined(__IPHONEOS__)
328 #if defined(__ANDROID__) || defined(__IPHONEOS__)
331 device = atoi(argv[1]);
334 if (joystick !=
NULL) {
338 while ( keepGoing ) {
339 if (joystick ==
NULL) {
340 if ( !reportederror ) {
353 SDL_Log(
"Waiting for attach\n");
361 device =
event.jdevice.which;
363 if (joystick !=
NULL) {
379 main(
int argc,
char *argv[])