Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Implement hotkeys #5510

Merged
merged 1 commit into from Jun 6, 2017
Merged

Qt: Implement hotkeys #5510

merged 1 commit into from Jun 6, 2017

Conversation

spycrab
Copy link
Contributor

@spycrab spycrab commented Jun 1, 2017

Adds hotkeys (+ configuration windows) to Qt.
Screenshot

void Hotkey3D::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

class HotkeyScheduler
{
public:
HotkeyScheduler(MainWindow* parent);

This comment was marked as off-topic.

public:
HotkeyScheduler(MainWindow* parent);

void stop();

This comment was marked as off-topic.

void start();

private:
void run();

This comment was marked as off-topic.

@@ -76,6 +78,8 @@ private slots:
void ShowControllersWindow();
void ShowAboutDialog();

void OpenConfigureHotkeys();

This comment was marked as off-topic.

void HotkeyScheduler::stop()
{
m_stop_requested = true;
m_thread.join();

This comment was marked as off-topic.

void HotkeyScheduler::start()
{
m_stop_requested = false;
m_thread = std::thread([this] { run(); });

This comment was marked as off-topic.

bool m_stop_requested;
MainWindow* m_parent;
std::thread m_thread;
};

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -47,11 +49,13 @@ MainWindow::MainWindow() : QMainWindow(nullptr)
ConnectMenuBar();

InitControllers();

This comment was marked as off-topic.

if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true))
fl_speed *= 1.1f;

if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true))

This comment was marked as off-topic.

if (IsHotkey(HK_FREELOOK_RIGHT, true))
VertexShaderManager::TranslateView(-fl_speed, 0.0);

if (IsHotkey(HK_FREELOOK_RIGHT, true))

This comment was marked as off-topic.

@spycrab spycrab force-pushed the qt_hotkeys branch 3 times, most recently from b83d505 to 57af249 Compare June 3, 2017 11:47
@@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

#include "DolphinQt2/MainWindow.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"

#include "InputCommon/ControllerInterface/ControllerInterface.h"

MainWindow::MainWindow() : QMainWindow(nullptr)
MainWindow::MainWindow() : QMainWindow(nullptr), m_hotkey_window(new MappingWindow(this, 0))

This comment was marked as off-topic.

void MainWindow::ShowHotkeyDialog()
{
HotkeyManagerEmu::Enable(false);
m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS);

This comment was marked as off-topic.

AboutDialog* about = new AboutDialog(this);
about->show();
HotkeyManagerEmu::Enable(true);

This comment was marked as off-topic.

This comment was marked as off-topic.

void MenuBar::AddOptionsMenu()
{
QMenu* options_menu = addMenu(tr("Options"));
options_menu->addAction(tr("Hotkey Settings"), [this] { emit ConfigureHotkeys(); });

This comment was marked as off-topic.

if (g_Config.iStereoMode != STEREO_SBS)
{
// Disable post-processing shader, as stereoscopy itself is currently a shader
if (g_Config.sPostProcessingShader == "dubois")

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.


// Exit
if (IsHotkey(HK_EXIT))
QCoreApplication::exit();

This comment was marked as off-topic.


// Fullscreen
if (IsHotkey(HK_FULLSCREEN))
m_parent->FullScreen();

This comment was marked as off-topic.

IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
}
// TODO Debugging shortcuts (Separate PR)
Common::SleepCurrentThread(1000 / 60);

This comment was marked as off-topic.

{
m_stop_requested = false;
m_thread = std::thread(&HotkeyScheduler::Run, this);
m_thread.detach();

This comment was marked as off-topic.

@spycrab spycrab force-pushed the qt_hotkeys branch 11 times, most recently from 8d514fb to 946581b Compare June 5, 2017 21:35
@spycrab
Copy link
Contributor Author

spycrab commented Jun 5, 2017

Would you mind taking a look again, @ligfx?

@MayImilae
Copy link
Contributor

Please upload a new screenshot now that #5503 has been merged. It should make the window look a lot nicer!

@spycrab spycrab force-pushed the qt_hotkeys branch 2 times, most recently from 78b3f82 to 5296cc3 Compare June 5, 2017 22:06
@spycrab
Copy link
Contributor Author

spycrab commented Jun 5, 2017

@MayImilae Updated screenshot


#include "Core/HotkeyManager.h"

QInputDialog::QInputDialog(QWidget* parent) : QDialog(parent)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"

constexpr const char* DUBOIS_ALGORITHM_SHADER = "dubois";

This comment was marked as off-topic.


void HotkeyScheduler::Stop()
{
m_stop_requested.Set(true);

This comment was marked as off-topic.

This comment was marked as off-topic.

State::UndoSaveState();
}

Common::SleepCurrentThread(1000 / 60);

This comment was marked as off-topic.

g_controller_interface.Shutdown();
Pad::Shutdown();
Keyboard::Shutdown();
Wiimote::Shutdown();
HotkeyManagerEmu::Shutdown();

delete m_hotkey_scheduler;

This comment was marked as off-topic.

void MainWindow::ShowHotkeyDialog()
{
m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS);
m_hotkey_window->show();

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@spycrab spycrab force-pushed the qt_hotkeys branch 2 times, most recently from 38219e0 to fd35105 Compare June 6, 2017 11:23
@shuffle2
Copy link
Contributor

shuffle2 commented Jun 6, 2017

Is it really proper to poll all the hotkey states instead of acting on events?

@spycrab
Copy link
Contributor Author

spycrab commented Jun 6, 2017

@shuffle2 I don't think there's another way as this is handled by InputCommon. Also Wx handles it in the same fashion.

@phire
Copy link
Member

phire commented Jun 6, 2017

It's input common which is wrong here.

It should be fixed, but fixing it is kind of out of scope of this PR.

@ligfx
Copy link
Contributor

ligfx commented Jun 6, 2017

Yeah, InputCommon is all polling-driven, not event-driven.

@shuffle2
Copy link
Contributor

shuffle2 commented Jun 6, 2017

well i'm glad we agree it sucks

@shuffle2 shuffle2 merged commit 03c1a1e into dolphin-emu:master Jun 6, 2017
@leoetlino leoetlino modified the milestone: Qt Sep 13, 2017
@spycrab spycrab deleted the qt_hotkeys branch April 14, 2018 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants