mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #12815 from Dentomologist/enable_hotkeys_and_controllers_for_focused_tas_input
TAS Input: Enable emulator hotkeys and controller input when TAS Input window has focus
This commit is contained in:
@ -162,6 +162,11 @@ bool Host::GetGBAFocus()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Host::GetTASInputFocus() const
|
||||
{
|
||||
return m_tas_input_focus;
|
||||
}
|
||||
|
||||
bool Host::GetRenderFullscreen()
|
||||
{
|
||||
return m_render_fullscreen;
|
||||
@ -177,6 +182,11 @@ void Host::SetRenderFullscreen(bool fullscreen)
|
||||
}
|
||||
}
|
||||
|
||||
void Host::SetTASInputFocus(const bool focus)
|
||||
{
|
||||
m_tas_input_focus = focus;
|
||||
}
|
||||
|
||||
void Host::ResizeSurface(int new_width, int new_height)
|
||||
{
|
||||
if (g_presenter)
|
||||
@ -228,6 +238,11 @@ bool Host_RendererIsFullscreen()
|
||||
return Host::GetInstance()->GetRenderFullscreen();
|
||||
}
|
||||
|
||||
bool Host_TASInputHasFocus()
|
||||
{
|
||||
return Host::GetInstance()->GetTASInputFocus();
|
||||
}
|
||||
|
||||
void Host_YieldToUI()
|
||||
{
|
||||
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
@ -25,12 +25,14 @@ public:
|
||||
bool GetRenderFullFocus();
|
||||
bool GetRenderFullscreen();
|
||||
bool GetGBAFocus();
|
||||
bool GetTASInputFocus() const;
|
||||
|
||||
void SetMainWindowHandle(void* handle);
|
||||
void SetRenderHandle(void* handle);
|
||||
void SetRenderFocus(bool focus);
|
||||
void SetRenderFullFocus(bool focus);
|
||||
void SetRenderFullscreen(bool fullscreen);
|
||||
void SetTASInputFocus(bool focus);
|
||||
void ResizeSurface(int new_width, int new_height);
|
||||
|
||||
signals:
|
||||
@ -49,4 +51,5 @@ private:
|
||||
std::atomic<bool> m_render_focus{false};
|
||||
std::atomic<bool> m_render_full_focus{false};
|
||||
std::atomic<bool> m_render_fullscreen{false};
|
||||
std::atomic<bool> m_tas_input_focus{false};
|
||||
};
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QEvent>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@ -17,6 +19,7 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/QtUtils/AspectRatioWidget.h"
|
||||
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
||||
#include "DolphinQt/Resources.h"
|
||||
@ -268,3 +271,16 @@ std::optional<ControlState> TASInputWindow::GetSpinBox(TASSpinBox* spin, int zer
|
||||
|
||||
return (spin->GetValue() - zero) / scale;
|
||||
}
|
||||
|
||||
void TASInputWindow::changeEvent(QEvent* const event)
|
||||
{
|
||||
if (event->type() == QEvent::ActivationChange)
|
||||
{
|
||||
const bool active_window_is_tas_input =
|
||||
qobject_cast<TASInputWindow*>(QApplication::activeWindow()) != nullptr;
|
||||
|
||||
// Switching between TAS Input windows will call SetTASInputFocus(true) twice, but that's fine.
|
||||
Host::GetInstance()->SetTASInputFocus(active_window_is_tas_input);
|
||||
}
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
class QBoxLayout;
|
||||
class QCheckBox;
|
||||
class QDialog;
|
||||
class QEvent;
|
||||
class QGroupBox;
|
||||
class QSpinBox;
|
||||
class QString;
|
||||
@ -68,6 +69,8 @@ protected:
|
||||
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
|
||||
QWidget* shortcut_widget);
|
||||
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
QGroupBox* m_settings_box;
|
||||
QCheckBox* m_use_controller;
|
||||
QSpinBox* m_turbo_press_frames;
|
||||
|
Reference in New Issue
Block a user