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.
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)
option(ENABLE_X11 "Enables X11 Support" ON)
endif()

View file

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

View file

@ -1168,7 +1168,7 @@ void CEXISlippi::prepareFrameData(u8* payload)
g_playbackStatus->lastFrame = m_current_game->GetLatestIndex();
auto isNextFrameFound = g_playbackStatus->lastFrame > 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 (watchSettings.startFrame > Slippi::GAME_FIRST_FRAME)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -919,12 +919,14 @@ bool Renderer::InitializeImGui()
return false;
}
#ifdef IS_PLAYBACK
ImFontConfig config;
config.MergeMode = true;
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 };
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);
#endif
// Don't create an ini file. TODO: Do we want this in the future?
ImGui::GetIO().IniFilename = nullptr;