2016-03-11 22:50:15 +00:00
|
|
|
#include "CGuiPhysicalMsg.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CGuiPhysicalMsg::CGuiPhysicalMsg(const PhysicalMap& map)
|
|
|
|
{
|
|
|
|
SetMessage(map, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiPhysicalMsg::Exists(const CGuiPhysicalMsg& other) const
|
|
|
|
{
|
|
|
|
return ((~x8_repeatStates | other.x8_repeatStates) & x0_curStates) == other.x0_curStates;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiPhysicalMsg::SetMessage(const PhysicalMap& map, bool pressed)
|
|
|
|
{
|
|
|
|
for (const std::pair<EPhysicalControllerID, CPhysicalID>& item : map)
|
|
|
|
{
|
|
|
|
u64 physicalBit = 1 << u64(item.second.x0_key);
|
|
|
|
if (pressed)
|
|
|
|
x0_curStates |= physicalBit;
|
|
|
|
else
|
|
|
|
x0_curStates &= ~physicalBit;
|
|
|
|
|
2016-03-14 23:32:44 +00:00
|
|
|
if (item.second.x4_repeat)
|
2016-03-11 22:50:15 +00:00
|
|
|
x8_repeatStates |= physicalBit;
|
|
|
|
else
|
|
|
|
x8_repeatStates &= ~physicalBit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-14 23:32:44 +00:00
|
|
|
void CGuiPhysicalMsg::AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool repeat)
|
2016-03-11 22:50:15 +00:00
|
|
|
{
|
2016-03-14 23:32:44 +00:00
|
|
|
map.emplace(std::make_pair(key, CPhysicalID{key, repeat}));
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-14 23:32:44 +00:00
|
|
|
CGuiPhysicalMsg::EControllerState
|
2016-03-11 22:50:15 +00:00
|
|
|
CGuiPhysicalMsg::FindControllerID(const PhysicalMap& map, EPhysicalControllerID key)
|
|
|
|
{
|
|
|
|
auto search = map.find(key);
|
|
|
|
if (search == map.cend())
|
2016-03-14 23:32:44 +00:00
|
|
|
return EControllerState::NotPressed;
|
|
|
|
return search->second.x4_repeat ? EControllerState::PressRepeat : EControllerState::Press;
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|