Go to the documentation of this file.
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) {
140 const Sint16 deadzone = 8000;
142 if (
value < -deadzone) {
146 }
else if (
value > deadzone) {
167 #ifdef __EMSCRIPTEN__
169 emscripten_cancel_main_loop();
178 const char *basetitle =
"Game Controller Test: ";
232 SDL_Log(
"Watching controller %s\n",
name ?
name :
"Unknown Controller");
235 #ifdef __EMSCRIPTEN__
236 emscripten_set_main_loop_arg(
loop, gamecontroller, 0, 1);
239 loop(gamecontroller);
259 SDL_GameController *gamecontroller;
274 SDL_Log(
"Supported mappings:\n");
288 const char *description;
291 guid,
sizeof (guid));
299 description =
"XBox 360 Controller";
302 description =
"XBox One Controller";
305 description =
"PS3 Controller";
308 description =
"PS4 Controller";
311 description =
"Nintendo Switch Pro Controller";
314 description =
"Game Controller";
319 description =
"Joystick";
321 SDL_Log(
"%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x, player index = %d)\n",
322 description,
i,
name ?
name :
"Unknown", guid,
331 int device = atoi(argv[1]);
337 guid,
sizeof (guid));
338 SDL_Log(
"Attempting to open device %i, guid %s\n",
device, guid);
341 if (gamecontroller !=
NULL) {
346 if (gamecontroller ==
NULL) {
347 if (!reportederror) {
359 gamecontroller =
NULL;
361 SDL_Log(
"Waiting for attach\n");
370 if (gamecontroller !=
NULL) {
388 main(
int argc,
char *argv[])
#define SDL_JoystickGetDeviceProduct
#define SDL_RenderPresent
#define SDL_IsGameController
A collection of pixels used in software blitting.
#define SDL_GameControllerRumble
#define SDL_GameControllerGetAttached
#define SDL_WINDOWPOS_CENTERED
#define SDL_GameControllerGetStringForButton
#define SDL_GameControllerOpen
#define SDL_INIT_JOYSTICK
@ SDL_CONTROLLERBUTTONDOWN
#define SDL_GameControllerName
#define SDL_QuitSubSystem
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
#define SDL_JoystickNameForIndex
#define SDL_GameControllerGetJoystick
#define SDL_GameControllerNumMappings
@ SDL_CONTROLLERDEVICEADDED
int main(int argc, char *argv[])
@ SDL_CONTROLLERAXISMOTION
The type used to identify a window.
@ SDL_CONTROLLER_BUTTON_MAX
@ SDL_CONTROLLER_TYPE_PS3
#define SDL_CreateTextureFromSurface
static const struct @282 axis_positions[]
#define SDL_JoystickGetDeviceGUID
@ SDL_CONTROLLER_TYPE_PS4
SDL_bool WatchGameController(SDL_GameController *gamecontroller)
EGLSurface EGLNativeWindowType * window
@ SDL_CONTROLLER_AXIS_TRIGGERLEFT
GLenum GLenum GLenum GLenum mapping
@ SDL_LOG_CATEGORY_APPLICATION
GLuint const GLchar * name
#define SDL_SetTextureColorMod
@ SDL_CONTROLLER_AXIS_MAX
#define SDL_GameControllerGetStringForAxis
static SDL_Texture * LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
#define SDL_GameControllerFromInstanceID
#define SDL_JoystickGetDevicePlayerIndex
#define SDL_RenderSetLogicalSize
#define SDL_LoadBMP(file)
#define SDL_assert(condition)
#define SDL_GameControllerClose
#define SDL_GameControllerGetButton
static SDL_Renderer * renderer
#define SDL_GameControllerMappingForIndex
#define SDL_LogSetPriority
GLsizei const GLfloat * value
A rectangle, with the origin at the upper left (integer).
#define SDL_GameControllerTypeForIndex
#define SDL_GameControllerNameForIndex
#define SDL_SetRenderDrawColor
@ SDL_CONTROLLER_TYPE_XBOX360
#define SDL_INIT_GAMECONTROLLER
#define SDL_GameControllerGetAxis
@ SDL_CONTROLLER_AXIS_TRIGGERRIGHT
#define SDL_CreateRenderer
#define SDL_DestroyRenderer
GLenum GLenum GLuint texture
static SDL_AudioDeviceID device
@ SDL_CONTROLLER_TYPE_XBOXONE
#define SDL_GameControllerAddMappingsFromFile(file)
#define SDL_DestroyWindow
@ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
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)
static const struct @281 button_positions[]
#define SDL_JoystickGetDeviceVendor