hotkeys work

This commit is contained in:
R2DLiu 2020-07-16 18:05:24 -04:00
commit 10588ff22c
9 changed files with 56 additions and 49 deletions

View file

@ -17,6 +17,9 @@ project(dolphin-emu)
# unique name here. # unique name here.
set(DISTRIBUTOR "None" CACHE STRING "Name of the distributor.") set(DISTRIBUTOR "None" CACHE STRING "Name of the distributor.")
# Slippi Playback build option
add_compile_definitions(IS_PLAYBACK)
if(UNIX AND NOT APPLE AND NOT ANDROID) if(UNIX AND NOT APPLE AND NOT ANDROID)
option(ENABLE_X11 "Enables X11 Support" ON) option(ENABLE_X11 "Enables X11 Support" ON)
endif() endif()

View file

@ -20,7 +20,6 @@ namespace Common
#define SLIPPI_REV_STR "2.1.1" #define SLIPPI_REV_STR "2.1.1"
#define IS_PLAYBACK 1
const std::string scm_slippi_semver_str = SLIPPI_REV_STR; const std::string scm_slippi_semver_str = SLIPPI_REV_STR;
#ifdef IS_PLAYBACK #ifdef IS_PLAYBACK

View file

@ -1168,7 +1168,7 @@ void CEXISlippi::prepareFrameData(u8* payload)
g_playbackStatus->lastFrame = m_current_game->GetLatestIndex(); g_playbackStatus->lastFrame = m_current_game->GetLatestIndex();
auto isNextFrameFound = g_playbackStatus->lastFrame > frameIndex; auto isNextFrameFound = g_playbackStatus->lastFrame > frameIndex;
auto isFrameComplete = checkFrameFullyFetched(frameIndex); auto isFrameComplete = checkFrameFullyFetched(frameIndex);
auto isFrameReady = !g_playbackStatus->shouldPause && isFrameFound && (isProcessingComplete || isNextFrameFound || isFrameComplete); auto isFrameReady = isFrameFound && (isProcessingComplete || isNextFrameFound || isFrameComplete);
// If there is a startFrame configured, manage the fast-forward flag // If there is a startFrame configured, manage the fast-forward flag
if (watchSettings.startFrame > Slippi::GAME_FIRST_FRAME) if (watchSettings.startFrame > Slippi::GAME_FIRST_FRAME)

View file

