Pad: Add button name -> code lookup functions
This commit is contained in:
parent
8930383c96
commit
c1710482df
4 changed files with 58 additions and 1 deletions
|
|
@ -72,3 +72,33 @@ std::shared_ptr<DigitalController> DigitalController::Create()
|
|||
{
|
||||
return std::make_shared<DigitalController>();
|
||||
}
|
||||
|
||||
std::optional<s32> DigitalController::GetButtonCodeByName(std::string_view button_name)
|
||||
{
|
||||
#define BUTTON(name) \
|
||||
if (button_name == #name) \
|
||||
{ \
|
||||
return static_cast<s32>(ZeroExtend32(static_cast<u8>(Button::name))); \
|
||||
}
|
||||
|
||||
BUTTON(Select);
|
||||
BUTTON(L3);
|
||||
BUTTON(R3);
|
||||
BUTTON(Start);
|
||||
BUTTON(Up);
|
||||
BUTTON(Right);
|
||||
BUTTON(Down);
|
||||
BUTTON(Left);
|
||||
BUTTON(L2);
|
||||
BUTTON(R2);
|
||||
BUTTON(L1);
|
||||
BUTTON(R1);
|
||||
BUTTON(Triangle);
|
||||
BUTTON(Circle);
|
||||
BUTTON(Cross);
|
||||
BUTTON(Square);
|
||||
|
||||
return std::nullopt;
|
||||
|
||||
#undef BUTTON
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue