Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
| Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | # endif | ||||
| if (!success) { | if (!success) { | ||||
| JOYSTICK_ECHO("Error-Initializing-SDL: " << SDL_GetError()); | JOYSTICK_ECHO("Error-Initializing-SDL: " << SDL_GetError()); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| m_joynum = SDL_NumJoysticks(); | m_joynum = SDL_NumJoysticks(); | ||||
| for (i=0; i<JOYINDEX_MAX; i++) { | for (i = 0; i < m_joynum; i++) { | ||||
| m_instance[i] = new SCA_Joystick(i); | m_instance[i] = new SCA_Joystick(i); | ||||
| m_instance[i]->CreateJoystickDevice(); | m_instance[i]->CreateJoystickDevice(); | ||||
| } | } | ||||
| m_refCount = 1; | m_refCount = 1; | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| m_refCount++; | m_refCount++; | ||||
| } | } | ||||
| return m_instance[joyindex]; | return m_instance[joyindex]; | ||||
| #endif /* WITH_SDL */ | #endif /* WITH_SDL */ | ||||
| } | } | ||||
| void SCA_Joystick::ReleaseInstance() | void SCA_Joystick::ReleaseInstance() | ||||
| { | { | ||||
| if (--m_refCount == 0) | if (--m_refCount == 0) | ||||
| { | { | ||||
| #ifdef WITH_SDL | #ifdef WITH_SDL | ||||
| if (!SDL_CHECK(SDL_QuitSubSystem)) { | if (!SDL_CHECK(SDL_QuitSubSystem)) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (int i=0; i<JOYINDEX_MAX; i++) { | for (int i = 0; i < m_joynum; i++) { | ||||
| if (m_instance[i]) { | if (m_instance[i]) { | ||||
| m_instance[i]->DestroyJoystickDevice(); | m_instance[i]->DestroyJoystickDevice(); | ||||
| delete m_instance[i]; | delete m_instance[i]; | ||||
| } | } | ||||
| m_instance[i] = NULL; | m_instance[i] = NULL; | ||||
| } | } | ||||
| /* The video subsystem is required for joystick input to work. However, | /* The video subsystem is required for joystick input to work. However, | ||||
| ▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines | |||||