@ -232,7 +232,6 @@ void SlippiPlaybackStatus::SeekToFrame()
} }
targetFrameNum = INT_MAX; targetFrameNum = INT_MAX;
shouldPause = false;
Core::SetState(prevState); Core::SetState(prevState);
seekMtx.unlock(); seekMtx.unlock();
} else { } else {

View file

@ -19,7 +19,6 @@ public:
bool shouldJumpBack = false; bool shouldJumpBack = false;
bool shouldJumpForward = false; bool shouldJumpForward = false;
bool inSlippiPlayback = false; bool inSlippiPlayback = false;
volatile bool shouldPause = false;
volatile bool shouldRunThreads = false; volatile bool shouldRunThreads = false;
bool isHardFFW = false; bool isHardFFW = false;
bool isSoftFFW = false; bool isSoftFFW = false;

View file

@ -234,7 +234,7 @@ void HotkeyScheduler::Run()
if (device != nullptr) if (device != nullptr)
std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)->UpdateSyncButtonState( std::static_pointer_cast<IOS::HLE::Device::BluetoothBase>(device)->UpdateSyncButtonState(
IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
} }
if (SConfig::GetInstance().bEnableDebugging) if (SConfig::GetInstance().bEnableDebugging)
@ -267,7 +267,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_TOGGLE_USB_KEYBOARD)) if (IsHotkey(HK_TOGGLE_USB_KEYBOARD))
{ {
Settings::Instance().SetUSBKeyboardConnected( Settings::Instance().SetUSBKeyboardConnected(
!Settings::Instance().IsUSBKeyboardConnected()); !Settings::Instance().IsUSBKeyboardConnected());
} }
} }
@ -313,9 +313,9 @@ void HotkeyScheduler::Run()
auto ShowVolume = []() { auto ShowVolume = []() {
OSD::AddMessage(std::string("Volume: ") + OSD::AddMessage(std::string("Volume: ") +
(SConfig::GetInstance().m_IsMuted ? (SConfig::GetInstance().m_IsMuted ?
"Muted" : "Muted" :
std::to_string(SConfig::GetInstance().m_Volume) + "%")); std::to_string(SConfig::GetInstance().m_Volume) + "%"));
}; };
// Volume // Volume
@ -401,20 +401,20 @@ void HotkeyScheduler::Run()
auto ShowXFBCopies = []() { auto ShowXFBCopies = []() {
OSD::AddMessage(StringFromFormat( OSD::AddMessage(StringFromFormat(
"Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "", "Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "",
Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM")); Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM"));
}; };
if (IsHotkey(HK_TOGGLE_XFBCOPIES)) if (IsHotkey(HK_TOGGLE_XFBCOPIES))
{ {
Config::SetCurrent(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, Config::SetCurrent(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM,
!Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM)); !Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM));
ShowXFBCopies(); ShowXFBCopies();
} }
if (IsHotkey(HK_TOGGLE_IMMEDIATE_XFB)) if (IsHotkey(HK_TOGGLE_IMMEDIATE_XFB))
{ {
Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB, Config::SetCurrent(Config::GFX_HACK_IMMEDIATE_XFB,
!Config::Get(Config::GFX_HACK_IMMEDIATE_XFB)); !Config::Get(Config::GFX_HACK_IMMEDIATE_XFB));
ShowXFBCopies(); ShowXFBCopies();
} }
if (IsHotkey(HK_TOGGLE_FOG)) if (IsHotkey(HK_TOGGLE_FOG))
@ -434,10 +434,10 @@ void HotkeyScheduler::Run()
auto ShowEmulationSpeed = []() { auto ShowEmulationSpeed = []() {
OSD::AddMessage( OSD::AddMessage(
SConfig::GetInstance().m_EmulationSpeed <= 0 ? SConfig::GetInstance().m_EmulationSpeed <= 0 ?
"Speed Limit: Unlimited" : "Speed Limit: Unlimited" :
StringFromFormat("Speed Limit: %li%%", StringFromFormat("Speed Limit: %li%%",
std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f))); std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)));
}; };
if (IsHotkey(HK_DECREASE_EMULATION_SPEED)) if (IsHotkey(HK_DECREASE_EMULATION_SPEED))
@ -509,40 +509,45 @@ void HotkeyScheduler::Run()
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, ""); Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
} }
} }
}
#ifdef IS_PLAYBACK #ifdef IS_PLAYBACK
// Slippi Playback // Slippi Playback
if (IsHotkey(HK_SLIPPI_JUMP_BACK)) if (IsHotkey(HK_SLIPPI_JUMP_BACK))
{ {
if (g_playbackStatus->targetFrameNum == INT_MAX) { INFO_LOG(SLIPPI, "jump back");
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 1200; if (g_playbackStatus->targetFrameNum == INT_MAX) {
Host_PlaybackSeek(); g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 1200;
} Host_PlaybackSeek();
} }
}
if (IsHotkey(HK_SLIPPI_STEP_BACK)) if (IsHotkey(HK_SLIPPI_STEP_BACK))
{ {
if (g_playbackStatus->targetFrameNum == INT_MAX) { INFO_LOG(SLIPPI, "step back");
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 300; if (g_playbackStatus->targetFrameNum == INT_MAX) {
Host_PlaybackSeek(); g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame - 300;
} Host_PlaybackSeek();
} }
}
if (IsHotkey(HK_SLIPPI_STEP_FORWARD)) if (IsHotkey(HK_SLIPPI_STEP_FORWARD))
{ {
if (g_playbackStatus->targetFrameNum == INT_MAX) { INFO_LOG(SLIPPI, "step forward");
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 300; if (g_playbackStatus->targetFrameNum == INT_MAX) {
Host_PlaybackSeek(); g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 300;
} Host_PlaybackSeek();
} }
}
if (IsHotkey(HK_SLIPPI_JUMP_FORWARD)) if (IsHotkey(HK_SLIPPI_JUMP_FORWARD))
{ {
if (g_playbackStatus->targetFrameNum == INT_MAX) { INFO_LOG(SLIPPI, "jump forward");
g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 1200; if (g_playbackStatus->targetFrameNum == INT_MAX) {
Host_PlaybackSeek(); g_playbackStatus->targetFrameNum = g_playbackStatus->currentPlaybackFrame + 1200;
} Host_PlaybackSeek();
} }
}
#endif #endif
const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH); const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH);
@ -552,7 +557,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_INCREASE_DEPTH, true)) if (IsHotkey(HK_INCREASE_DEPTH, true))
Config::SetCurrent(Config::GFX_STEREO_DEPTH, Config::SetCurrent(Config::GFX_STEREO_DEPTH,
std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM)); std::min(stereo_depth + 1, Config::GFX_STEREO_DEPTH_MAXIMUM));
const auto stereo_convergence = Config::Get(Config::GFX_STEREO_CONVERGENCE); const auto stereo_convergence = Config::Get(Config::GFX_STEREO_CONVERGENCE);
@ -561,7 +566,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_INCREASE_CONVERGENCE, true)) if (IsHotkey(HK_INCREASE_CONVERGENCE, true))
Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE, Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE,
std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM)); std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM));
// Freelook // Freelook
static float fl_speed = 1.0; static float fl_speed = 1.0;

