Pad: Add button name -> code lookup functions
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user