mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-10 20:05:47 -04:00
Frontend: Dynamic button mapping based on controller type
This commit is contained in:
@ -43,10 +43,15 @@ std::optional<s32> Controller::GetButtonCodeByName(ControllerType type, std::str
|
||||
switch (type)
|
||||
{
|
||||
case ControllerType::DigitalController:
|
||||
return DigitalController::GetButtonCodeByName(button_name);
|
||||
return DigitalController::StaticGetButtonCodeByName(button_name);
|
||||
|
||||
case ControllerType::None:
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<s32> Controller::GetButtonCodeByName(std::string_view button_name) const
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -12,6 +12,12 @@ public:
|
||||
Controller();
|
||||
virtual ~Controller();
|
||||
|
||||
/// Returns the type of controller.
|
||||
virtual ControllerType GetType() const = 0;
|
||||
|
||||
/// Gets the integer code for a button in the specified controller type.
|
||||
virtual std::optional<s32> GetButtonCodeByName(std::string_view button_name) const;
|
||||
|
||||
virtual void Reset();
|
||||
virtual bool DoState(StateWrapper& sw);
|
||||
|
||||
|
@ -6,6 +6,16 @@ DigitalController::DigitalController() = default;
|
||||
|
||||
DigitalController::~DigitalController() = default;
|
||||
|
||||
ControllerType DigitalController::GetType() const
|
||||
{
|
||||
return ControllerType::DigitalController;
|
||||
}
|
||||
|
||||
std::optional<s32> DigitalController::GetButtonCodeByName(std::string_view button_name) const
|
||||
{
|
||||
return StaticGetButtonCodeByName(button_name);
|
||||
}
|
||||
|
||||
void DigitalController::SetButtonState(Button button, bool pressed)
|
||||
{
|
||||
if (pressed)
|
||||
@ -81,7 +91,7 @@ std::unique_ptr<DigitalController> DigitalController::Create()
|
||||
return std::make_unique<DigitalController>();
|
||||
}
|
||||
|
||||
std::optional<s32> DigitalController::GetButtonCodeByName(std::string_view button_name)
|
||||
std::optional<s32> DigitalController::StaticGetButtonCodeByName(std::string_view button_name)
|
||||
{
|
||||
#define BUTTON(name) \
|
||||
if (button_name == #name) \
|
||||
|
@ -32,7 +32,10 @@ public:
|
||||
~DigitalController() override;
|
||||
|
||||
static std::unique_ptr<DigitalController> Create();
|
||||
static std::optional<s32> GetButtonCodeByName(std::string_view button_name);
|
||||
static std::optional<s32> StaticGetButtonCodeByName(std::string_view button_name);
|
||||
|
||||
ControllerType GetType() const override;
|
||||
std::optional<s32> GetButtonCodeByName(std::string_view button_name) const override;
|
||||
|
||||
void SetButtonState(Button button, bool pressed);
|
||||
void SetButtonState(s32 button_code, bool pressed);
|
||||
|
Reference in New Issue
Block a user