Skip to content

Commit

Permalink
Encapsulated g_Keyboard in CInputManager
Browse files Browse the repository at this point in the history
cleaned up some includes
  • Loading branch information
Paxxi committed Mar 2, 2015
1 parent 51b7d28 commit d43c6c4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ bool CApplication::Create()
g_Mouse.Initialize();
g_Mouse.SetEnabled(CSettings::Get().GetBool("input.enablemouse"));

g_Keyboard.Initialize();
CInputManager::Get().InitializeInputs();

#if defined(TARGET_DARWIN_OSX)
// Configure and possible manually start the helper.
Expand Down
14 changes: 7 additions & 7 deletions xbmc/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#include "ButtonTranslator.h"
#include "input/MouseStat.h"
#include "peripherals/Peripherals.h"
#include "input/KeyboardStat.h"
#include "XBMC_vkeys.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
Expand Down Expand Up @@ -88,8 +87,9 @@ void CInputManager::InitializeInputs()
// Pass the mapping of axis to triggers to m_Joystick
m_Joystick.Initialize();
#endif
}

m_Keyboard.Initialize();
}

void CInputManager::ReInitializeJoystick()
{
Expand Down Expand Up @@ -420,10 +420,10 @@ bool CInputManager::OnEvent(XBMC_Event& newEvent)
switch (newEvent.type)
{
case XBMC_KEYDOWN:
OnKey(g_Keyboard.ProcessKeyDown(newEvent.key.keysym));
OnKey(m_Keyboard.ProcessKeyDown(newEvent.key.keysym));
break;
case XBMC_KEYUP:
g_Keyboard.ProcessKeyUp();
m_Keyboard.ProcessKeyUp();
break;
case XBMC_MOUSEBUTTONDOWN:
case XBMC_MOUSEBUTTONUP:
Expand Down Expand Up @@ -512,7 +512,7 @@ bool CInputManager::OnKey(const CKey& key)
// allow some keys to be processed while the screensaver is active
if (g_application.WakeUpScreenSaverAndDPMS(processKey) && !processKey)
{
CLog::LogF(LOGDEBUG, "%s pressed, screen saver/dpms woken up", g_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str());
CLog::LogF(LOGDEBUG, "%s pressed, screen saver/dpms woken up", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str());
return true;
}

Expand Down Expand Up @@ -596,7 +596,7 @@ bool CInputManager::OnKey(const CKey& key)
}
}

CLog::LogF(LOGDEBUG, "%s pressed, trying keyboard action %x", g_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetID());
CLog::LogF(LOGDEBUG, "%s pressed, trying keyboard action %x", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetID());

if (g_application.OnAction(action))
return true;
Expand All @@ -611,7 +611,7 @@ bool CInputManager::OnKey(const CKey& key)
action = CButtonTranslator::GetInstance().GetAction(iWin, key);
}
if (!key.IsAnalogButton())
CLog::LogF(LOGDEBUG, "%s pressed, action is %s", g_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetName().c_str());
CLog::LogF(LOGDEBUG, "%s pressed, action is %s", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetName().c_str());

return ExecuteInputAction(action);
}
Expand Down
3 changes: 3 additions & 0 deletions xbmc/input/InputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#endif
#include "windowing/XBMC_events.h"
#include "guilib/Key.h"
#include "input/KeyboardStat.h"

class CInputManager
{
Expand Down Expand Up @@ -141,6 +142,8 @@ class CInputManager
*/
bool ExecuteInputAction(const CAction &action);

CKeyboardStat m_Keyboard;

#ifdef HAS_EVENT_SERVER
std::map<std::string, std::map<int, float> > m_lastAxisMap;
#endif
Expand Down
1 change: 0 additions & 1 deletion xbmc/input/KeyboardStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
using namespace std;
using namespace PERIPHERALS;

CKeyboardStat g_Keyboard;

CKeyboardStat::CKeyboardStat()
{
Expand Down
5 changes: 3 additions & 2 deletions xbmc/input/KeyboardStat.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
// but this allows for double/redundant or ambiguous mapping definition, e.g.
// ASCII/unicode could be derived from scancodes, virtual keys, modifiers and/or other ASCII/unicode.

#include <string>

#include "windowing/XBMC_events.h"
#include "guilib/Key.h"
#include "input/XBMC_keyboard.h"

class CKeyboardStat
{
Expand All @@ -60,6 +63,4 @@ class CKeyboardStat
unsigned int m_lastKeyTime;
};

extern CKeyboardStat g_Keyboard;

#endif

0 comments on commit d43c6c4

Please sign in to comment.