void * JoystickPollingLoop(void *ptr ) { int fd, rc; struct js_event jse; fd = open_joystick(joystick_device); if (fd < 0) { printf("joystick open failed.\n"); STOP_JOYSTICK_THREAD=1; return 0; } JOYSTICK_OK=1; while ( !STOP_JOYSTICK_THREAD ) { rc = read_joystick_event(&jse); usleep(1000); if (rc == 1) { //printf("Event: time %8u, value %8hd, type: %3u, axis/button: %u\n",jse.time, jse.value, jse.type, jse.number); HandleJoystickEvent(&jse); } } JOYSTICK_OK=0; return 0; }
void HandleOtherEvents(Event *event) { switch (event->type) { case EVENT_EXPOSE: HandleExposeEvent((ExposeEvent *) event); break; case EVENT_UNMAPNOTIFY: #if 0 /* This causes the game to stop not only when iconified, but also when on another virtual desktop, which might be not desired. */ SleepWhileUnmapped(); #endif break; case EVENT_FOCUSIN: case EVENT_FOCUSOUT: HandleFocusEvent((FocusChangeEvent *) event); break; case EVENT_CLIENTMESSAGE: HandleClientMessageEvent((ClientMessageEvent *) event); break; #if defined(TARGET_SDL) case SDL_JOYAXISMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: HandleJoystickEvent(event); break; case SDL_SYSWMEVENT: HandleWindowManagerEvent(event); break; #endif default: break; } }