Skip to content

Commit

Permalink
Fix input being sucked up when not in fullscreen game
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Oct 2, 2015
1 parent 0891907 commit 7630d64
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
26 changes: 22 additions & 4 deletions xbmc/games/addons/GameClient.cpp
Expand Up @@ -26,6 +26,8 @@
#include "filesystem/Directory.h"
#include "filesystem/SpecialProtocol.h"
#include "games/GameManager.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/WindowIDs.h"
#include "input/joysticks/JoystickTypes.h"
#include "input/PortManager.h"
#include "settings/Settings.h"
Expand Down Expand Up @@ -88,6 +90,10 @@ InputType CControllerInput::GetInputType(const std::string& feature) const
{
const std::vector<CGameControllerFeature>& features = m_controller->Layout().Features();

// TODO: Return INPUT_TYPE_UNKNOWN if feature isn't handled by the add-on, for
// example if a libretro add-on doesn't include the feature in its
// buttonmap.xml

for (std::vector<CGameControllerFeature>::const_iterator it = features.begin(); it != features.end(); ++it)
{
if (feature == it->Name())
Expand All @@ -113,22 +119,34 @@ InputType CControllerInput::GetInputType(const std::string& feature) const

bool CControllerInput::OnButtonPress(const std::string& feature, bool bPressed)
{
return m_addon->OnButtonPress(m_port, feature, bPressed);
if (g_windowManager.GetActiveWindowID() == WINDOW_FULLSCREEN_GAME)
return m_addon->OnButtonPress(m_port, feature, bPressed);

return false;
}

bool CControllerInput::OnButtonMotion(const std::string& feature, float magnitude)
{
return m_addon->OnButtonMotion(m_port, feature, magnitude);
if (g_windowManager.GetActiveWindowID() == WINDOW_FULLSCREEN_GAME)
return m_addon->OnButtonMotion(m_port, feature, magnitude);

return false;
}

bool CControllerInput::OnAnalogStickMotion(const std::string& feature, float x, float y)
{
return m_addon->OnAnalogStickMotion(m_port, feature, x, y);
if (g_windowManager.GetActiveWindowID() == WINDOW_FULLSCREEN_GAME)
return m_addon->OnAnalogStickMotion(m_port, feature, x, y);

return false;
}

bool CControllerInput::OnAccelerometerMotion(const std::string& feature, float x, float y, float z)
{
return m_addon->OnAccelerometerMotion(m_port, feature, x, y, z);
if (g_windowManager.GetActiveWindowID() == WINDOW_FULLSCREEN_GAME)
return m_addon->OnAccelerometerMotion(m_port, feature, x, y, z);

return false;
}

// --- CGameClient -------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions xbmc/guilib/GUIWindowManager.cpp
Expand Up @@ -1320,6 +1320,9 @@ int CGUIWindowManager::GetActiveWindowID()
// check for LiveTV and switch to it's virtual window
else if (g_PVRManager.IsStarted() && g_application.CurrentFileItem().HasPVRChannelInfoTag())
iWin = WINDOW_FULLSCREEN_LIVETV;
// check if a game is playing
else if (g_application.m_pPlayer->IsPlayingGame())
iWin = WINDOW_FULLSCREEN_GAME;
}
// special casing for PVR radio
if (iWin == WINDOW_VISUALISATION && g_PVRManager.IsStarted() && g_application.CurrentFileItem().HasPVRChannelInfoTag())
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/WindowIDs.h
Expand Up @@ -139,6 +139,7 @@
#define WINDOW_GAME_CONTROLLERS 10626
#define WINDOW_DIALOG_CONTROLLER_INPUT 10627
#define WINDOW_GAMES 10628
#define WINDOW_FULLSCREEN_GAME 10629 // virtual window for fullscreen game

//#define WINDOW_VIRTUAL_KEYBOARD 11000
// WINDOW_ID's from 11100 to 11199 reserved for Skins
Expand Down

0 comments on commit 7630d64

Please sign in to comment.