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) {
167 emscripten_cancel_main_loop();
176 const char *basetitle =
"Game Controller Test: ";
230 SDL_Log(
"Watching controller %s\n",
name ?
name :
"Unknown Controller");
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) {
367main(
int argc,
char *argv[])
#define SDL_INIT_GAMECONTROLLER
#define SDL_INIT_JOYSTICK
#define SDL_assert(condition)
#define SDL_GameControllerNumMappings
#define SDL_RenderPresent
#define SDL_DestroyWindow
#define SDL_GameControllerGetJoystick
#define SDL_JoystickGetDeviceProduct
#define SDL_DestroyRenderer
#define SDL_JoystickGetDeviceVendor
#define SDL_SetRenderDrawColor
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerRumble
#define SDL_GameControllerClose
#define SDL_JoystickNameForIndex
#define SDL_RenderSetLogicalSize
#define SDL_GameControllerGetAttached
#define SDL_JoystickGetGUIDString
#define SDL_GameControllerGetStringForButton
#define SDL_CreateRenderer
#define SDL_GameControllerNameForIndex
#define SDL_JoystickGetDeviceGUID
#define SDL_LogSetPriority
#define SDL_GameControllerName
#define SDL_GameControllerOpen
#define SDL_GameControllerGetStringForAxis
#define SDL_SetTextureColorMod
#define SDL_GameControllerMappingForIndex
#define SDL_GameControllerGetButton
#define SDL_JoystickInstanceID
#define SDL_QuitSubSystem
#define SDL_GameControllerGetAxis
#define SDL_IsGameController
#define SDL_GameControllerFromInstanceID
@ SDL_CONTROLLERDEVICEADDED
@ SDL_CONTROLLERBUTTONDOWN
@ SDL_CONTROLLERAXISMOTION
#define SDL_GameControllerAddMappingsFromFile(file)
@ SDL_CONTROLLER_AXIS_MAX
@ SDL_CONTROLLER_BUTTON_MAX
@ SDL_CONTROLLER_BUTTON_A
@ SDL_LOG_CATEGORY_APPLICATION
GLuint const GLchar * name
GLenum GLenum GLenum GLenum mapping
GLenum GLenum GLuint texture
GLsizei const GLfloat * value
#define SDL_LoadBMP(file)
#define SDL_WINDOWPOS_CENTERED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
EGLSurface EGLNativeWindowType * window
static SDL_AudioDeviceID device
A rectangle, with the origin at the upper left (integer).
A collection of pixels used in software blitting.
The type used to identify a window.
static SDL_Renderer * renderer
SDL_bool WatchGameController(SDL_GameController *gamecontroller)
static const struct @288 button_positions[]
int main(int argc, char *argv[])
static SDL_Texture * LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
static const struct @289 axis_positions[]