Skip to content

Commit

Permalink
Update CJoystick for changed ButtonTranslator signature
Browse files Browse the repository at this point in the history
  • Loading branch information
zzattack committed Feb 9, 2015
1 parent 057a1b5 commit 2d74f06
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
18 changes: 4 additions & 14 deletions xbmc/input/SDLJoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "system.h"
#include "SDLJoystick.h"
#include "input/ButtonTranslator.h"
#include "peripherals/devices/PeripheralImon.h"
#include "settings/AdvancedSettings.h"
#include "settings/lib/Setting.h"
Expand Down Expand Up @@ -406,28 +407,17 @@ bool CJoystick::Reinitialize()
return true;
}

void CJoystick::LoadAxesConfigs(const std::map<boost::shared_ptr<CRegExp>, AxesConfig> &axesConfigs)
{
m_AxesConfigs.clear();
m_AxesConfigs.insert(axesConfigs.begin(), axesConfigs.end());
}

void CJoystick::ApplyAxesConfigs()
{
// load axes configuration from keymap
int axesCount = 0;
for (std::map<int, SDL_Joystick*>::const_iterator it = m_Joysticks.begin(); it != m_Joysticks.end(); ++it)
{
std::string joyName(SDL_JoystickName(it->second));
std::map<boost::shared_ptr<CRegExp>, AxesConfig>::const_iterator axesCfg;
for (axesCfg = m_AxesConfigs.begin(); axesCfg != m_AxesConfigs.end(); ++axesCfg)
{
if (axesCfg->first->RegFind(joyName) >= 0)
break;
}
if (axesCfg != m_AxesConfigs.end())
const AxesConfig* axesCfg = CButtonTranslator::GetInstance().GetAxesConfigFor(joyName);
if (axesCfg != NULL)
{
for (AxesConfig::const_iterator it = axesCfg->second.begin(); it != axesCfg->second.end(); ++it)
for (AxesConfig::const_iterator it = axesCfg->begin(); it != axesCfg->end(); ++it)
{
int axis = axesCount + it->axis - 1;
m_Axes[axis].trigger = it->isTrigger;
Expand Down
2 changes: 0 additions & 2 deletions xbmc/input/SDLJoystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class CJoystick : public ISettingCallback
float SetDeadzone(float val);
bool Reinitialize();
typedef std::vector<AxisConfig> AxesConfig; // [<axis, isTrigger, rest state value>]
void LoadAxesConfigs(const std::map<boost::shared_ptr<CRegExp>, AxesConfig>& axesConfigs);
void ApplyAxesConfigs();

private:
Expand Down Expand Up @@ -120,7 +119,6 @@ class CJoystick : public ISettingCallback
uint32_t m_pressTicksButton;
uint32_t m_pressTicksHat;
std::map<int, SDL_Joystick*> m_Joysticks;
std::map<boost::shared_ptr<CRegExp>, AxesConfig> m_AxesConfigs; // <joy, <axis num, isTrigger, restState> >
};

#endif
Expand Down
17 changes: 3 additions & 14 deletions xbmc/input/windows/WINJoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,10 @@ BOOL CALLBACK CJoystick::EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInst
p_this->m_devCaps.push_back(diDevCaps);

// load axes configuration from keymap
std::map<boost::shared_ptr<CRegExp>, AxesConfig>::const_iterator axesCfg;
for (axesCfg = p_this->m_AxesConfigs.begin(); axesCfg != p_this->m_AxesConfigs.end(); ++axesCfg)
const AxesConfig* axesCfg = CButtonTranslator::GetInstance().GetAxesConfigFor(joyName);
if (axesCfg != NULL)
{
if (axesCfg->first->RegFind(joyName) >= 0)
break;
}
if (axesCfg != p_this->m_AxesConfigs.end())
{
for (AxesConfig::const_iterator it = axesCfg->second.begin(); it != axesCfg->second.end(); ++it)
for (AxesConfig::const_iterator it = axesCfg->begin(); it != axesCfg->end(); ++it)
{
int axis = p_this->MapAxis(pJoystick, it->axis - 1);
p_this->m_Axes[axis].trigger = it->isTrigger;
Expand Down Expand Up @@ -521,12 +516,6 @@ void CJoystick::Acquire()
}
}

void CJoystick::LoadAxesConfigs(const std::map<boost::shared_ptr<CRegExp>, AxesConfig> &axesConfigs)
{
m_AxesConfigs.clear();
m_AxesConfigs.insert(axesConfigs.begin(), axesConfigs.end());
}

int CJoystick::JoystickIndex(const std::string &joyName) const
{
for (size_t i = 0; i < m_JoystickNames.size(); ++i)
Expand Down
2 changes: 0 additions & 2 deletions xbmc/input/windows/WINJoystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class CJoystick : public ISettingCallback
bool Reinitialize();
void Acquire();
typedef std::vector<AxisConfig> AxesConfig; // [<axis, isTrigger, rest state value>]
void LoadAxesConfigs(const std::map<boost::shared_ptr<CRegExp>, AxesConfig> &axesConfigs);

private:
bool IsButtonActive() const { return m_ButtonIdx != -1; }
Expand Down Expand Up @@ -115,5 +114,4 @@ class CJoystick : public ISettingCallback
std::vector<LPDIRECTINPUTDEVICE8> m_pJoysticks;
std::vector<std::string> m_JoystickNames;
std::vector<DIDEVCAPS> m_devCaps;
std::map<boost::shared_ptr<CRegExp>, AxesConfig> m_AxesConfigs; // <joy, <axis num, isTrigger, restState> >
};

0 comments on commit 2d74f06

Please sign in to comment.