mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
ControllerInterface: Don't fire events when fullscreen UI active
This commit is contained in:
parent
00ffffe8c0
commit
a6d2324f0e
|
@ -3504,13 +3504,21 @@ std::unique_ptr<ByteStream> CommonHostInterface::OpenPackageFile(const char* pat
|
||||||
return FileSystem::OpenFile(full_path.c_str(), real_flags);
|
return FileSystem::OpenFile(full_path.c_str(), real_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonHostInterface::SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button,
|
bool CommonHostInterface::IsControllerNavigationActive() const
|
||||||
bool pressed)
|
|
||||||
{
|
{
|
||||||
if (!m_fullscreen_ui_enabled)
|
if (!m_fullscreen_ui_enabled)
|
||||||
return false;
|
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
|
#ifdef WITH_DISCORD_PRESENCE
|
||||||
|
|
|
@ -300,9 +300,11 @@ public:
|
||||||
/// This is the APK for Android builds, or the program directory for standalone builds.
|
/// 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;
|
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
|
/// Returns true if the fullscreen UI is intercepting controller input.
|
||||||
/// execute the normal handler.
|
bool IsControllerNavigationActive() const;
|
||||||
bool SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
|
|
||||||
|
/// Controller navigation, used by fullscreen mode.
|
||||||
|
void SetControllerNavigationButtonState(FrontendCommon::ControllerNavigationButton button, bool pressed);
|
||||||
|
|
||||||
/// Toggles fast forward state.
|
/// Toggles fast forward state.
|
||||||
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
|
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "core/controller.h"
|
#include "core/controller.h"
|
||||||
#include "core/host_interface.h"
|
#include "core/host_interface.h"
|
||||||
#include "core/system.h"
|
#include "core/system.h"
|
||||||
#include <cstdlib>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -334,8 +334,10 @@ bool EvdevControllerInterface::HandleButtonEvent(ControllerData* cd, u32 button,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const FrontendCommon::ControllerNavigationButton nav_button = MapEventButtonToNavigationButton(button_id);
|
const FrontendCommon::ControllerNavigationButton nav_button = MapEventButtonToNavigationButton(button_id);
|
||||||
if (nav_button < FrontendCommon::ControllerNavigationButton::Count &&
|
if (nav_button < FrontendCommon::ControllerNavigationButton::Count)
|
||||||
m_host_interface->SetControllerNavigationButtonState(nav_button, pressed))
|
m_host_interface->SetControllerNavigationButtonState(nav_button, pressed);
|
||||||
|
|
||||||
|
if (m_host_interface->IsControllerNavigationActive())
|
||||||
{
|
{
|
||||||
// UI consumed the event
|
// UI consumed the event
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -703,8 +703,12 @@ bool SDLControllerInterface::HandleControllerButtonEvent(const SDL_ControllerBut
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (ev->button < nav_button_mapping.size() &&
|
if (ev->button < nav_button_mapping.size() &&
|
||||||
nav_button_mapping[ev->button] != FrontendCommon::ControllerNavigationButton::Count &&
|
nav_button_mapping[ev->button] != FrontendCommon::ControllerNavigationButton::Count)
|
||||||
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[ev->button], pressed))
|
{
|
||||||
|
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[ev->button], pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_host_interface->IsControllerNavigationActive())
|
||||||
{
|
{
|
||||||
// UI consumed the event
|
// UI consumed the event
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -301,8 +301,12 @@ bool XInputControllerInterface::HandleButtonEvent(u32 index, u32 button, bool pr
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (button < nav_button_mapping.size() &&
|
if (button < nav_button_mapping.size() &&
|
||||||
nav_button_mapping[button] != FrontendCommon::ControllerNavigationButton::Count &&
|
nav_button_mapping[button] != FrontendCommon::ControllerNavigationButton::Count)
|
||||||
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[button], pressed))
|
{
|
||||||
|
m_host_interface->SetControllerNavigationButtonState(nav_button_mapping[button], pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_host_interface->IsControllerNavigationActive())
|
||||||
{
|
{
|
||||||
// UI consumed the event
|
// UI consumed the event
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue