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) {
160 #ifdef __EMSCRIPTEN__ 162 emscripten_cancel_main_loop();
171 const char *basetitle =
"Game Controller Test: ";
189 if (window ==
NULL) {
195 if (screen ==
NULL) {
213 if (!background || !button || !axis) {
225 SDL_Log(
"Watching controller %s\n", name ? name :
"Unknown Controller");
228 #ifdef __EMSCRIPTEN__ 229 emscripten_set_main_loop_arg(
loop, gamecontroller, 0, 1);
232 loop(gamecontroller);
252 SDL_GameController *gamecontroller;
267 SDL_Log(
"Supported mappings:\n");
281 const char *description;
284 guid,
sizeof (guid));
290 description =
"Controller";
293 description =
"Joystick";
295 SDL_Log(
"%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x)\n",
296 description, i, name ? name :
"Unknown", guid,
305 int device = atoi(argv[1]);
311 guid,
sizeof (guid));
312 SDL_Log(
"Attempting to open device %i, guid %s\n", device, guid);
315 if (gamecontroller !=
NULL) {
320 if (gamecontroller ==
NULL) {
321 if (!reportederror) {
333 gamecontroller =
NULL;
335 SDL_Log(
"Waiting for attach\n");
344 if (gamecontroller !=
NULL) {
362 main(
int argc,
char *argv[])
#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_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
GLenum GLenum GLuint texture
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerGetStringForAxis
#define SDL_GameControllerFromInstanceID
static SDL_Renderer * renderer
#define SDL_RenderSetLogicalSize
static const struct @55 axis_positions[]
GLsizei const GLfloat * value
static const struct @54 button_positions[]
#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