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[])
static const struct @60 axis_positions[]
#define SDL_WINDOWPOS_CENTERED
SDL_ControllerAxisEvent caxis
SDL_bool WatchGameController(SDL_GameController *gamecontroller)
SDL_ControllerDeviceEvent cdevice
#define SDL_LoadBMP(file)
#define SDL_INIT_JOYSTICK
#define SDL_IsGameController
#define SDL_GameControllerRumble
#define SDL_GameControllerGetAttached
#define SDL_GameControllerOpen
#define SDL_GameControllerGetStringForButton
#define SDL_QuitSubSystem
static SDL_Texture * LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
#define SDL_JoystickNameForIndex
A collection of pixels used in software blitting.
#define SDL_GameControllerNumMappings
#define SDL_GameControllerGetJoystick
#define SDL_GameControllerName
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
GLuint const GLchar * name
#define SDL_JoystickGetDeviceGUID
static SDL_AudioDeviceID device
static const struct @59 button_positions[]
GLenum GLenum GLuint texture
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerGetStringForAxis
#define SDL_GameControllerFromInstanceID
static SDL_Renderer * renderer
#define SDL_RenderSetLogicalSize
GLsizei const GLfloat * value
#define SDL_SetTextureColorMod
#define SDL_GameControllerClose
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)
#define SDL_assert(condition)
#define SDL_LogSetPriority
#define SDL_GameControllerMappingForIndex
#define SDL_GameControllerGetButton
EGLSurface EGLNativeWindowType * window
SDL_ControllerButtonEvent cbutton
The type used to identify a window.
#define SDL_GameControllerNameForIndex
GLenum GLenum GLenum GLenum mapping
#define SDL_INIT_GAMECONTROLLER
#define SDL_SetRenderDrawColor
#define SDL_GameControllerGetAxis
#define SDL_GameControllerAddMappingsFromFile(file)
#define SDL_DestroyRenderer
#define SDL_JoystickGetDeviceVendor
#define SDL_DestroyWindow
#define SDL_CreateRenderer
int main(int argc, char *argv[])
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent
#define SDL_JoystickGetDeviceProduct