bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick) { if ( (newJoystick.index < 0) || (newJoystick.index >= SDL_NumJoysticks()) ) return false; if (m_private->joystick != nullptr) CloseJoystick(); return OpenJoystick(); }
int main (int argc, char **argv) /* simple main program */ { /* don't tell me that this condition looks ugly... */ if ( (argc > 2) || ( (argc == 2) && ( (strcmp(argv[1],PRINT_VERSION) == 0) || (strcmp(argv[1],PRINT_VERSION_LONG) == 0) ) ) ) { printf(PROGRAM_VERSION "\n"); printf(PROGRAM_INFOTEXT "\n"); exit(0); }; SetDefaultValues(); if (config.debug > 1) { Print(stdout,PROGRAM_VERSION," starting up"); } InstallSignalHandler(); if (argc > 1) { free(config.config_file); config.config_file = AllocString(argv[1]); } ReadConfigFile(); if (config.daemon) { ForkToBackground(); } OpenJoystick(); AddMissingCalibrations(); ActionLoop(); CloseJoystick(); Print(stdout,PROGRAM_VERSION," quits now (should've never come around here!?)"); return 0; }
void CApplication::SetJoystickEnabled(bool enable) { m_joystickEnabled = enable; if (m_joystickEnabled) { if (! OpenJoystick()) { m_joystickEnabled = false; } } else { CloseJoystick(); } }