mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 06:45:45 -04:00
Introduce ControllerInterface class, port SDL interface over
This breaks controller support in the SDL frontend until it's ported over to the common interface.
This commit is contained in:
@ -11,9 +11,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class ControllerInterface;
|
||||
|
||||
class CommonHostInterface : public HostInterface
|
||||
{
|
||||
public:
|
||||
friend ControllerInterface;
|
||||
|
||||
using HostKeyCode = s32;
|
||||
|
||||
using InputButtonHandler = std::function<void(bool)>;
|
||||
@ -29,8 +33,14 @@ public:
|
||||
|
||||
using HotkeyInfoList = std::vector<HotkeyInfo>;
|
||||
|
||||
virtual bool Initialize();
|
||||
virtual void Shutdown();
|
||||
|
||||
/// Returns a list of all available hotkeys.
|
||||
const HotkeyInfoList& GetHotkeyInfoList() const { return m_hotkeys; }
|
||||
ALWAYS_INLINE const HotkeyInfoList& GetHotkeyInfoList() const { return m_hotkeys; }
|
||||
|
||||
/// Access to current controller interface.
|
||||
ALWAYS_INLINE ControllerInterface* GetControllerInterface() const { return m_controller_interface.get(); }
|
||||
|
||||
protected:
|
||||
CommonHostInterface();
|
||||
@ -40,28 +50,36 @@ protected:
|
||||
virtual void ToggleFullscreen();
|
||||
|
||||
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override;
|
||||
virtual std::unique_ptr<ControllerInterface> CreateControllerInterface();
|
||||
|
||||
virtual void OnSystemCreated() override;
|
||||
virtual void OnSystemPaused(bool paused) override;
|
||||
virtual void OnControllerTypeChanged(u32 slot) override;
|
||||
|
||||
virtual void SetDefaultSettings(SettingsInterface& si) override;
|
||||
|
||||
virtual std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const;
|
||||
|
||||
virtual bool AddButtonToInputMap(const std::string& binding, const std::string_view& device,
|
||||
const std::string_view& button, InputButtonHandler handler);
|
||||
virtual bool AddAxisToInputMap(const std::string& binding, const std::string_view& device,
|
||||
const std::string_view& axis, InputAxisHandler handler);
|
||||
|
||||
/// Reloads the input map from config. Callable from controller interface.
|
||||
virtual void UpdateInputMap() = 0;
|
||||
|
||||
void RegisterHotkey(String category, String name, String display_name, InputButtonHandler handler);
|
||||
bool HandleHostKeyEvent(HostKeyCode code, bool pressed);
|
||||
void UpdateInputMap(SettingsInterface& si);
|
||||
|
||||
std::unique_ptr<ControllerInterface> m_controller_interface;
|
||||
|
||||
private:
|
||||
void RegisterGeneralHotkeys();
|
||||
void RegisterGraphicsHotkeys();
|
||||
void RegisterSaveStateHotkeys();
|
||||
void UpdateControllerInputMap(SettingsInterface& si);
|
||||
void UpdateHotkeyInputMap(SettingsInterface& si);
|
||||
virtual bool AddButtonToInputMap(const std::string& binding, const std::string_view& device,
|
||||
const std::string_view& button, InputButtonHandler handler);
|
||||
virtual bool AddAxisToInputMap(const std::string& binding, const std::string_view& device,
|
||||
const std::string_view& axis, InputAxisHandler handler);
|
||||
|
||||
HotkeyInfoList m_hotkeys;
|
||||
|
||||
|
Reference in New Issue
Block a user