22 #include <emscripten/emscripten.h> 25 #ifndef SDL_JOYSTICK_DISABLED 28 #define SCREEN_WIDTH 320 29 #define SCREEN_HEIGHT 480 31 #define SCREEN_WIDTH 640 32 #define SCREEN_HEIGHT 480 51 SDL_Joystick *joystick = (SDL_Joystick *)arg;
66 SDL_Log(
"Joystick %d axis %d value: %d\n",
71 SDL_Log(
"Joystick %d hat %d value:",
86 SDL_Log(
"Joystick %d ball %d delta: (%d,%d)\n",
91 SDL_Log(
"Joystick %d button %d down\n",
95 SDL_Log(
"Joystick %d button %d up\n",
179 #ifdef __EMSCRIPTEN__ 181 emscripten_cancel_main_loop();
199 if (window ==
NULL) {
205 if (screen ==
NULL) {
219 name ? name :
"Unknown Joystick");
220 SDL_Log(
"Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
225 #ifdef __EMSCRIPTEN__ 226 emscripten_set_main_loop_arg(
loop, joystick, 0, 1);
244 SDL_Joystick *joystick;
261 SDL_Log(
"Joystick %d: %s\n", i, name ? name :
"Unknown Joystick");
263 if (joystick ==
NULL) {
270 guid,
sizeof (guid));
273 type =
"Game Controller";
279 type =
"Arcade Stick";
282 type =
"Flight Stick";
315 #if defined(__ANDROID__) || defined(__IPHONEOS__) 324 #if defined(__ANDROID__) || defined(__IPHONEOS__) 327 device = atoi(argv[1]);
330 if (joystick !=
NULL) {
334 while ( keepGoing ) {
335 if (joystick ==
NULL) {
336 if ( !reportederror ) {
349 SDL_Log(
"Waiting for attach\n");
357 device =
event.jdevice.which;
359 if (joystick !=
NULL) {
375 main(
int argc,
char *argv[])
GLdouble GLdouble GLdouble r
#define SDL_WINDOWPOS_CENTERED
#define SDL_JoystickGetButton
SDL_JoyDeviceEvent jdevice
#define SDL_JoystickClose
#define SDL_JoystickGetVendor
#define SDL_JoystickGetGUID
#define SDL_INIT_JOYSTICK
GLint GLint GLint GLint GLint x
SDL_JoyButtonEvent jbutton
GLfloat GLfloat GLfloat GLfloat h
#define SDL_RenderFillRect
#define SDL_QuitSubSystem
#define SDL_JoystickNameForIndex
static void DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
#define SDL_JoystickNumButtons
#define SDL_JoystickGetGUIDString
#define SDL_JoystickInstanceID
#define SDL_JoystickGetProduct
#define SDL_JoystickGetHat
GLuint const GLchar * name
#define SDL_JoystickNumAxes
static SDL_AudioDeviceID device
#define SDL_JoystickGetType
#define SDL_JoystickFromInstanceID
#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK
A variable controlling whether the Android / iOS built-in accelerometer should be listed as a joystic...
int main(int argc, char *argv[])
GLubyte GLubyte GLubyte GLubyte w
#define SDL_JoystickGetAttached
GLint GLint GLint GLint GLint GLint y
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_JoystickNumHats
#define SDL_JoystickGetAxis
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
#define SDL_JoystickNumBalls
GLuint GLuint GLsizei GLenum type
static SDL_bool WatchJoystick(SDL_Joystick *joystick)
#define SDL_SetRenderDrawColor
#define SDL_DestroyRenderer
#define SDL_DestroyWindow
#define SDL_CreateRenderer
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent