22 #include <emscripten/emscripten.h>
25 #ifndef SDL_JOYSTICK_DISABLED
28 #define SCREEN_WIDTH 480
29 #define SCREEN_HEIGHT 320
31 #define SCREEN_WIDTH 512
32 #define SCREEN_HEIGHT 320
102 SDL_GameController *gamecontroller = (SDL_GameController *)arg;
110 switch (event.
type) {
145 const Sint16 deadzone = 8000;
147 if (value < -deadzone) {
151 }
else if (value > deadzone) {
165 #ifdef __EMSCRIPTEN__
167 emscripten_cancel_main_loop();
176 const char *basetitle =
"Game Controller Test: ";
194 if (window ==
NULL) {
200 if (screen ==
NULL) {
218 if (!background || !button || !axis) {
230 SDL_Log(
"Watching controller %s\n", name ? name :
"Unknown Controller");
233 #ifdef __EMSCRIPTEN__
234 emscripten_set_main_loop_arg(
loop, gamecontroller, 0, 1);
237 loop(gamecontroller);
257 SDL_GameController *gamecontroller;
272 SDL_Log(
"Supported mappings:\n");
286 const char *description;
289 guid,
sizeof (guid));
295 description =
"Controller";
298 description =
"Joystick";
300 SDL_Log(
"%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x)\n",
301 description, i, name ? name :
"Unknown", guid,
310 int device = atoi(argv[1]);
316 guid,
sizeof (guid));
317 SDL_Log(
"Attempting to open device %i, guid %s\n", device, guid);
320 if (gamecontroller !=
NULL) {
325 if (gamecontroller ==
NULL) {
326 if (!reportederror) {
338 gamecontroller =
NULL;
340 SDL_Log(
"Waiting for attach\n");
349 if (gamecontroller !=
NULL) {
367 main(
int argc,
char *argv[])