2017-06-06 11:49:49 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/HotkeyScheduler.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
2018-10-09 14:26:31 +00:00
|
|
|
#include <cmath>
|
2017-06-06 11:49:49 +00:00
|
|
|
#include <thread>
|
|
|
|
|
2022-10-12 02:21:51 +00:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2021-07-04 11:26:47 +00:00
|
|
|
#include <QApplication>
|
2017-06-06 11:49:49 +00:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
#include "AudioCommon/AudioCommon.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-15 03:20:59 +00:00
|
|
|
#include "Common/Config/Config.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "Common/Thread.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2020-06-12 05:27:34 +00:00
|
|
|
#include "Core/Config/FreeLookSettings.h"
|
2018-05-11 17:06:30 +00:00
|
|
|
#include "Core/Config/GraphicsSettings.h"
|
2021-10-14 00:29:04 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2020-02-07 23:56:13 +00:00
|
|
|
#include "Core/Config/UISettings.h"
|
2017-06-22 22:11:53 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "Core/Core.h"
|
2020-06-12 05:27:34 +00:00
|
|
|
#include "Core/FreeLookManager.h"
|
2020-02-07 23:56:13 +00:00
|
|
|
#include "Core/Host.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "Core/HotkeyManager.h"
|
|
|
|
#include "Core/IOS/IOS.h"
|
|
|
|
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
2021-04-12 10:49:29 +00:00
|
|
|
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "Core/State.h"
|
2021-04-12 10:49:29 +00:00
|
|
|
#include "Core/WiiUtils.h"
|
2018-05-10 22:58:30 +00:00
|
|
|
|
2021-07-04 11:26:47 +00:00
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
#include "DolphinQt/GBAWidget.h"
|
|
|
|
#endif
|
|
|
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
2018-05-10 22:58:30 +00:00
|
|
|
|
2019-11-06 21:59:36 +00:00
|
|
|
#include "InputCommon/ControlReference/ControlReference.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2018-05-10 22:58:30 +00:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
2017-06-06 11:49:49 +00:00
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
|
|
|
constexpr const char* DUBOIS_ALGORITHM_SHADER = "dubois";
|
|
|
|
|
|
|
|
HotkeyScheduler::HotkeyScheduler() : m_stop_requested(false)
|
|
|
|
{
|
|
|
|
HotkeyManagerEmu::Enable(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
HotkeyScheduler::~HotkeyScheduler()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotkeyScheduler::Start()
|
|
|
|
{
|
|
|
|
m_stop_requested.Set(false);
|
|
|
|
m_thread = std::thread(&HotkeyScheduler::Run, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotkeyScheduler::Stop()
|
|
|
|
{
|
|
|
|
m_stop_requested.Set(true);
|
|
|
|
|
|
|
|
if (m_thread.joinable())
|
|
|
|
m_thread.join();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsHotkey(int id, bool held = false)
|
|
|
|
{
|
|
|
|
return HotkeyManagerEmu::IsPressed(id, held);
|
|
|
|
}
|
|
|
|
|
2018-08-09 08:32:32 +00:00
|
|
|
static void HandleFrameStepHotkeys()
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
2018-08-09 08:32:32 +00:00
|
|
|
constexpr int MAX_FRAME_STEP_DELAY = 60;
|
2017-06-06 11:49:49 +00:00
|
|
|
constexpr int FRAME_STEP_DELAY = 30;
|
|
|
|
|
|
|
|
static int frame_step_count = 0;
|
|
|
|
static int frame_step_delay = 1;
|
|
|
|
static int frame_step_delay_count = 0;
|
|
|
|
static bool frame_step_hold = false;
|
|
|
|
|
|
|
|
if (IsHotkey(HK_FRAME_ADVANCE_INCREASE_SPEED))
|
|
|
|
{
|
2021-10-16 03:22:22 +00:00
|
|
|
frame_step_delay = std::max(frame_step_delay - 1, 0);
|
2017-06-06 11:49:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_FRAME_ADVANCE_DECREASE_SPEED))
|
|
|
|
{
|
2021-10-16 03:22:22 +00:00
|
|
|
frame_step_delay = std::min(frame_step_delay + 1, MAX_FRAME_STEP_DELAY);
|
2017-06-06 11:49:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_FRAME_ADVANCE_RESET_SPEED))
|
|
|
|
{
|
|
|
|
frame_step_delay = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_FRAME_ADVANCE, true))
|
|
|
|
{
|
|
|
|
if (frame_step_delay_count < frame_step_delay && frame_step_hold)
|
|
|
|
frame_step_delay_count++;
|
|
|
|
|
2018-02-09 11:54:35 +00:00
|
|
|
if ((frame_step_count == 0 || frame_step_count == FRAME_STEP_DELAY) && !frame_step_hold)
|
|
|
|
{
|
|
|
|
Core::DoFrameStep();
|
|
|
|
frame_step_hold = true;
|
|
|
|
}
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (frame_step_count < FRAME_STEP_DELAY)
|
|
|
|
{
|
2018-02-09 11:54:35 +00:00
|
|
|
frame_step_count++;
|
|
|
|
frame_step_hold = false;
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame_step_count == FRAME_STEP_DELAY && frame_step_hold &&
|
|
|
|
frame_step_delay_count >= frame_step_delay)
|
|
|
|
{
|
|
|
|
frame_step_hold = false;
|
|
|
|
frame_step_delay_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2018-02-09 11:54:35 +00:00
|
|
|
else if (frame_step_count > 0)
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
|
|
|
// Reset frame advance
|
|
|
|
frame_step_count = 0;
|
|
|
|
frame_step_hold = false;
|
|
|
|
frame_step_delay_count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotkeyScheduler::Run()
|
|
|
|
{
|
2020-08-22 09:55:31 +00:00
|
|
|
Common::SetCurrentThreadName("HotkeyScheduler");
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
while (!m_stop_requested.IsSet())
|
|
|
|
{
|
2021-03-18 16:03:12 +00:00
|
|
|
Common::SleepCurrentThread(5);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2020-12-26 01:11:21 +00:00
|
|
|
g_controller_interface.SetCurrentInputChannel(ciface::InputChannel::FreeLook);
|
|
|
|
g_controller_interface.UpdateInput();
|
|
|
|
FreeLook::UpdateInput();
|
|
|
|
|
2020-04-21 04:16:07 +00:00
|
|
|
g_controller_interface.SetCurrentInputChannel(ciface::InputChannel::Host);
|
|
|
|
g_controller_interface.UpdateInput();
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2019-10-26 15:01:27 +00:00
|
|
|
if (!HotkeyManagerEmu::IsEnabled())
|
|
|
|
continue;
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (Core::GetState() != Core::State::Stopping)
|
|
|
|
{
|
2020-02-07 23:56:13 +00:00
|
|
|
// Obey window focus (config permitting) before checking hotkeys.
|
|
|
|
Core::UpdateInputGate(Config::Get(Config::MAIN_FOCUSED_HOTKEYS));
|
2019-11-06 21:59:36 +00:00
|
|
|
|
2021-07-04 11:26:47 +00:00
|
|
|
HotkeyManagerEmu::GetStatus(false);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2019-11-06 21:59:36 +00:00
|
|
|
// Everything else on the host thread (controller config dialog) should always get input.
|
|
|
|
ControlReference::SetInputGate(true);
|
|
|
|
|
2021-07-04 11:26:47 +00:00
|
|
|
HotkeyManagerEmu::GetStatus(true);
|
|
|
|
|
2021-09-23 05:17:12 +00:00
|
|
|
// Open
|
2018-05-09 06:27:04 +00:00
|
|
|
if (IsHotkey(HK_OPEN))
|
|
|
|
emit Open();
|
|
|
|
|
2021-09-23 05:17:12 +00:00
|
|
|
// Refresh Game List
|
|
|
|
if (IsHotkey(HK_REFRESH_LIST))
|
|
|
|
emit RefreshGameListHotkey();
|
|
|
|
|
|
|
|
// Recording
|
|
|
|
if (IsHotkey(HK_START_RECORDING))
|
|
|
|
emit StartRecording();
|
|
|
|
|
|
|
|
// Exit
|
|
|
|
if (IsHotkey(HK_EXIT))
|
|
|
|
emit ExitHotkey();
|
|
|
|
|
|
|
|
if (!Core::IsRunningAndStarted())
|
2021-09-24 14:31:36 +00:00
|
|
|
{
|
|
|
|
// Only check for Play Recording hotkey when no game is running
|
|
|
|
if (IsHotkey(HK_PLAY_RECORDING))
|
|
|
|
emit PlayRecording();
|
|
|
|
|
2021-09-23 05:17:12 +00:00
|
|
|
continue;
|
2021-09-24 14:31:36 +00:00
|
|
|
}
|
2021-09-23 05:17:12 +00:00
|
|
|
|
2018-05-09 06:27:04 +00:00
|
|
|
// Disc
|
|
|
|
|
|
|
|
if (IsHotkey(HK_EJECT_DISC))
|
|
|
|
emit EjectDisc();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_CHANGE_DISC))
|
|
|
|
emit ChangeDisc();
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Fullscreen
|
|
|
|
if (IsHotkey(HK_FULLSCREEN))
|
2018-05-18 07:20:02 +00:00
|
|
|
{
|
2017-06-06 11:49:49 +00:00
|
|
|
emit FullScreenHotkey();
|
|
|
|
|
2018-05-18 07:20:02 +00:00
|
|
|
// Prevent fullscreen from getting toggled too often
|
|
|
|
Common::SleepCurrentThread(100);
|
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Pause and Unpause
|
|
|
|
if (IsHotkey(HK_PLAY_PAUSE))
|
2018-02-09 11:54:35 +00:00
|
|
|
emit TogglePauseHotkey();
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
// Stop
|
|
|
|
if (IsHotkey(HK_STOP))
|
|
|
|
emit StopHotkey();
|
|
|
|
|
2018-05-12 01:56:10 +00:00
|
|
|
// Reset
|
|
|
|
if (IsHotkey(HK_RESET))
|
|
|
|
emit ResetHotkey();
|
|
|
|
|
2018-08-09 08:32:32 +00:00
|
|
|
// Frame advance
|
|
|
|
HandleFrameStepHotkeys();
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
// Screenshot
|
|
|
|
if (IsHotkey(HK_SCREENSHOT))
|
|
|
|
emit ScreenShotHotkey();
|
|
|
|
|
2021-05-09 10:28:04 +00:00
|
|
|
// Unlock Cursor
|
|
|
|
if (IsHotkey(HK_UNLOCK_CURSOR))
|
|
|
|
emit UnlockCursor();
|
|
|
|
|
2022-07-15 18:31:44 +00:00
|
|
|
if (IsHotkey(HK_CENTER_MOUSE, true))
|
|
|
|
g_controller_interface.SetMouseCenteringRequested(true);
|
|
|
|
|
2017-06-21 08:26:06 +00:00
|
|
|
auto& settings = Settings::Instance();
|
|
|
|
|
2019-03-24 14:57:36 +00:00
|
|
|
// Toggle Chat
|
|
|
|
if (IsHotkey(HK_ACTIVATE_CHAT))
|
|
|
|
emit ActivateChat();
|
|
|
|
|
2019-04-02 12:08:27 +00:00
|
|
|
if (IsHotkey(HK_REQUEST_GOLF_CONTROL))
|
|
|
|
emit RequestGolfControl();
|
|
|
|
|
2017-09-03 00:58:38 +00:00
|
|
|
if (IsHotkey(HK_EXPORT_RECORDING))
|
|
|
|
emit ExportRecording();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_READ_ONLY_MODE))
|
|
|
|
emit ToggleReadOnlyMode();
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Wiimote
|
2021-04-12 10:49:29 +00:00
|
|
|
if (auto bt = WiiUtils::GetBluetoothRealDevice())
|
|
|
|
bt->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2021-12-31 02:00:39 +00:00
|
|
|
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING))
|
2018-05-13 21:39:44 +00:00
|
|
|
{
|
2018-05-13 22:12:31 +00:00
|
|
|
CheckDebuggingHotkeys();
|
2018-05-13 21:39:44 +00:00
|
|
|
}
|
2018-02-14 22:25:01 +00:00
|
|
|
|
|
|
|
// TODO: HK_MBP_ADD
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
if (SConfig::GetInstance().bWii)
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
|
|
|
int wiimote_id = -1;
|
|
|
|
if (IsHotkey(HK_WIIMOTE1_CONNECT))
|
|
|
|
wiimote_id = 0;
|
|
|
|
if (IsHotkey(HK_WIIMOTE2_CONNECT))
|
|
|
|
wiimote_id = 1;
|
|
|
|
if (IsHotkey(HK_WIIMOTE3_CONNECT))
|
|
|
|
wiimote_id = 2;
|
|
|
|
if (IsHotkey(HK_WIIMOTE4_CONNECT))
|
|
|
|
wiimote_id = 3;
|
|
|
|
if (IsHotkey(HK_BALANCEBOARD_CONNECT))
|
|
|
|
wiimote_id = 4;
|
|
|
|
|
2018-01-24 14:25:35 +00:00
|
|
|
if (wiimote_id > -1)
|
|
|
|
emit ConnectWiiRemote(wiimote_id);
|
2018-08-02 10:55:30 +00:00
|
|
|
|
2019-07-03 20:34:07 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_SD_CARD))
|
|
|
|
Settings::Instance().SetSDCardInserted(!Settings::Instance().IsSDCardInserted());
|
|
|
|
|
2018-08-02 10:55:30 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_USB_KEYBOARD))
|
|
|
|
{
|
|
|
|
Settings::Instance().SetUSBKeyboardConnected(
|
|
|
|
!Settings::Instance().IsUSBKeyboardConnected());
|
|
|
|
}
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
2018-04-22 21:27:10 +00:00
|
|
|
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_1))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfile(0);
|
|
|
|
else if (IsHotkey(HK_NEXT_WIIMOTE_PROFILE_1))
|
|
|
|
m_profile_cycler.NextWiimoteProfile(0);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_2))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfile(1);
|
|
|
|
else if (IsHotkey(HK_NEXT_WIIMOTE_PROFILE_2))
|
|
|
|
m_profile_cycler.NextWiimoteProfile(1);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_3))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfile(2);
|
|
|
|
else if (IsHotkey(HK_NEXT_WIIMOTE_PROFILE_3))
|
|
|
|
m_profile_cycler.NextWiimoteProfile(2);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_4))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfile(3);
|
|
|
|
else if (IsHotkey(HK_NEXT_WIIMOTE_PROFILE_4))
|
|
|
|
m_profile_cycler.NextWiimoteProfile(3);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_GAME_WIIMOTE_PROFILE_1))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfileForGame(0);
|
|
|
|
else if (IsHotkey(HK_NEXT_GAME_WIIMOTE_PROFILE_1))
|
|
|
|
m_profile_cycler.NextWiimoteProfileForGame(0);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_GAME_WIIMOTE_PROFILE_2))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfileForGame(1);
|
|
|
|
else if (IsHotkey(HK_NEXT_GAME_WIIMOTE_PROFILE_2))
|
|
|
|
m_profile_cycler.NextWiimoteProfileForGame(1);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_GAME_WIIMOTE_PROFILE_3))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfileForGame(2);
|
|
|
|
else if (IsHotkey(HK_NEXT_GAME_WIIMOTE_PROFILE_3))
|
|
|
|
m_profile_cycler.NextWiimoteProfileForGame(2);
|
|
|
|
|
|
|
|
if (IsHotkey(HK_PREV_GAME_WIIMOTE_PROFILE_4))
|
|
|
|
m_profile_cycler.PreviousWiimoteProfileForGame(3);
|
|
|
|
else if (IsHotkey(HK_NEXT_GAME_WIIMOTE_PROFILE_4))
|
|
|
|
m_profile_cycler.NextWiimoteProfileForGame(3);
|
2018-04-17 05:43:56 +00:00
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
auto ShowVolume = []() {
|
|
|
|
OSD::AddMessage(std::string("Volume: ") +
|
2021-10-14 00:29:04 +00:00
|
|
|
(Config::Get(Config::MAIN_AUDIO_MUTED) ?
|
2018-10-09 14:26:31 +00:00
|
|
|
"Muted" :
|
2021-10-14 00:29:04 +00:00
|
|
|
std::to_string(Config::Get(Config::MAIN_AUDIO_VOLUME)) + "%"));
|
2018-05-11 15:09:39 +00:00
|
|
|
};
|
|
|
|
|
2018-06-05 21:34:28 +00:00
|
|
|
// Volume
|
|
|
|
if (IsHotkey(HK_VOLUME_DOWN))
|
|
|
|
{
|
|
|
|
settings.DecreaseVolume(3);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowVolume();
|
2018-06-05 21:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_VOLUME_UP))
|
|
|
|
{
|
|
|
|
settings.IncreaseVolume(3);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowVolume();
|
2018-06-05 21:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_VOLUME_TOGGLE_MUTE))
|
|
|
|
{
|
|
|
|
AudioCommon::ToggleMuteVolume();
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowVolume();
|
2018-06-05 21:34:28 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Graphics
|
2018-05-11 17:06:30 +00:00
|
|
|
const auto efb_scale = Config::Get(Config::GFX_EFB_SCALE);
|
2018-10-09 14:26:31 +00:00
|
|
|
auto ShowEFBScale = []() {
|
|
|
|
switch (Config::Get(Config::GFX_EFB_SCALE))
|
|
|
|
{
|
|
|
|
case EFB_SCALE_AUTO_INTEGRAL:
|
|
|
|
OSD::AddMessage("Internal Resolution: Auto (integral)");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
OSD::AddMessage("Internal Resolution: Native");
|
|
|
|
break;
|
|
|
|
default:
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format("Internal Resolution: {}x", g_Config.iEFBScale));
|
2018-10-09 14:26:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2018-05-11 17:06:30 +00:00
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_INCREASE_IR))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_EFB_SCALE, efb_scale + 1);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowEFBScale();
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_DECREASE_IR))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-05-11 17:06:30 +00:00
|
|
|
if (efb_scale > EFB_SCALE_AUTO_INTEGRAL)
|
2018-10-09 14:26:31 +00:00
|
|
|
{
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_EFB_SCALE, efb_scale - 1);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowEFBScale();
|
|
|
|
}
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_CROP))
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_CROP, !Config::Get(Config::GFX_CROP));
|
2018-05-10 22:58:30 +00:00
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_AR))
|
2017-11-11 03:45:32 +00:00
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
const int aspect_ratio = (static_cast<int>(Config::Get(Config::GFX_ASPECT_RATIO)) + 1) & 3;
|
|
|
|
Config::SetCurrent(Config::GFX_ASPECT_RATIO, static_cast<AspectMode>(aspect_ratio));
|
2018-10-09 14:26:31 +00:00
|
|
|
switch (static_cast<AspectMode>(aspect_ratio))
|
|
|
|
{
|
|
|
|
case AspectMode::Stretch:
|
|
|
|
OSD::AddMessage("Stretch");
|
|
|
|
break;
|
|
|
|
case AspectMode::Analog:
|
|
|
|
OSD::AddMessage("Force 4:3");
|
|
|
|
break;
|
|
|
|
case AspectMode::AnalogWide:
|
|
|
|
OSD::AddMessage("Force 16:9");
|
|
|
|
break;
|
|
|
|
case AspectMode::Auto:
|
|
|
|
default:
|
|
|
|
OSD::AddMessage("Auto");
|
|
|
|
break;
|
|
|
|
}
|
2017-11-11 03:45:32 +00:00
|
|
|
}
|
2020-10-30 00:03:06 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_TOGGLE_SKIP_EFB_ACCESS))
|
|
|
|
{
|
|
|
|
const bool new_value = !Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE);
|
|
|
|
Config::SetCurrent(Config::GFX_HACK_EFB_ACCESS_ENABLE, new_value);
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format("{} EFB Access from CPU", new_value ? "Skip" : "Don't skip"));
|
2020-10-30 00:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_EFBCOPIES))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
const bool new_value = !Config::Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
|
|
|
|
Config::SetCurrent(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, new_value);
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format("Copy EFB: {}", new_value ? "to Texture" : "to RAM"));
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
auto ShowXFBCopies = []() {
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format(
|
|
|
|
"Copy XFB: {}{}", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "",
|
2018-10-09 14:26:31 +00:00
|
|
|
Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM"));
|
|
|
|
};
|
|
|
|
|
2017-06-26 03:23:47 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_XFBCOPIES))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM,
|
|
|
|
!Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM));
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowXFBCopies();
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
2017-08-13 04:10:21 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_IMMEDIATE_XFB))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB,
|
|
|
|
!Config::Get(Config::GFX_HACK_IMMEDIATE_XFB));
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowXFBCopies();
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_FOG))
|
2018-05-10 22:58:30 +00:00
|
|
|
{
|
2018-10-09 14:26:31 +00:00
|
|
|
const bool new_value = !Config::Get(Config::GFX_DISABLE_FOG);
|
|
|
|
Config::SetCurrent(Config::GFX_DISABLE_FOG, new_value);
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format("Fog: {}", new_value ? "Enabled" : "Disabled"));
|
2018-05-10 22:58:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_DUMPTEXTURES))
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_DUMP_TEXTURES, !Config::Get(Config::GFX_DUMP_TEXTURES));
|
2018-05-10 22:58:30 +00:00
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_TEXTURES))
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_HIRES_TEXTURES, !Config::Get(Config::GFX_HIRES_TEXTURES));
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
Core::SetIsThrottlerTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true));
|
|
|
|
|
2018-10-09 14:26:31 +00:00
|
|
|
auto ShowEmulationSpeed = []() {
|
2022-01-05 22:22:07 +00:00
|
|
|
const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED);
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(emulation_speed <= 0 ?
|
|
|
|
"Speed Limit: Unlimited" :
|
|
|
|
fmt::format("Speed Limit: {}%", std::lround(emulation_speed * 100.f)));
|
2018-10-09 14:26:31 +00:00
|
|
|
};
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_DECREASE_EMULATION_SPEED))
|
|
|
|
{
|
2022-01-05 22:22:07 +00:00
|
|
|
auto speed = Config::Get(Config::MAIN_EMULATION_SPEED) - 0.1;
|
2017-06-06 11:49:49 +00:00
|
|
|
speed = (speed <= 0 || (speed >= 0.95 && speed <= 1.05)) ? 1.0 : speed;
|
2022-01-05 22:22:07 +00:00
|
|
|
Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowEmulationSpeed();
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_INCREASE_EMULATION_SPEED))
|
|
|
|
{
|
2022-01-05 22:22:07 +00:00
|
|
|
auto speed = Config::Get(Config::MAIN_EMULATION_SPEED) + 0.1;
|
2017-06-06 11:49:49 +00:00
|
|
|
speed = (speed >= 0.95 && speed <= 1.05) ? 1.0 : speed;
|
2022-01-05 22:22:07 +00:00
|
|
|
Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed);
|
2018-10-09 14:26:31 +00:00
|
|
|
ShowEmulationSpeed();
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Slot Saving / Loading
|
|
|
|
if (IsHotkey(HK_SAVE_STATE_SLOT_SELECTED))
|
|
|
|
emit StateSaveSlotHotkey();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED))
|
|
|
|
emit StateLoadSlotHotkey();
|
|
|
|
|
2022-08-07 17:20:09 +00:00
|
|
|
if (IsHotkey(HK_INCREMENT_SELECTED_STATE_SLOT))
|
|
|
|
emit IncrementSelectedStateSlotHotkey();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_DECREMENT_SELECTED_STATE_SLOT))
|
|
|
|
emit DecrementSelectedStateSlotHotkey();
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Stereoscopy
|
2018-06-16 19:38:14 +00:00
|
|
|
if (IsHotkey(HK_TOGGLE_STEREO_SBS))
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
if (Config::Get(Config::GFX_STEREO_MODE) != StereoMode::SBS)
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
|
|
|
// Disable post-processing shader, as stereoscopy itself is currently a shader
|
2018-05-11 17:06:30 +00:00
|
|
|
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) == DUBOIS_ALGORITHM_SHADER)
|
2018-05-11 18:34:39 +00:00
|
|
|
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2018-06-16 19:38:14 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::SBS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Off);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_TOGGLE_STEREO_TAB))
|
|
|
|
{
|
|
|
|
if (Config::Get(Config::GFX_STEREO_MODE) != StereoMode::TAB)
|
|
|
|
{
|
|
|
|
// Disable post-processing shader, as stereoscopy itself is currently a shader
|
|
|
|
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) == DUBOIS_ALGORITHM_SHADER)
|
|
|
|
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
|
|
|
|
|
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::TAB);
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Off);
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_TOGGLE_STEREO_ANAGLYPH))
|
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
if (Config::Get(Config::GFX_STEREO_MODE) != StereoMode::Anaglyph)
|
2017-06-06 11:49:49 +00:00
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Anaglyph);
|
2018-05-11 18:34:39 +00:00
|
|
|
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, DUBOIS_ALGORITHM_SHADER);
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-11 20:38:44 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Off);
|
2018-05-11 18:34:39 +00:00
|
|
|
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-04 11:26:47 +00:00
|
|
|
|
|
|
|
CheckGBAHotkeys();
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-11 17:06:30 +00:00
|
|
|
const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH);
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
if (IsHotkey(HK_DECREASE_DEPTH, true))
|
2020-02-07 21:47:40 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_DEPTH, std::max(stereo_depth - 1, 0));
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_INCREASE_DEPTH, true))
|
2020-02-07 21:47:40 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_DEPTH,
|
|
|
|
std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM));
|
2018-05-11 17:06:30 +00:00
|
|
|
|
|
|
|
const auto stereo_convergence = Config::Get(Config::GFX_STEREO_CONVERGENCE);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_DECREASE_CONVERGENCE, true))
|
2018-05-11 17:06:30 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE, std::max(stereo_convergence - 5, 0));
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_INCREASE_CONVERGENCE, true))
|
2020-02-07 21:47:40 +00:00
|
|
|
Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE,
|
|
|
|
std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM));
|
2017-06-06 11:49:49 +00:00
|
|
|
|
2020-06-12 05:27:34 +00:00
|
|
|
// Free Look
|
2020-01-31 20:45:08 +00:00
|
|
|
if (IsHotkey(HK_FREELOOK_TOGGLE))
|
|
|
|
{
|
2020-06-12 05:27:34 +00:00
|
|
|
const bool new_value = !Config::Get(Config::FREE_LOOK_ENABLED);
|
|
|
|
Config::SetCurrent(Config::FREE_LOOK_ENABLED, new_value);
|
2022-10-12 02:21:51 +00:00
|
|
|
OSD::AddMessage(fmt::format("Free Look: {}", new_value ? "Enabled" : "Disabled"));
|
2020-01-31 20:45:08 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
// Savestates
|
|
|
|
for (u32 i = 0; i < State::NUM_STATES; i++)
|
|
|
|
{
|
|
|
|
if (IsHotkey(HK_LOAD_STATE_SLOT_1 + i))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateLoadSlot(i + 1);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_SAVE_STATE_SLOT_1 + i))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateSaveSlot(i + 1);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_LOAD_LAST_STATE_1 + i))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateLoadLastSaved(i + 1);
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_SELECT_STATE_SLOT_1 + i))
|
|
|
|
emit SetStateSlotHotkey(i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsHotkey(HK_SAVE_FIRST_STATE))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateSaveOldest();
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_UNDO_LOAD_STATE))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateLoadUndo();
|
2017-06-06 11:49:49 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_UNDO_SAVE_STATE))
|
2018-05-17 18:27:14 +00:00
|
|
|
emit StateSaveUndo();
|
2018-07-01 14:14:29 +00:00
|
|
|
|
|
|
|
if (IsHotkey(HK_LOAD_STATE_FILE))
|
|
|
|
emit StateLoadFile();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_SAVE_STATE_FILE))
|
|
|
|
emit StateSaveFile();
|
2017-06-06 11:49:49 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-13 22:12:31 +00:00
|
|
|
|
|
|
|
void HotkeyScheduler::CheckDebuggingHotkeys()
|
|
|
|
{
|
|
|
|
if (IsHotkey(HK_STEP))
|
|
|
|
emit Step();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_STEP_OVER))
|
|
|
|
emit StepOver();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_STEP_OUT))
|
|
|
|
emit StepOut();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_SKIP))
|
|
|
|
emit Skip();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_SHOW_PC))
|
|
|
|
emit ShowPC();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_SET_PC))
|
|
|
|
emit Skip();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_BP_TOGGLE))
|
|
|
|
emit ToggleBreakpoint();
|
|
|
|
|
|
|
|
if (IsHotkey(HK_BP_ADD))
|
|
|
|
emit AddBreakpoint();
|
|
|
|
}
|
2021-07-04 11:26:47 +00:00
|
|
|
|
|
|
|
void HotkeyScheduler::CheckGBAHotkeys()
|
|
|
|
{
|
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
GBAWidget* gba_widget = qobject_cast<GBAWidget*>(QApplication::activeWindow());
|
|
|
|
if (!gba_widget)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_LOAD))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->LoadROM(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_UNLOAD))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->UnloadROM(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_RESET))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->ResetCore(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_VOLUME_DOWN))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->VolumeDown(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_VOLUME_UP))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->VolumeUp(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_TOGGLE_MUTE))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->ToggleMute(); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_1X))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(1); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_2X))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(2); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_3X))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(3); });
|
|
|
|
|
|
|
|
if (IsHotkey(HK_GBA_4X))
|
|
|
|
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(4); });
|
|
|
|
#endif
|
|
|
|
}
|