mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-09-29 07:21:20 +00:00
Qt: Enable game window shortcuts
This commit is contained in:
parent
ad3d8675e7
commit
e58a89af2d
@ -435,34 +435,7 @@ void keyboard_pad_handler::processKeyEvent(QKeyEvent* event, bool pressed)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to ignore keys when using rpcs3 keyboard shortcuts
|
|
||||||
// NOTE: needs to be updated with gs_frame::keyPressEvent
|
|
||||||
switch (event->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_Escape:
|
|
||||||
case Qt::Key_F11:
|
|
||||||
case Qt::Key_F12:
|
|
||||||
break;
|
|
||||||
case Qt::Key_L:
|
|
||||||
if (event->modifiers() != Qt::AltModifier && event->modifiers() != Qt::ControlModifier)
|
|
||||||
handle_key();
|
handle_key();
|
||||||
break;
|
|
||||||
case Qt::Key_Return:
|
|
||||||
if (event->modifiers() != Qt::AltModifier)
|
|
||||||
handle_key();
|
|
||||||
break;
|
|
||||||
case Qt::Key_P:
|
|
||||||
case Qt::Key_S:
|
|
||||||
case Qt::Key_R:
|
|
||||||
case Qt::Key_E:
|
|
||||||
case Qt::Key_0:
|
|
||||||
if (event->modifiers() != Qt::ControlModifier)
|
|
||||||
handle_key();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
handle_key();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +123,8 @@ gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon,
|
|||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable in Qt6
|
m_shortcut_handler = new shortcut_handler(gui::shortcuts::shortcut_handler_id::game_window, this, m_gui_settings);
|
||||||
//m_shortcut_handler = new shortcut_handler(gui::shortcuts::shortcut_handler_id::game_window, this, m_gui_settings);
|
connect(m_shortcut_handler, &shortcut_handler::shortcut_activated, this, &gs_frame::handle_shortcut);
|
||||||
//connect(m_shortcut_handler, &shortcut_handler::shortcut_activated, this, &gs_frame::handle_shortcut);
|
|
||||||
|
|
||||||
// Change cursor when in fullscreen.
|
// Change cursor when in fullscreen.
|
||||||
connect(this, &QWindow::visibilityChanged, this, [this](QWindow::Visibility visibility)
|
connect(this, &QWindow::visibilityChanged, this, [this](QWindow::Visibility visibility)
|
||||||
@ -178,6 +177,14 @@ void gs_frame::load_gui_settings()
|
|||||||
m_hide_mouse_idletime = m_gui_settings->GetValue(gui::gs_hideMouseIdleTime).toUInt();
|
m_hide_mouse_idletime = m_gui_settings->GetValue(gui::gs_hideMouseIdleTime).toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gs_frame::update_shortcuts()
|
||||||
|
{
|
||||||
|
if (m_shortcut_handler)
|
||||||
|
{
|
||||||
|
m_shortcut_handler->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gs_frame::paintEvent(QPaintEvent *event)
|
void gs_frame::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
@ -226,94 +233,6 @@ void gs_frame::showEvent(QShowEvent *event)
|
|||||||
QWindow::showEvent(event);
|
QWindow::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove when shortcuts are properly hooked up (also check keyboard_pad_handler::processKeyEvent)
|
|
||||||
void gs_frame::keyPressEvent(QKeyEvent *keyEvent)
|
|
||||||
{
|
|
||||||
if (keyEvent->isAutoRepeat())
|
|
||||||
{
|
|
||||||
keyEvent->ignore();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: needs to be updated with keyboard_pad_handler::processKeyEvent
|
|
||||||
|
|
||||||
switch (keyEvent->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_L:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::AltModifier)
|
|
||||||
{
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_log_mark, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
{
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_mouse_lock, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_Return:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::AltModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_toggle_fullscreen, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_Escape:
|
|
||||||
{
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_exit_fullscreen, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_P:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_pause_play, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_S:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_savestate, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_R:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_restart, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_C:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::AltModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_rsx_capture, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_F10:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_frame_limit, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_F11:
|
|
||||||
{
|
|
||||||
if (keyEvent->modifiers() == Qt::ControlModifier)
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_toggle_mouse_and_keyboard, {});
|
|
||||||
else
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_toggle_recording, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Qt::Key_F12:
|
|
||||||
{
|
|
||||||
handle_shortcut(gui::shortcuts::shortcut::gw_screenshot, {});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void gs_frame::handle_shortcut(gui::shortcuts::shortcut shortcut_key, const QKeySequence& key_sequence)
|
void gs_frame::handle_shortcut(gui::shortcuts::shortcut shortcut_key, const QKeySequence& key_sequence)
|
||||||
{
|
{
|
||||||
gui_log.notice("Game window registered shortcut: %s (%s)", shortcut_key, key_sequence.toString());
|
gui_log.notice("Game window registered shortcut: %s (%s)", shortcut_key, key_sequence.toString());
|
||||||
|
@ -24,6 +24,8 @@ private:
|
|||||||
// taskbar progress
|
// taskbar progress
|
||||||
std::unique_ptr<progress_indicator> m_progress_indicator;
|
std::unique_ptr<progress_indicator> m_progress_indicator;
|
||||||
|
|
||||||
|
shortcut_handler* m_shortcut_handler = nullptr;
|
||||||
|
|
||||||
QRect m_initial_geometry;
|
QRect m_initial_geometry;
|
||||||
|
|
||||||
std::shared_ptr<gui_settings> m_gui_settings;
|
std::shared_ptr<gui_settings> m_gui_settings;
|
||||||
@ -55,6 +57,8 @@ public:
|
|||||||
void delete_context(draw_context_t context) override;
|
void delete_context(draw_context_t context) override;
|
||||||
void toggle_fullscreen() override;
|
void toggle_fullscreen() override;
|
||||||
|
|
||||||
|
void update_shortcuts();
|
||||||
|
|
||||||
// taskbar progress
|
// taskbar progress
|
||||||
void progress_reset(bool reset_limit = false);
|
void progress_reset(bool reset_limit = false);
|
||||||
void progress_set_value(int value);
|
void progress_set_value(int value);
|
||||||
@ -75,8 +79,6 @@ protected:
|
|||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *keyEvent) override;
|
|
||||||
|
|
||||||
void close() override;
|
void close() override;
|
||||||
|
|
||||||
bool shown() override;
|
bool shown() override;
|
||||||
|
@ -309,6 +309,7 @@ void gui_application::InitializeConnects()
|
|||||||
connect(m_main_window, &main_window::RequestLanguageChange, this, &gui_application::LoadLanguage);
|
connect(m_main_window, &main_window::RequestLanguageChange, this, &gui_application::LoadLanguage);
|
||||||
connect(m_main_window, &main_window::RequestGlobalStylesheetChange, this, &gui_application::OnChangeStyleSheetRequest);
|
connect(m_main_window, &main_window::RequestGlobalStylesheetChange, this, &gui_application::OnChangeStyleSheetRequest);
|
||||||
connect(m_main_window, &main_window::NotifyEmuSettingsChange, this, [this](){ OnEmuSettingsChange(); });
|
connect(m_main_window, &main_window::NotifyEmuSettingsChange, this, [this](){ OnEmuSettingsChange(); });
|
||||||
|
connect(m_main_window, &main_window::NotifyShortcutHandlers, this, &gui_application::OnShortcutChange);
|
||||||
|
|
||||||
connect(this, &gui_application::OnEmulatorRun, m_main_window, &main_window::OnEmuRun);
|
connect(this, &gui_application::OnEmulatorRun, m_main_window, &main_window::OnEmuRun);
|
||||||
connect(this, &gui_application::OnEmulatorStop, m_main_window, &main_window::OnEmuStop);
|
connect(this, &gui_application::OnEmulatorStop, m_main_window, &main_window::OnEmuStop);
|
||||||
@ -1031,6 +1032,14 @@ void gui_application::OnChangeStyleSheetRequest()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gui_application::OnShortcutChange()
|
||||||
|
{
|
||||||
|
if (m_game_window)
|
||||||
|
{
|
||||||
|
static_cast<gs_frame*>(m_game_window)->update_shortcuts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Using connects avoids timers being unable to be used in a non-qt thread. So, even if this looks stupid to just call func, it's succinct.
|
* Using connects avoids timers being unable to be used in a non-qt thread. So, even if this looks stupid to just call func, it's succinct.
|
||||||
*/
|
*/
|
||||||
|
@ -121,6 +121,7 @@ private:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void OnChangeStyleSheetRequest();
|
void OnChangeStyleSheetRequest();
|
||||||
|
void OnShortcutChange();
|
||||||
void OnAppStateChanged(Qt::ApplicationState state);
|
void OnAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -2762,7 +2762,11 @@ void main_window::CreateConnects()
|
|||||||
connect(ui->confShortcutsAct, &QAction::triggered, [this]()
|
connect(ui->confShortcutsAct, &QAction::triggered, [this]()
|
||||||
{
|
{
|
||||||
shortcut_dialog dlg(m_gui_settings, this);
|
shortcut_dialog dlg(m_gui_settings, this);
|
||||||
connect(&dlg, &shortcut_dialog::saved, m_shortcut_handler, &shortcut_handler::update);
|
connect(&dlg, &shortcut_dialog::saved, this, [this]()
|
||||||
|
{
|
||||||
|
m_shortcut_handler->update();
|
||||||
|
NotifyShortcutHandlers();
|
||||||
|
});
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ Q_SIGNALS:
|
|||||||
void RequestDialogRepaint();
|
void RequestDialogRepaint();
|
||||||
void NotifyEmuSettingsChange();
|
void NotifyEmuSettingsChange();
|
||||||
void NotifyWindowCloseEvent(bool closed);
|
void NotifyWindowCloseEvent(bool closed);
|
||||||
|
void NotifyShortcutHandlers();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void OnEmuStop();
|
void OnEmuStop();
|
||||||
|
@ -43,9 +43,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="game_window_group_box">
|
<widget class="QGroupBox" name="game_window_group_box">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Game Window Shortcuts</string>
|
<string>Game Window Shortcuts</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
LOG_CHANNEL(shortcut_log, "Shortcuts");
|
LOG_CHANNEL(shortcut_log, "Shortcuts");
|
||||||
|
|
||||||
shortcut_handler::shortcut_handler(gui::shortcuts::shortcut_handler_id handler_id, QWidget* parent, const std::shared_ptr<gui_settings>& gui_settings)
|
shortcut_handler::shortcut_handler(gui::shortcuts::shortcut_handler_id handler_id, QObject* parent, const std::shared_ptr<gui_settings>& gui_settings)
|
||||||
: QObject(parent), m_handler_id(handler_id), m_gui_settings(gui_settings)
|
: QObject(parent), m_handler_id(handler_id), m_gui_settings(gui_settings)
|
||||||
{
|
{
|
||||||
// Initialize shortcuts
|
// Initialize shortcuts
|
||||||
|
@ -13,7 +13,7 @@ class shortcut_handler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
shortcut_handler(gui::shortcuts::shortcut_handler_id handler_id, QWidget* parent, const std::shared_ptr<gui_settings>& gui_settings);
|
shortcut_handler(gui::shortcuts::shortcut_handler_id handler_id, QObject* parent, const std::shared_ptr<gui_settings>& gui_settings);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void shortcut_activated(gui::shortcuts::shortcut shortcut_key, const QKeySequence& key_sequence);
|
void shortcut_activated(gui::shortcuts::shortcut shortcut_key, const QKeySequence& key_sequence);
|
||||||
|
@ -78,6 +78,9 @@ gui_save shortcut_settings::get_shortcut_gui_save(const QString& shortcut_name)
|
|||||||
|
|
||||||
QKeySequence shortcut_settings::get_key_sequence(const shortcut_info& entry, const std::shared_ptr<gui_settings>& gui_settings)
|
QKeySequence shortcut_settings::get_key_sequence(const shortcut_info& entry, const std::shared_ptr<gui_settings>& gui_settings)
|
||||||
{
|
{
|
||||||
|
if (!gui_settings)
|
||||||
|
return {};
|
||||||
|
|
||||||
const QString saved_value = gui_settings->GetValue(get_shortcut_gui_save(entry.name)).toString();
|
const QString saved_value = gui_settings->GetValue(get_shortcut_gui_save(entry.name)).toString();
|
||||||
|
|
||||||
QKeySequence key_sequence = QKeySequence::fromString(saved_value);
|
QKeySequence key_sequence = QKeySequence::fromString(saved_value);
|
||||||
|
Loading…
Reference in New Issue
Block a user