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 106 SDL_GameController *gamecontroller = (SDL_GameController *)arg;
114 switch (event.
type) {
137 const Sint16 deadzone = 8000;
139 if (value < -deadzone) {
143 }
else if (value > deadzone) {
157 #ifdef __EMSCRIPTEN__ 159 emscripten_cancel_main_loop();
168 const char *basetitle =
"Game Controller Test: ";
186 if (window ==
NULL) {
192 if (screen ==
NULL) {
210 if (!background || !button || !axis) {
222 SDL_Log(
"Watching controller %s\n", name ? name :
"Unknown Controller");
225 #ifdef __EMSCRIPTEN__ 226 emscripten_set_main_loop_arg(
loop, gamecontroller, 0, 1);
229 loop(gamecontroller);
249 SDL_GameController *gamecontroller;
265 const char *description;
268 guid,
sizeof (guid));
274 description =
"Controller";
277 description =
"Joystick";
279 SDL_Log(
"%s %d: %s (guid %s)\n", description, i, name ? name :
"Unknown", guid);
287 int device = atoi(argv[1]);
293 guid,
sizeof (guid));
294 SDL_Log(
"Attempting to open device %i, guid %s\n", device, guid);
297 if (gamecontroller !=
NULL) {
302 if (gamecontroller ==
NULL) {
303 if (!reportederror) {
315 gamecontroller =
NULL;
317 SDL_Log(
"Waiting for attach\n");
326 if (gamecontroller !=
NULL) {
344 main(
int argc,
char *argv[])
#define SDL_WINDOWPOS_CENTERED
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
static SDL_Window * window
GLenum GLenum GLuint texture
#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_GameControllerGetJoystick
#define SDL_GameControllerName
GLuint const GLchar * name
uint32_t Uint32
An unsigned 32-bit integer type.
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
#define SDL_JoystickGetDeviceGUID
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerFromInstanceID
GLsizei const GLfloat * value
static SDL_Renderer * renderer
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_RenderSetLogicalSize
static const struct @40 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_GameControllerGetButton
The type used to identify a window.
#define SDL_GameControllerNameForIndex
#define SDL_INIT_GAMECONTROLLER
#define SDL_SetRenderDrawColor
#define SDL_GameControllerGetAxis
#define SDL_GameControllerAddMappingsFromFile(file)
#define SDL_DestroyRenderer
#define SDL_DestroyWindow
#define SDL_CreateRenderer
int main(int argc, char *argv[])
A rectangle, with the origin at the upper left.
static const struct @41 axis_positions[]
int16_t Sint16
A signed 16-bit integer type.
#define SDL_RenderPresent