Added GetBindingInfoDescription to avoid duplication.

This commit is contained in:
Jean-Philip Desjardins 2015-07-03 01:11:10 -04:00
parent df6bab3ee9
commit ba4ec06220
2 changed files with 18 additions and 22 deletions

View File

@ -210,6 +210,21 @@ void CInputManager::OnInputEventReceived(const GUID& device, uint32 id, uint32 v
}
}
std::tstring CInputManager::GetBindingInfoDescription(Framework::DirectInput::CManager* directInputManager, const BINDINGINFO& binding)
{
DIDEVICEINSTANCE deviceInstance;
DIDEVICEOBJECTINSTANCE objectInstance;
if(!directInputManager->GetDeviceInfo(binding.device, &deviceInstance))
{
return _T("");
}
if(!directInputManager->GetDeviceObjectInfo(binding.device, binding.id, &objectInstance))
{
return _T("");
}
return std::tstring(deviceInstance.tszInstanceName) + _T(": ") + std::tstring(objectInstance.tszName);
}
Framework::DirectInput::CManager* CInputManager::GetDirectInputManager() const
{
return m_directInputManager;
@ -265,17 +280,7 @@ void CInputManager::CSimpleBinding::Load(Framework::CConfig& config, const char*
std::tstring CInputManager::CSimpleBinding::GetDescription(Framework::DirectInput::CManager* directInputManager) const
{
DIDEVICEINSTANCE deviceInstance;
DIDEVICEOBJECTINSTANCE objectInstance;
if(!directInputManager->GetDeviceInfo(m_binding.device, &deviceInstance))
{
return _T("");
}
if(!directInputManager->GetDeviceObjectInfo(m_binding.device, m_binding.id, &objectInstance))
{
return _T("");
}
return std::tstring(deviceInstance.tszInstanceName) + _T(": ") + std::tstring(objectInstance.tszName);
return GetBindingInfoDescription(directInputManager, m_binding);
}
void CInputManager::CSimpleBinding::ProcessEvent(const GUID& device, uint32 id, uint32 value)
@ -341,17 +346,7 @@ void CInputManager::CPovHatBinding::Load(Framework::CConfig& config, const char*
std::tstring CInputManager::CPovHatBinding::GetDescription(Framework::DirectInput::CManager* directInputManager) const
{
DIDEVICEINSTANCE deviceInstance;
DIDEVICEOBJECTINSTANCE objectInstance;
if(!directInputManager->GetDeviceInfo(m_binding.device, &deviceInstance))
{
return _T("");
}
if(!directInputManager->GetDeviceObjectInfo(m_binding.device, m_binding.id, &objectInstance))
{
return _T("");
}
return std::tstring(deviceInstance.tszInstanceName) + _T(": ") + std::tstring(objectInstance.tszName);
return GetBindingInfoDescription(directInputManager, m_binding);
}
void CInputManager::CPovHatBinding::ProcessEvent(const GUID& device, uint32 id, uint32 value)

View File

@ -147,6 +147,7 @@ namespace PH_DirectInput
void OnInputEventReceived(const GUID&, uint32, uint32);
static std::tstring GetBindingInfoDescription(Framework::DirectInput::CManager*, const BINDINGINFO&);
BindingPtr m_bindings[PS2::CControllerInfo::MAX_BUTTONS];
static uint32 m_buttonDefaultValue[PS2::CControllerInfo::MAX_BUTTONS];