mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 12:15:45 -04:00
Allow keyboard binding in nogui/fullscreen mode (#1679)
* Allow keyboard binding in nogui/fullscreen mode
This commit is contained in:
@ -36,6 +36,12 @@ void ControllerInterface::ClearHook()
|
||||
m_event_intercept_callback = {};
|
||||
}
|
||||
|
||||
bool ControllerInterface::HasHook()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_event_intercept_mutex);
|
||||
return (bool)m_event_intercept_callback;
|
||||
}
|
||||
|
||||
bool ControllerInterface::DoEventHook(Hook::Type type, int controller_index, int button_or_axis_number,
|
||||
std::variant<float, std::string_view> value, bool track_history)
|
||||
{
|
||||
|
@ -113,6 +113,7 @@ public:
|
||||
};
|
||||
void SetHook(Hook::Callback callback);
|
||||
void ClearHook();
|
||||
bool HasHook();
|
||||
|
||||
protected:
|
||||
bool DoEventHook(Hook::Type type, int controller_index, int button_or_axis_number,
|
||||
|
@ -141,6 +141,7 @@ static InputBindingType s_input_binding_type = InputBindingType::None;
|
||||
static TinyString s_input_binding_section;
|
||||
static TinyString s_input_binding_key;
|
||||
static TinyString s_input_binding_display_name;
|
||||
static bool s_input_binding_keyboard_pressed;
|
||||
static Common::Timer s_input_binding_timer;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -816,6 +817,34 @@ static void ClearInputBindingVariables()
|
||||
s_input_binding_display_name.Clear();
|
||||
}
|
||||
|
||||
bool HandleKeyboardBinding(const char* keyName, bool pressed)
|
||||
{
|
||||
if (s_input_binding_type == InputBindingType::None)
|
||||
return false;
|
||||
|
||||
if (pressed)
|
||||
{
|
||||
s_input_binding_keyboard_pressed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!s_input_binding_keyboard_pressed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TinyString value;
|
||||
value.Format("Keyboard/%s", keyName);
|
||||
|
||||
s_host_interface->GetSettingsInterface()->SetStringValue(s_input_binding_section, s_input_binding_key, value);
|
||||
s_host_interface->AddFormattedOSDMessage(5.0f, "Set %s binding %s to %s.", s_input_binding_section.GetCharArray(),
|
||||
s_input_binding_display_name.GetCharArray(), value.GetCharArray());
|
||||
|
||||
EndInputBinding();
|
||||
s_host_interface->RunLater(SaveAndApplySettings);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BeginInputBinding(InputBindingType type, const std::string_view& section, const std::string_view& key,
|
||||
const std::string_view& display_name)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ void OpenQuickMenu();
|
||||
void CloseQuickMenu();
|
||||
void Shutdown();
|
||||
void Render();
|
||||
bool HandleKeyboardBinding(const char* keyName, bool pressed);
|
||||
|
||||
bool InvalidateCachedTexture(const std::string& path);
|
||||
|
||||
|
Reference in New Issue
Block a user