View file

@ -42,7 +42,7 @@ add_library(videocommon
HiresTextures.cpp HiresTextures.cpp
HiresTextures.h HiresTextures.h
HiresTextures_DDSLoader.cpp HiresTextures_DDSLoader.cpp
IconsFontAwesome4.h IconsFontAwesome4.h
ImageWrite.cpp ImageWrite.cpp
ImageWrite.h ImageWrite.h
IndexGenerator.cpp IndexGenerator.cpp

View file

@ -3,7 +3,6 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <chrono>
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <string> #include <string>
@ -18,10 +17,12 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/Timer.h" #include "Common/Timer.h"
#include "Core/Core.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/Slippi/SlippiPlayback.h" #include "Core/Slippi/SlippiPlayback.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/IconsFontAwesome4.h" #include "VideoCommon/IconsFontAwesome4.h"
@ -46,6 +47,7 @@ struct Message
}; };
static std::multimap<MessageType, Message> s_messages; static std::multimap<MessageType, Message> s_messages;
static std::mutex s_messages_mutex; static std::mutex s_messages_mutex;
static s32 frame = 0; static s32 frame = 0;
static std::string GetTimeForFrame(s32 currFrame) { static std::string GetTimeForFrame(s32 currFrame) {
@ -422,9 +424,7 @@ void DrawSlippiPlaybackControls()
} }
ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 30)); ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 30));
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5f, 0.45f)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5f, 0.45f));
//auto const paused = g_playbackStatus->shouldPause;
//if (ButtonCustom(paused ? ICON_FA_PLAY : ICON_FA_PAUSE, ImVec2(40.0f, 32.0f))) { //if (ButtonCustom(paused ? ICON_FA_PLAY : ICON_FA_PAUSE, ImVec2(40.0f, 32.0f))) {
// g_playbackStatus->shouldPause = !paused;
// INFO_LOG(SLIPPI, "playing"); // INFO_LOG(SLIPPI, "playing");
//} //}
//ImGui::SameLine(0.0f, 5.0f); //ImGui::SameLine(0.0f, 5.0f);

View file

@ -919,12 +919,14 @@ bool Renderer::InitializeImGui()
return false; return false;
} }
#ifdef IS_PLAYBACK
ImFontConfig config; ImFontConfig config;
config.MergeMode = true; config.MergeMode = true;
ImGui::GetIO().Fonts->AddFontFromFileTTF("Roboto-Medium.ttf", 14.0f, 0, ImGui::GetIO().Fonts->GetGlyphRangesDefault()); ImGui::GetIO().Fonts->AddFontFromFileTTF("Roboto-Medium.ttf", 14.0f, 0, ImGui::GetIO().Fonts->GetGlyphRangesDefault());
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
ImGui::GetIO().Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_FA, 16.0f, &icons_config, icons_ranges); ImGui::GetIO().Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_FA, 16.0f, &icons_config, icons_ranges);
#endif
// Don't create an ini file. TODO: Do we want this in the future? // Don't create an ini file. TODO: Do we want this in the future?
ImGui::GetIO().IniFilename = nullptr; ImGui::GetIO().IniFilename = nullptr;