ControllerInterface: Don't fire events when fullscreen UI active

This commit is contained in:
Connor McLaughlin 2021-05-13 13:58:57 +10:00
parent 00ffffe8c0
commit a6d2324f0e
5 changed files with 33 additions and 13 deletions

View file

@ -3504,13 +3504,21 @@ std::unique_ptr<ByteStream> CommonHostInterface::OpenPackageFile(const char* pat
return FileSystem::OpenFile(full_path.c_str(), real_flags);
}
bool CommonHostInterface::SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button,
bool pressed)
bool CommonHostInterface::IsControllerNavigationActive() const
{
if (!m_fullscreen_ui_enabled)
return false;
return FullscreenUI::SetControllerNavInput(button, pressed);
return FullscreenUI::HasActiveWindow();
}
void CommonHostInterface::SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button,
bool pressed)
{
if (!m_fullscreen_ui_enabled)
return;
FullscreenUI::SetControllerNavInput(button, pressed);
}
#ifdef WITH_DISCORD_PRESENCE

View file

@ -300,9 +300,11 @@ public:
/// This is the APK for Android builds, or the program directory for standalone builds.
virtual std::unique_ptr<ByteStream> OpenPackageFile(const char* path, u32 flags) override;
/// Controller navigation, used by fullscreen mode. Returns true if the UI consumed the event, and it should not
/// execute the normal handler.
bool SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
/// Returns true if the fullscreen UI is intercepting controller input.
bool IsControllerNavigationActive() const;
/// Controller navigation, used by fullscreen mode.
void SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
/// Toggles fast forward state.
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }

View file

@ -5,8 +5,8 @@
#include "core/controller.h"
#include "core/host_interface.h"
#include "core/system.h"
#include <cstdlib>
#include <cmath>
#include <cstdlib>
#include <fcntl.h>
#include <poll.h>
#include <unistd.h>
@ -334,8 +334,10 @@ bool EvdevControllerInterface::HandleButtonEvent(ControllerData* cd, u32 button,
return true;
const FrontendCommon::ControllerNavigationButton nav_button = MapEventButtonToNavigationButton(button_id);
if (nav_button < FrontendCommon::ControllerNavigationButton::Count &&
m_host_interface->SetControllerNavigationButtonState(nav_button, pressed))
if (nav_button < FrontendCommon::ControllerNavigationButton::Count)
m_host_interface->SetControllerNavigationButtonState(nav_button, pressed);
if (m_host_interface->IsControllerNavigationActive())
{
// UI consumed the event
return true;

View file

@ -703,8 +703,12 @@ bool SDLControllerInterface::HandleControllerButtonEvent(const SDL_ControllerBut
return true;
if (ev->button < nav_button_mapping.size() &&
nav_button_mapping[ev->button] != FrontendCommon::ControllerNavigationButton::Count &&
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[ev->button], pressed))
nav_button_mapping[ev->button] != FrontendCommon::ControllerNavigationButton::Count)
{
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[ev->button], pressed);
}
if (m_host_interface->IsControllerNavigationActive())
{
// UI consumed the event
return true;

View file

@ -301,8 +301,12 @@ bool XInputControllerInterface::HandleButtonEvent(u32 index, u32 button, bool pr
return true;
if (button < nav_button_mapping.size() &&
nav_button_mapping[button] != FrontendCommon::ControllerNavigationButton::Count &&
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[button], pressed))
nav_button_mapping[button] != FrontendCommon::ControllerNavigationButton::Count)
{
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[button], pressed);
}
if (m_host_interface->IsControllerNavigationActive())
{
// UI consumed the event
return true;