mirror of https://github.com/AxioDL/metaforce.git
Input handling for CGuiFrame
This commit is contained in:
parent
aa207d3e5f
commit
66247cfe79
|
@ -0,0 +1,30 @@
|
|||
#include "CGuiAutoRepeatData.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
void CGuiAutoRepeatData::AddAutoEvent(int cIdx, CGuiPhysicalMsg::PhysicalMap& events, float eTime)
|
||||
{
|
||||
if (x28_pressed[cIdx])
|
||||
{
|
||||
if (x2c_defer[cIdx])
|
||||
{
|
||||
x2c_defer[cIdx] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (eTime >= x8_nextDue[cIdx])
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(events, x0_instEvent, true);
|
||||
x8_nextDue[cIdx] = x18_remainder[cIdx] + eTime;
|
||||
x18_remainder[cIdx] -= 0.05;
|
||||
if (x18_remainder[cIdx] < 0.05)
|
||||
x18_remainder[cIdx] = 0.05;
|
||||
}
|
||||
if (CGuiPhysicalMsg::FindControllerID(events, x4_contEvent) ==
|
||||
CGuiPhysicalMsg::EControllerState::NotPressed)
|
||||
x28_pressed[cIdx] = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,13 +8,23 @@ namespace urde
|
|||
|
||||
class CGuiAutoRepeatData
|
||||
{
|
||||
EPhysicalControllerID x0_a;
|
||||
EPhysicalControllerID x4_b;
|
||||
float x8_[8] = {0.f, 0.f, 0.f, 0.f, 0.2f, 0.2f, 0.2f, 0.2f};
|
||||
bool x28_[8] = {};
|
||||
EPhysicalControllerID x0_instEvent;
|
||||
EPhysicalControllerID x4_contEvent;
|
||||
float x8_nextDue[4] = {0.f, 0.f, 0.f, 0.f};
|
||||
float x18_remainder[4] = {0.2f, 0.2f, 0.2f, 0.2f};
|
||||
bool x28_pressed[4] = {};
|
||||
bool x2c_defer[4] = {};
|
||||
public:
|
||||
CGuiAutoRepeatData(EPhysicalControllerID a, EPhysicalControllerID b)
|
||||
: x0_a(a), x4_b(b) {}
|
||||
CGuiAutoRepeatData(EPhysicalControllerID inst, EPhysicalControllerID cont)
|
||||
: x0_instEvent(inst), x4_contEvent(cont) {}
|
||||
void SetActive(int cIdx, float eTime)
|
||||
{
|
||||
x8_nextDue[cIdx] = eTime + 0.6f;
|
||||
x28_pressed[cIdx] = true;
|
||||
x2c_defer[cIdx] = true;
|
||||
x18_remainder[cIdx] = 0.2f;
|
||||
}
|
||||
void AddAutoEvent(int cIdx, CGuiPhysicalMsg::PhysicalMap& events, float eTime);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ namespace urde
|
|||
class CGuiControllerInfo
|
||||
{
|
||||
public:
|
||||
class CGuiControllerStateInfo
|
||||
struct CGuiControllerStateInfo
|
||||
{
|
||||
char cIdx;
|
||||
char lx, ly, rx, ry;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "CGuiSys.hpp"
|
||||
#include "CGuiHeadWidget.hpp"
|
||||
#include "CGuiAnimController.hpp"
|
||||
#include "CGuiMessage.hpp"
|
||||
#include "Input/CFinalInput.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde
|
||||
|
@ -40,6 +42,227 @@ void CGuiFrame::ResetControllerStatus()
|
|||
x0_controllerStatus[3] = false;
|
||||
}
|
||||
|
||||
void CGuiFrame::InterpretGUIControllerState(const CFinalInput& input,
|
||||
CGuiPhysicalMsg::PhysicalMap& state,
|
||||
char& lx, char& ly, char& rx, char& ry)
|
||||
{
|
||||
zeus::CVector2f left(std::fabs(input.ALeftX()), std::fabs(input.ALeftY()));
|
||||
bool leftThreshold = false;
|
||||
if (left.magnitude() >= 0.6f)
|
||||
leftThreshold = true;
|
||||
|
||||
zeus::CVector2f right(std::fabs(input.ARightX()), std::fabs(input.ARightY()));
|
||||
bool rightThreshold = false;
|
||||
if (right.magnitude() >= 0.6f)
|
||||
rightThreshold = true;
|
||||
|
||||
if (leftThreshold)
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickThreshold, false);
|
||||
|
||||
if (input.ALeftX() < 0.f)
|
||||
lx = input.ALeftX() * 128.f;
|
||||
else
|
||||
lx = input.ALeftX() * 127.f;
|
||||
|
||||
if (input.ALeftY() < 0.f)
|
||||
ly = input.ALeftY() * 128.f;
|
||||
else
|
||||
ly = input.ALeftY() * 127.f;
|
||||
|
||||
if (0.7f < input.ALeftY())
|
||||
{
|
||||
if (input.PLAUp())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickUpInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUpInst, false);
|
||||
}
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickUp, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUp, false);
|
||||
}
|
||||
|
||||
if (-0.7f > input.ALeftY())
|
||||
{
|
||||
if (input.PLADown())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickDownInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDownInst, false);
|
||||
}
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickDown, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDown, false);
|
||||
}
|
||||
|
||||
if (0.7f < input.ALeftX())
|
||||
{
|
||||
if (input.PLARight())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRightInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRightInst, false);
|
||||
}
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRight, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRight, false);
|
||||
}
|
||||
|
||||
if (-0.7f > input.ALeftX())
|
||||
{
|
||||
if (input.PLALeft())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickLeftInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeftInst, false);
|
||||
}
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickLeft, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeft, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRelease, false);
|
||||
lx = 0;
|
||||
ly = 0;
|
||||
}
|
||||
|
||||
if (rightThreshold)
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickThreshold, false);
|
||||
|
||||
if (input.ARightX() < 0.f)
|
||||
rx = input.ARightX() * 128.f;
|
||||
else
|
||||
rx = input.ARightX() * 127.f;
|
||||
|
||||
if (input.ARightY() < 0.f)
|
||||
ry = input.ARightY() * 128.f;
|
||||
else
|
||||
ry = input.ARightY() * 127.f;
|
||||
|
||||
if (0.7f < input.ARightY())
|
||||
{
|
||||
if (input.PRAUp())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickUpInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickUp, false);
|
||||
}
|
||||
|
||||
if (-0.7f > input.ARightY())
|
||||
{
|
||||
if (input.PRADown())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickDownInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickDown, false);
|
||||
}
|
||||
|
||||
if (0.7f < input.ARightX())
|
||||
{
|
||||
if (input.PRARight())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRightInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRight, false);
|
||||
}
|
||||
|
||||
if (-0.7f > input.ARightX())
|
||||
{
|
||||
if (input.PRALeft())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickLeftInst, false);
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickLeft, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRelease, false);
|
||||
rx = 0;
|
||||
ry = 0;
|
||||
}
|
||||
|
||||
if (input.PDPUp())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadUpInst, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUpInst, false);
|
||||
}
|
||||
else if (input.DDPUp())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadUp, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUp, false);
|
||||
}
|
||||
|
||||
if (input.PDPDown())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadDownInst, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDownInst, false);
|
||||
}
|
||||
else if (input.DDPDown())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadDown, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDown, false);
|
||||
}
|
||||
|
||||
if (input.PDPRight())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadRightInst, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRightInst, false);
|
||||
}
|
||||
else if (input.DDPRight())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadRight, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRight, false);
|
||||
}
|
||||
|
||||
if (input.PDPLeft())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadLeftInst, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeftInst, false);
|
||||
}
|
||||
else if (input.DDPLeft())
|
||||
{
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadLeft, false);
|
||||
if (leftThreshold)
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeft, false);
|
||||
}
|
||||
|
||||
if (input.PStart())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::StartInst, false);
|
||||
if (input.DStart())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Start, false);
|
||||
|
||||
if (input.PB())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::BInst, false);
|
||||
if (input.DB())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::B, false);
|
||||
|
||||
if (input.PA())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::AInst, false);
|
||||
if (input.DA())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::A, false);
|
||||
|
||||
if (input.PX())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::XInst, false);
|
||||
if (input.DX())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::X, false);
|
||||
|
||||
if (input.PY())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::YInst, false);
|
||||
if (input.DY())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Y, false);
|
||||
|
||||
if (input.PZ())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::ZInst, false);
|
||||
if (input.DZ())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Z, false);
|
||||
|
||||
if (input.PLTrigger())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LInst, false);
|
||||
if (input.DLTrigger())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::L, false);
|
||||
|
||||
if (input.PRTrigger())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RInst, false);
|
||||
if (input.DRTrigger())
|
||||
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::R, false);
|
||||
}
|
||||
|
||||
CGuiFrame::WidgetToLogicalEventMap* CGuiFrame::FindWidget2LogicalEventMap(u64 events)
|
||||
{
|
||||
auto search = x7c_messageMap.find(events);
|
||||
|
@ -61,6 +284,23 @@ CGuiFrame::LogicalEventList* CGuiFrame::FindLogicalEventList(u64 events, s16 id)
|
|||
return search->second.get();
|
||||
}
|
||||
|
||||
bool CGuiFrame::SendWidgetMessage(s16 id,
|
||||
std::list<std::unique_ptr<CGuiFrameMessageMapNode>>& list,
|
||||
CGuiPhysicalMsg::PhysicalMap& state,
|
||||
CGuiControllerInfo::CGuiControllerStateInfo& csInfo)
|
||||
{
|
||||
CGuiWidget* widget = FindWidget(id);
|
||||
for (std::unique_ptr<CGuiFrameMessageMapNode>& node : list)
|
||||
{
|
||||
CGuiMessage msg(CGuiMessage::Type(node->GetTrigger().GetTriggerId()),
|
||||
reinterpret_cast<uintptr_t>(&state),
|
||||
reinterpret_cast<uintptr_t>(&csInfo));
|
||||
if (!widget->Message(msg))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGuiFrame::ClearMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id)
|
||||
{
|
||||
CGuiFrame::LogicalEventList* list =
|
||||
|
@ -105,6 +345,51 @@ void CGuiFrame::SortDrawOrder()
|
|||
});
|
||||
}
|
||||
|
||||
void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
||||
{
|
||||
if (x18_ & 0x4 && input.controllerIdx() == 0)
|
||||
{
|
||||
CGuiPhysicalMsg::PhysicalMap state;
|
||||
CGuiControllerInfo::CGuiControllerStateInfo stateInfo;
|
||||
stateInfo.cIdx = input.controllerIdx();
|
||||
InterpretGUIControllerState(input, state, stateInfo.lx, stateInfo.ly, stateInfo.rx, stateInfo.ry);
|
||||
float eventTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000.f;
|
||||
|
||||
for (const std::pair<EPhysicalControllerID, CGuiPhysicalMsg::CPhysicalID>& newPair : state)
|
||||
{
|
||||
auto search = x3c_guiSys.GetRepeatMap().find(newPair.first);
|
||||
if (search != x3c_guiSys.GetRepeatMap().end())
|
||||
search->second.SetActive(input.controllerIdx(), eventTime);
|
||||
}
|
||||
|
||||
for (std::pair<const EPhysicalControllerID, CGuiAutoRepeatData>& pair : x3c_guiSys.GetRepeatMap())
|
||||
{
|
||||
pair.second.AddAutoEvent(input.controllerIdx(), state, eventTime);
|
||||
}
|
||||
|
||||
CGuiPhysicalMsg msg(state);
|
||||
SetControllerStatus(input.controllerIdx(), true);
|
||||
|
||||
for (std::pair<const u64, std::unique_ptr<WidgetToLogicalEventMap>>& outer : x7c_messageMap)
|
||||
{
|
||||
if (outer.second)
|
||||
{
|
||||
for (std::pair<const s16, std::unique_ptr<LogicalEventList>>& inner : *outer.second)
|
||||
{
|
||||
if (inner.second && inner.second->size())
|
||||
{
|
||||
LogicalEventList& list = *inner.second;
|
||||
if (msg.Exists(list.back()->GetTrigger().GetPhysicalMsg()))
|
||||
if (!SendWidgetMessage(inner.first, list, state, stateInfo))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiFrame::Initialize()
|
||||
{
|
||||
SortDrawOrder();
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
bool x0_controllerStatus[4] = {};
|
||||
std::string x4_name;
|
||||
TResId x14_id;
|
||||
u32 x18_ = 0;
|
||||
CGuiFrameTransitionOptions x1c_transitionOpts;
|
||||
u32 x34_ = 0;
|
||||
u32 x38_ = 0;
|
||||
|
@ -75,6 +76,10 @@ private:
|
|||
bool xbc_24_flag1 : 1;
|
||||
bool xbd_flag2 = false;
|
||||
|
||||
static void InterpretGUIControllerState(const CFinalInput& input,
|
||||
CGuiPhysicalMsg::PhysicalMap& state,
|
||||
char& lx, char& ly, char& rx, char& ry);
|
||||
|
||||
public:
|
||||
CGuiFrame(TResId id, const std::string& name, CGuiSys& sys, int a, int b, int c);
|
||||
|
||||
|
@ -88,12 +93,9 @@ public:
|
|||
void SetFrameBackground(CGuiWidget* bg) {x50_background = bg;}
|
||||
void SetFrameCamera(CGuiCamera* camr) {x4c_camera = camr;}
|
||||
void SetHeadWidget(CGuiHeadWidget* hwig) {x44_headWidget = hwig;}
|
||||
void InterpretGUIControllerState(const CFinalInput& input,
|
||||
CGuiPhysicalMsg::PhysicalMap& state,
|
||||
char&, char&, char&, char&);
|
||||
WidgetToLogicalEventMap* FindWidget2LogicalEventMap(u64 events);
|
||||
LogicalEventList* FindLogicalEventList(u64 events, s16 id);
|
||||
void SendWidgetMessage(s16,
|
||||
bool SendWidgetMessage(s16,
|
||||
std::list<std::unique_ptr<CGuiFrameMessageMapNode>>&,
|
||||
CGuiPhysicalMsg::PhysicalMap& state,
|
||||
CGuiControllerInfo::CGuiControllerStateInfo& csInfo);
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace urde
|
|||
|
||||
class CGuiFuncParm
|
||||
{
|
||||
friend class CGuiMessage;
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
|
@ -21,14 +22,14 @@ private:
|
|||
Type x0_type = Type::Null;
|
||||
union
|
||||
{
|
||||
u32 x4_int;
|
||||
uintptr_t x4_int;
|
||||
float x4_float;
|
||||
void* x4_ptr = nullptr;
|
||||
};
|
||||
|
||||
public:
|
||||
CGuiFuncParm() = default;
|
||||
CGuiFuncParm(int arg) : x0_type(Type::Int), x4_int(arg) {}
|
||||
CGuiFuncParm(uintptr_t arg) : x0_type(Type::Int), x4_int(arg) {}
|
||||
CGuiFuncParm(float arg) : x0_type(Type::Float), x4_float(arg) {}
|
||||
CGuiFuncParm(void* arg) : x0_type(Type::IntrusivePointer), x4_ptr(arg) {}
|
||||
~CGuiFuncParm()
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef __URDE_CGUIMESSAGE_HPP__
|
||||
#define __URDE_CGUIMESSAGE_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CGuiFuncParm.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CGuiMessage
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Eighteen = 18,
|
||||
Nineteen = 19
|
||||
};
|
||||
private:
|
||||
Type x4_type;
|
||||
CGuiFuncParm x8_a;
|
||||
CGuiFuncParm x10_b;
|
||||
public:
|
||||
CGuiMessage(Type type, uintptr_t a, uintptr_t b)
|
||||
: x4_type(type), x8_a(a), x10_b(b) {}
|
||||
uintptr_t GetInt(u32 val) const
|
||||
{
|
||||
if (val == 0x60EF4DB0)
|
||||
return x8_a.x4_int;
|
||||
else
|
||||
return x10_b.x4_int;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __URDE_CGUIMESSAGE_HPP__
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual ~CGuiObject();
|
||||
virtual void Update(float dt);
|
||||
virtual void Draw(const CGuiWidgetDrawParms& parms) const;
|
||||
virtual void Message(const CGuiMessage& msg)=0;
|
||||
virtual bool Message(const CGuiMessage& msg)=0;
|
||||
|
||||
void MoveInWorld(const zeus::CVector3f& vec);
|
||||
const zeus::CVector3f& GetLocalPosition() const {return x4_localXF.m_origin;}
|
||||
|
|
|
@ -23,25 +23,25 @@ void CGuiPhysicalMsg::SetMessage(const PhysicalMap& map, bool pressed)
|
|||
else
|
||||
x0_curStates &= ~physicalBit;
|
||||
|
||||
if (item.second.x4_active)
|
||||
if (item.second.x4_repeat)
|
||||
x8_repeatStates |= physicalBit;
|
||||
else
|
||||
x8_repeatStates &= ~physicalBit;
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiPhysicalMsg::AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool active)
|
||||
void CGuiPhysicalMsg::AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool repeat)
|
||||
{
|
||||
map.emplace(std::make_pair(key, CPhysicalID{key, active}));
|
||||
map.emplace(std::make_pair(key, CPhysicalID{key, repeat}));
|
||||
}
|
||||
|
||||
CGuiPhysicalMsg::ControllerState
|
||||
CGuiPhysicalMsg::EControllerState
|
||||
CGuiPhysicalMsg::FindControllerID(const PhysicalMap& map, EPhysicalControllerID key)
|
||||
{
|
||||
auto search = map.find(key);
|
||||
if (search == map.cend())
|
||||
return ControllerState::NotFound;
|
||||
return search->second.x4_active ? ControllerState::Pressed : ControllerState::NotPressed;
|
||||
return EControllerState::NotPressed;
|
||||
return search->second.x4_repeat ? EControllerState::PressRepeat : EControllerState::Press;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,38 +8,63 @@ namespace urde
|
|||
{
|
||||
enum class EPhysicalControllerID
|
||||
{
|
||||
Seventeen = 17,
|
||||
Eighteen = 18,
|
||||
Nineteen = 19,
|
||||
Twenty = 20,
|
||||
TwentyOne = 21,
|
||||
TwentyTwo = 22,
|
||||
TwentyThree = 23,
|
||||
TwentyFour = 24,
|
||||
ThirtyThree = 33,
|
||||
ThirtyFour = 34,
|
||||
ThirtyFive = 35,
|
||||
ThirtySix = 36,
|
||||
ThirtySeven = 37,
|
||||
ThirtyEight = 38,
|
||||
ThirtyNine = 39,
|
||||
Forty = 40,
|
||||
FortyOne = 41,
|
||||
FortyTwo = 42,
|
||||
FortyThree = 43,
|
||||
FortyFour = 44,
|
||||
FortyFive = 45,
|
||||
FortySix = 46,
|
||||
FortySeven = 47,
|
||||
FortyEight = 48,
|
||||
TwentyFive = 25,
|
||||
TwentySix = 26,
|
||||
TwentySeven = 27,
|
||||
TwentyEight = 28,
|
||||
TwentyNine = 29,
|
||||
Thirty = 30,
|
||||
ThirtyOne = 31,
|
||||
ThirtyTwo = 32
|
||||
AInst = 1,
|
||||
A = 2,
|
||||
BInst = 3,
|
||||
B = 4,
|
||||
LInst = 5,
|
||||
L = 6,
|
||||
RInst = 7,
|
||||
R = 8,
|
||||
XInst = 9,
|
||||
X = 10,
|
||||
YInst = 11,
|
||||
Y = 12,
|
||||
ZInst = 13,
|
||||
Z = 14,
|
||||
StartInst = 15,
|
||||
Start = 16,
|
||||
|
||||
DPadUpInst = 17,
|
||||
DPadUp = 18,
|
||||
DPadRightInst = 19,
|
||||
DPadRight = 20,
|
||||
DPadDownInst = 21,
|
||||
DPadDown = 22,
|
||||
DPadLeftInst = 23,
|
||||
DPadLeft = 24,
|
||||
|
||||
LeftUpInst = 25,
|
||||
LeftUp = 26,
|
||||
LeftRightInst = 27,
|
||||
LeftRight = 28,
|
||||
LeftDownInst = 29,
|
||||
LeftDown = 30,
|
||||
LeftLeftInst = 31,
|
||||
LeftLeft = 32,
|
||||
|
||||
LeftStickUpInst = 33,
|
||||
LeftStickUp = 34,
|
||||
LeftStickRightInst = 35,
|
||||
LeftStickRight = 36,
|
||||
LeftStickDownInst = 37,
|
||||
LeftStickDown = 38,
|
||||
LeftStickLeftInst = 39,
|
||||
LeftStickLeft = 40,
|
||||
|
||||
RightStickUpInst = 41,
|
||||
RightStickUp = 42,
|
||||
RightStickRightInst = 43,
|
||||
RightStickRight = 44,
|
||||
RightStickDownInst = 45,
|
||||
RightStickDown = 46,
|
||||
RightStickLeftInst = 47,
|
||||
RightStickLeft = 48,
|
||||
|
||||
LeftStickThreshold = 49,
|
||||
LeftStickRelease = 50,
|
||||
RightStickThreshold = 51,
|
||||
RightStickRelease = 52
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -62,23 +87,23 @@ struct CGuiPhysicalMsg
|
|||
struct CPhysicalID
|
||||
{
|
||||
EPhysicalControllerID x0_key;
|
||||
bool x4_active;
|
||||
CPhysicalID(EPhysicalControllerID key, bool active) : x0_key(key), x4_active(active) {}
|
||||
bool x4_repeat;
|
||||
CPhysicalID(EPhysicalControllerID key, bool repeat) : x0_key(key), x4_repeat(repeat) {}
|
||||
};
|
||||
using PhysicalMap = std::unordered_map<EPhysicalControllerID, CPhysicalID>;
|
||||
|
||||
CGuiPhysicalMsg(const PhysicalMap& map);
|
||||
bool Exists(const CGuiPhysicalMsg& other) const;
|
||||
void SetMessage(const PhysicalMap& map, bool pressed);
|
||||
static void AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool pressed);
|
||||
static void AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool repeat);
|
||||
|
||||
enum class ControllerState
|
||||
enum class EControllerState
|
||||
{
|
||||
NotFound = -1,
|
||||
NotPressed = 0,
|
||||
Pressed = 1
|
||||
NotPressed = -1,
|
||||
Press = 0,
|
||||
PressRepeat = 1
|
||||
};
|
||||
static ControllerState FindControllerID(const PhysicalMap& map, EPhysicalControllerID key);
|
||||
static EControllerState FindControllerID(const PhysicalMap& map, EPhysicalControllerID key);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -74,50 +74,50 @@ CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode)
|
|||
AddFactories(mode);
|
||||
LoadWidgetFunctions();
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::Seventeen,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::Seventeen, EPhysicalControllerID::Eighteen)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadUpInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::DPadUpInst, EPhysicalControllerID::DPadUp)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::Nineteen,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::Nineteen, EPhysicalControllerID::Twenty)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadRightInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::DPadRightInst, EPhysicalControllerID::DPadRight)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::TwentyOne,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::TwentyOne, EPhysicalControllerID::TwentyTwo)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadDownInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::DPadDownInst, EPhysicalControllerID::DPadDown)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::TwentyThree,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::TwentyThree, EPhysicalControllerID::TwentyFour)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadLeftInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::DPadLeftInst, EPhysicalControllerID::DPadLeft)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::ThirtyFive,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::ThirtyFive, EPhysicalControllerID::ThirtySix)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickRightInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickRightInst, EPhysicalControllerID::LeftStickRight)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::ThirtySeven,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::ThirtySeven, EPhysicalControllerID::ThirtyEight)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickDownInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickDownInst, EPhysicalControllerID::LeftStickDown)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::ThirtyNine,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::ThirtyNine, EPhysicalControllerID::Forty)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickLeftInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickLeftInst, EPhysicalControllerID::LeftStickLeft)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::FortyOne,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::FortyOne, EPhysicalControllerID::FortyTwo)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickUpInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::RightStickUpInst, EPhysicalControllerID::RightStickUp)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::FortyThree,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::FortyThree, EPhysicalControllerID::FortyFour)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickRightInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::RightStickRightInst, EPhysicalControllerID::RightStickRight)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::FortyFive,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::FortyFive, EPhysicalControllerID::FortySix)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickDownInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::RightStickDownInst, EPhysicalControllerID::RightStickDown)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::FortySeven,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::FortySeven, EPhysicalControllerID::FortyEight)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickLeftInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::RightStickLeftInst, EPhysicalControllerID::RightStickLeft)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::TwentyFive,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::TwentyFive, EPhysicalControllerID::TwentySix)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftUpInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftUpInst, EPhysicalControllerID::LeftUp)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::TwentySeven,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::TwentySeven, EPhysicalControllerID::TwentyEight)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftRightInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftRightInst, EPhysicalControllerID::LeftRight)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::TwentyNine,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::TwentyNine, EPhysicalControllerID::Thirty)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftDownInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftDownInst, EPhysicalControllerID::LeftDown)));
|
||||
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::ThirtyOne,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::ThirtyOne, EPhysicalControllerID::ThirtyTwo)));
|
||||
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftLeftInst,
|
||||
CGuiAutoRepeatData(EPhysicalControllerID::LeftLeftInst, EPhysicalControllerID::LeftLeft)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode);
|
||||
|
||||
CSimplePool& GetResStore() {return x4_resStore;}
|
||||
std::unordered_map<EPhysicalControllerID, CGuiAutoRepeatData>& GetRepeatMap() {return x18_repeatMap;}
|
||||
EUsageMode GetUsageMode() const {return x2c_mode;}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "CGuiFrame.hpp"
|
||||
#include "CGuiAnimController.hpp"
|
||||
#include "CGuiLogicalEventTrigger.hpp"
|
||||
#include "CGuiMessage.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
@ -61,6 +62,10 @@ CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool CGuiWidget::Message(const CGuiMessage& msg)
|
||||
{
|
||||
}
|
||||
|
||||
void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms)
|
||||
{
|
||||
CGuiWidget* parent = frame->FindWidget(parms.x8_parentId);
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool);
|
||||
static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
|
||||
|
||||
virtual void Message(const CGuiMessage& msg);
|
||||
virtual bool Message(const CGuiMessage& msg);
|
||||
virtual void ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms);
|
||||
virtual void ParseMessages(CInputStream& in, const CGuiWidgetParms& parms);
|
||||
virtual void ParseAnimations(CInputStream& in, const CGuiWidgetParms& parms);
|
||||
|
|
|
@ -76,4 +76,6 @@ add_library(RuntimeCommonGuiSys
|
|||
CGuiBackground.cpp
|
||||
CGuiBackground.hpp
|
||||
CGuiPane.cpp
|
||||
CGuiPane.hpp)
|
||||
CGuiPane.hpp
|
||||
CGuiMessage.cpp
|
||||
CGuiMessage.hpp)
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
CFinalInput& operator|=(const CFinalInput& other);
|
||||
bool operator==(const CFinalInput& other)
|
||||
{ return memcmp(this, &other, sizeof(CFinalInput)) == 0; }
|
||||
u32 controllerIdx() const {return x4_controllerIdx;}
|
||||
|
||||
bool PStart() const {return x2e_b31_PStart;}
|
||||
bool PR() const {return x2e_b26_PR;}
|
||||
|
@ -141,6 +142,13 @@ public:
|
|||
float ALALeft() const {return x8_anaLeftX < 0.0 ? -x8_anaLeftX : 0.0;}
|
||||
float ALADown() const {return xc_anaLeftY < 0.0 ? -xc_anaLeftY : 0.0;}
|
||||
float ALAUp() const {return xc_anaLeftY > 0.0 ? xc_anaLeftY : 0.0;}
|
||||
|
||||
float ALeftX() const {return x8_anaLeftX;}
|
||||
float ALeftY() const {return xc_anaLeftY;}
|
||||
float ARightX() const {return x10_anaRightX;}
|
||||
float ARightY() const {return x14_anaRightY;}
|
||||
float ALeftTrigger() const {return x18_anaLeftTrigger;}
|
||||
float ARightTrigger() const {return x1c_anaRightTrigger;}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit a243ad75836a77bc0560207c2db53fc4ec39fcb5
|
||||
Subproject commit 64ff101b73f5c639ab592adbcd54e9b20064eaf3
|
Loading…
Reference in New Issue