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 317 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: ";
184 if (window ==
NULL) {
190 if (screen ==
NULL) {
208 if (!background || !button || !axis) {
220 SDL_Log(
"Watching controller %s\n", name ? name :
"Unknown Controller");
223 #ifdef __EMSCRIPTEN__ 224 emscripten_set_main_loop_arg(
loop, gamecontroller, 0, 1);
227 loop(gamecontroller);
247 SDL_GameController *gamecontroller;
263 const char *description;
266 guid,
sizeof (guid));
272 description =
"Controller";
275 description =
"Joystick";
277 SDL_Log(
"%s %d: %s (guid %s)\n", description, i, name ? name :
"Unknown", guid);
285 int device = atoi(argv[1]);
291 guid,
sizeof (guid));
292 SDL_Log(
"Attempting to open device %i, guid %s\n", device, guid);
295 if (gamecontroller !=
NULL) {
300 if (gamecontroller ==
NULL) {
301 if (!reportederror) {
313 gamecontroller =
NULL;
315 SDL_Log(
"Waiting for attach\n");
324 if (gamecontroller !=
NULL) {
342 main(
int argc,
char *argv[])
#define SDL_WINDOWPOS_CENTERED
SDL_bool WatchGameController(SDL_GameController *gamecontroller)
uint32_t Uint32
An unsigned 32-bit integer type.
SDL_ControllerDeviceEvent cdevice
#define SDL_LoadBMP(file)
#define SDL_INIT_JOYSTICK
#define SDL_IsGameController
#define SDL_GameControllerGetAttached
#define SDL_GameControllerOpen
GLenum GLenum GLuint texture
#define SDL_QuitSubSystem
#define SDL_JoystickNameForIndex
A collection of pixels used in software blitting.
#define SDL_GameControllerGetJoystick
#define SDL_GameControllerName
GLuint const GLchar * name
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
#define SDL_JoystickGetDeviceGUID
#define SDL_CreateTextureFromSurface
#define SDL_GameControllerFromInstanceID
GLsizei const GLfloat * value
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_RenderSetLogicalSize
#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
static const struct @41 button_positions[]
The type used to identify a window.
static SDL_Texture * LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
#define SDL_GameControllerNameForIndex
#define SDL_INIT_GAMECONTROLLER
#define SDL_SetRenderDrawColor
#define SDL_GameControllerGetAxis
#define SDL_GameControllerAddMappingsFromFile(file)
#define SDL_DestroyRenderer
#define SDL_DestroyWindow
static const struct @42 axis_positions[]
#define SDL_CreateRenderer
int main(int argc, char *argv[])
A rectangle, with the origin at the upper left.
int16_t Sint16
A signed 16-bit integer type.
#define SDL_RenderPresent