diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-09-23 18:48:28 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-09-23 18:48:28 +0400 |
commit | eaf354e222ec64dc0e258a53107ef1eca9ac341c (patch) | |
tree | 1ba37f32860bf2ee6df455d1848e0b7078ab3339 /source/gameengine | |
parent | 97cb65df52ea61b23a8b760de48df7ddab4310a1 (diff) |
Fix related to #36319: restore SDL_VIDEODRIVER=dummy environment variable, it
seems that somehow not having this is causing keyboard events to be caught by
SDL. This was removed because it broke addons that could use SDL, now set the
environment variable only temporary during SDL initialization.
This may have been causing issues with keyboard events getting missed in the
game engine, but I couldn't confirm the issue here.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 64ab0af4d26..793ce6a7b83 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -39,6 +39,8 @@ #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" +#include "BLI_path_util.h" + SCA_Joystick::SCA_Joystick(short int index) : m_joyindex(index), @@ -88,14 +90,26 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) if (m_refCount == 0) { int i; + /* The video subsystem is required for joystick input to work. However, - * when GHOST is running under SDL, video is initialized elsewhere. - * Do this once only. */ + * when GHOST is running under SDL, video is initialized elsewhere. We + * also need to set the videodriver to dummy, and do it here to avoid + * interfering with addons that may use SDL too. + * + * We also init SDL once only. */ # ifdef WITH_GHOST_SDL - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1 ) { + int success = (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1 ); # else - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO) == -1 ) { + /* set and restore environment variable */ + char *videodriver = getenv("SDL_VIDEODRIVER"); + BLI_setenv("SDL_VIDEODRIVER", "dummy"); + + int success = (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO) != -1 ); + + BLI_setenv("SDL_VIDEODRIVER", videodriver); # endif + + if (!success) { JOYSTICK_ECHO("Error-Initializing-SDL: " << SDL_GetError()); return NULL; } |