Merge pull request #3076 from void-ghost/stereo3d_presets
Stereo3d presets
This commit is contained in:
commit
81414b4fa2
|
@ -117,6 +117,12 @@ const std::string hotkey_labels[] =
|
||||||
_trans("Undo Save State"),
|
_trans("Undo Save State"),
|
||||||
_trans("Save State"),
|
_trans("Save State"),
|
||||||
_trans("Load State"),
|
_trans("Load State"),
|
||||||
|
|
||||||
|
_trans("Toggle 3D Preset"),
|
||||||
|
_trans("Use 3D Preset 1"),
|
||||||
|
_trans("Use 3D Preset 2"),
|
||||||
|
_trans("Use 3D Preset 3"),
|
||||||
|
|
||||||
};
|
};
|
||||||
static_assert(NUM_HOTKEYS == sizeof(hotkey_labels) / sizeof(hotkey_labels[0]), "Wrong count of hotkey_labels");
|
static_assert(NUM_HOTKEYS == sizeof(hotkey_labels) / sizeof(hotkey_labels[0]), "Wrong count of hotkey_labels");
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,11 @@ enum Hotkey
|
||||||
HK_SAVE_STATE_FILE,
|
HK_SAVE_STATE_FILE,
|
||||||
HK_LOAD_STATE_FILE,
|
HK_LOAD_STATE_FILE,
|
||||||
|
|
||||||
|
HK_SWITCH_STEREOSCOPY_PRESET,
|
||||||
|
HK_USE_STEREOSCOPY_PRESET_0,
|
||||||
|
HK_USE_STEREOSCOPY_PRESET_1,
|
||||||
|
HK_USE_STEREOSCOPY_PRESET_2,
|
||||||
|
|
||||||
NUM_HOTKEYS,
|
NUM_HOTKEYS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1416,29 +1416,73 @@ void CFrame::ParseHotkeys()
|
||||||
{
|
{
|
||||||
State::Load(g_saveSlot);
|
State::Load(g_saveSlot);
|
||||||
}
|
}
|
||||||
if (IsHotkey(HK_DECREASE_DEPTH, true))
|
|
||||||
|
auto savePreset = [](const std::string& param, int value)
|
||||||
|
{
|
||||||
|
IniFile localIni = SConfig::GetInstance().LoadLocalGameIni();
|
||||||
|
localIni.GetOrCreateSection("Enhancements")->Set(
|
||||||
|
StringFromFormat("Stereo%s_%d", param.c_str(), g_Config.iStereoActivePreset),
|
||||||
|
value);
|
||||||
|
std::string iniFileName = File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetUniqueID() + ".ini";
|
||||||
|
OSD::AddMessage(StringFromFormat("%s: %d", param.c_str(), value) , 1000);
|
||||||
|
localIni.Save(iniFileName);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (IsHotkey(HK_DECREASE_DEPTH))
|
||||||
{
|
{
|
||||||
if (--g_Config.iStereoDepth < 0)
|
if (--g_Config.iStereoDepth < 0)
|
||||||
g_Config.iStereoDepth = 0;
|
g_Config.iStereoDepth = 0;
|
||||||
|
g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth = g_Config.iStereoDepth;
|
||||||
|
savePreset("Depth", g_Config.iStereoDepth);
|
||||||
}
|
}
|
||||||
if (IsHotkey(HK_INCREASE_DEPTH, true))
|
if (IsHotkey(HK_INCREASE_DEPTH))
|
||||||
{
|
{
|
||||||
if (++g_Config.iStereoDepth > 100)
|
if (++g_Config.iStereoDepth > 100)
|
||||||
g_Config.iStereoDepth = 100;
|
g_Config.iStereoDepth = 100;
|
||||||
|
g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth = g_Config.iStereoDepth;
|
||||||
|
savePreset("Depth", g_Config.iStereoDepth);
|
||||||
}
|
}
|
||||||
if (IsHotkey(HK_DECREASE_CONVERGENCE, true))
|
if (IsHotkey(HK_DECREASE_CONVERGENCE))
|
||||||
{
|
{
|
||||||
g_Config.iStereoConvergence -= 5;
|
g_Config.iStereoConvergence -= 5;
|
||||||
if (g_Config.iStereoConvergence < 0)
|
if (g_Config.iStereoConvergence < 0)
|
||||||
g_Config.iStereoConvergence = 0;
|
g_Config.iStereoConvergence = 0;
|
||||||
|
g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence = g_Config.iStereoConvergence;
|
||||||
|
savePreset("Convergence", g_Config.iStereoConvergence);
|
||||||
}
|
}
|
||||||
if (IsHotkey(HK_INCREASE_CONVERGENCE, true))
|
if (IsHotkey(HK_INCREASE_CONVERGENCE))
|
||||||
{
|
{
|
||||||
g_Config.iStereoConvergence += 5;
|
g_Config.iStereoConvergence += 5;
|
||||||
if (g_Config.iStereoConvergence > 500)
|
if (g_Config.iStereoConvergence > 500)
|
||||||
g_Config.iStereoConvergence = 500;
|
g_Config.iStereoConvergence = 500;
|
||||||
|
g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence = g_Config.iStereoConvergence;
|
||||||
|
savePreset("Convergence", g_Config.iStereoConvergence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsHotkey(HK_SWITCH_STEREOSCOPY_PRESET))
|
||||||
|
{
|
||||||
|
g_Config.iStereoActivePreset = !g_Config.iStereoActivePreset;
|
||||||
|
g_Config.iStereoConvergence = g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence;
|
||||||
|
g_Config.iStereoDepth = g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth;
|
||||||
|
}
|
||||||
|
if (IsHotkey(HK_USE_STEREOSCOPY_PRESET_0))
|
||||||
|
{
|
||||||
|
g_Config.iStereoActivePreset = 0;
|
||||||
|
g_Config.iStereoConvergence = g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence;
|
||||||
|
g_Config.iStereoDepth = g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth;
|
||||||
|
}
|
||||||
|
if (IsHotkey(HK_USE_STEREOSCOPY_PRESET_1))
|
||||||
|
{
|
||||||
|
g_Config.iStereoActivePreset = 1;
|
||||||
|
g_Config.iStereoConvergence = g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence;
|
||||||
|
g_Config.iStereoDepth = g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth;
|
||||||
|
}
|
||||||
|
if (IsHotkey(HK_USE_STEREOSCOPY_PRESET_2))
|
||||||
|
{
|
||||||
|
g_Config.iStereoActivePreset = 2;
|
||||||
|
g_Config.iStereoConvergence = g_Config.oStereoPresets[g_Config.iStereoActivePreset].convergence;
|
||||||
|
g_Config.iStereoDepth = g_Config.oStereoPresets[g_Config.iStereoActivePreset].depth;
|
||||||
|
}
|
||||||
static float debugSpeed = 1.0f;
|
static float debugSpeed = 1.0f;
|
||||||
if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true))
|
if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true))
|
||||||
debugSpeed /= 1.1f;
|
debugSpeed /= 1.1f;
|
||||||
|
|
|
@ -17,6 +17,7 @@ class VideoBackend : public VideoBackendHardware
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::string GetDisplayName() const override;
|
std::string GetDisplayName() const override;
|
||||||
|
std::string GetConfigName() const override;
|
||||||
|
|
||||||
void Video_Prepare() override;
|
void Video_Prepare() override;
|
||||||
void Video_Cleanup() override;
|
void Video_Cleanup() override;
|
||||||
|
|
|
@ -64,6 +64,11 @@ std::string VideoBackend::GetDisplayName() const
|
||||||
return "Direct3D";
|
return "Direct3D";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VideoBackend::GetConfigName() const
|
||||||
|
{
|
||||||
|
return "gfx_dx11";
|
||||||
|
}
|
||||||
|
|
||||||
void InitBackendInfo()
|
void InitBackendInfo()
|
||||||
{
|
{
|
||||||
HRESULT hr = DX11::D3D::LoadDXGI();
|
HRESULT hr = DX11::D3D::LoadDXGI();
|
||||||
|
@ -142,7 +147,7 @@ void InitBackendInfo()
|
||||||
void VideoBackend::ShowConfig(void *hParent)
|
void VideoBackend::ShowConfig(void *hParent)
|
||||||
{
|
{
|
||||||
InitBackendInfo();
|
InitBackendInfo();
|
||||||
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx11");
|
Host_ShowVideoConfig(hParent, GetDisplayName(), GetConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoBackend::Initialize(void *window_handle)
|
bool VideoBackend::Initialize(void *window_handle)
|
||||||
|
@ -155,7 +160,7 @@ bool VideoBackend::Initialize(void *window_handle)
|
||||||
|
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
|
|
||||||
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini");
|
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + GetConfigName() + ".ini");
|
||||||
g_Config.GameIniLoad();
|
g_Config.GameIniLoad();
|
||||||
g_Config.UpdateProjectionHack();
|
g_Config.UpdateProjectionHack();
|
||||||
g_Config.VerifyValidity();
|
g_Config.VerifyValidity();
|
||||||
|
|
|
@ -17,6 +17,7 @@ class VideoBackend : public VideoBackendHardware
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::string GetDisplayName() const override;
|
std::string GetDisplayName() const override;
|
||||||
|
std::string GetConfigName() const override;
|
||||||
|
|
||||||
void Video_Prepare() override;
|
void Video_Prepare() override;
|
||||||
void Video_Cleanup() override;
|
void Video_Cleanup() override;
|
||||||
|
|
|
@ -102,6 +102,11 @@ std::string VideoBackend::GetDisplayName() const
|
||||||
return "OpenGL";
|
return "OpenGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VideoBackend::GetConfigName() const
|
||||||
|
{
|
||||||
|
return "gfx_opengl";
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::string> GetShaders(const std::string &sub_dir = "")
|
static std::vector<std::string> GetShaders(const std::string &sub_dir = "")
|
||||||
{
|
{
|
||||||
std::vector<std::string> paths = DoFileSearch({".glsl"}, {
|
std::vector<std::string> paths = DoFileSearch({".glsl"}, {
|
||||||
|
@ -143,7 +148,7 @@ void VideoBackend::ShowConfig(void *_hParent)
|
||||||
{
|
{
|
||||||
if (!s_BackendInitialized)
|
if (!s_BackendInitialized)
|
||||||
InitBackendInfo();
|
InitBackendInfo();
|
||||||
Host_ShowVideoConfig(_hParent, GetDisplayName(), "gfx_opengl");
|
Host_ShowVideoConfig(_hParent, GetDisplayName(), GetConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoBackend::Initialize(void *window_handle)
|
bool VideoBackend::Initialize(void *window_handle)
|
||||||
|
@ -153,7 +158,7 @@ bool VideoBackend::Initialize(void *window_handle)
|
||||||
|
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
|
|
||||||
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini");
|
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + GetConfigName() + ".ini");
|
||||||
g_Config.GameIniLoad();
|
g_Config.GameIniLoad();
|
||||||
g_Config.UpdateProjectionHack();
|
g_Config.UpdateProjectionHack();
|
||||||
g_Config.VerifyValidity();
|
g_Config.VerifyValidity();
|
||||||
|
|
|
@ -67,14 +67,19 @@ std::string VideoSoftware::GetDisplayName() const
|
||||||
return "Software Renderer";
|
return "Software Renderer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string VideoSoftware::GetConfigName() const
|
||||||
|
{
|
||||||
|
return "gfx_software";
|
||||||
|
}
|
||||||
|
|
||||||
void VideoSoftware::ShowConfig(void *hParent)
|
void VideoSoftware::ShowConfig(void *hParent)
|
||||||
{
|
{
|
||||||
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_software");
|
Host_ShowVideoConfig(hParent, GetDisplayName(), GetConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoSoftware::Initialize(void *window_handle)
|
bool VideoSoftware::Initialize(void *window_handle)
|
||||||
{
|
{
|
||||||
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
|
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + GetConfigName() + ".ini").c_str());
|
||||||
|
|
||||||
InitInterface();
|
InitInterface();
|
||||||
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
|
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
|
||||||
|
|
|
@ -19,6 +19,7 @@ class VideoSoftware : public VideoBackend
|
||||||
|
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
std::string GetDisplayName() const override;
|
std::string GetDisplayName() const override;
|
||||||
|
std::string GetConfigName() const override;
|
||||||
|
|
||||||
void EmuStateChange(EMUSTATE_CHANGE newState) override;
|
void EmuStateChange(EMUSTATE_CHANGE newState) override;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
|
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
virtual std::string GetDisplayName() const { return GetName(); }
|
virtual std::string GetDisplayName() const { return GetName(); }
|
||||||
|
virtual std::string GetConfigName() const = 0;
|
||||||
|
|
||||||
virtual void ShowConfig(void*) = 0;
|
virtual void ShowConfig(void*) = 0;
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,16 @@ void VideoConfig::Load(const std::string& ini_file)
|
||||||
enhancements->Get("StereoConvergence", &iStereoConvergence, 20);
|
enhancements->Get("StereoConvergence", &iStereoConvergence, 20);
|
||||||
enhancements->Get("StereoSwapEyes", &bStereoSwapEyes, false);
|
enhancements->Get("StereoSwapEyes", &bStereoSwapEyes, false);
|
||||||
|
|
||||||
|
//currently these settings are not saved in global config, so we could've initialized them directly
|
||||||
|
for (int i = 0; i < oStereoPresets.size(); ++i)
|
||||||
|
{
|
||||||
|
enhancements->Get(StringFromFormat("StereoConvergence_%d", i), &oStereoPresets[i].depth, iStereoConvergence);
|
||||||
|
enhancements->Get(StringFromFormat("StereoDepth_%d", i), &oStereoPresets[i].convergence, iStereoDepth);
|
||||||
|
}
|
||||||
|
enhancements->Get("StereoActivePreset", &iStereoActivePreset, 0);
|
||||||
|
iStereoConvergence = oStereoPresets[iStereoActivePreset].convergence;
|
||||||
|
iStereoDepth = oStereoPresets[iStereoActivePreset].depth;
|
||||||
|
|
||||||
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
|
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
|
||||||
hacks->Get("EFBAccessEnable", &bEFBAccessEnable, true);
|
hacks->Get("EFBAccessEnable", &bEFBAccessEnable, true);
|
||||||
hacks->Get("BBoxEnable", &bBBoxEnable, false);
|
hacks->Get("BBoxEnable", &bBBoxEnable, false);
|
||||||
|
@ -200,6 +210,17 @@ void VideoConfig::GameIniLoad()
|
||||||
CHECK_SETTING("Video_Enhancements", "StereoConvergence", iStereoConvergence);
|
CHECK_SETTING("Video_Enhancements", "StereoConvergence", iStereoConvergence);
|
||||||
CHECK_SETTING("Video_Enhancements", "StereoSwapEyes", bStereoSwapEyes);
|
CHECK_SETTING("Video_Enhancements", "StereoSwapEyes", bStereoSwapEyes);
|
||||||
|
|
||||||
|
//these are not overrides, they are per-game settings, hence no warning
|
||||||
|
IniFile::Section* enhancements = iniFile.GetOrCreateSection("Enhancements");
|
||||||
|
for (int i = 0; i < oStereoPresets.size(); ++i)
|
||||||
|
{
|
||||||
|
enhancements->Get(StringFromFormat("StereoConvergence_%d", i), &oStereoPresets[i].depth, iStereoConvergence);
|
||||||
|
enhancements->Get(StringFromFormat("StereoDepth_%d", i), &oStereoPresets[i].convergence, iStereoDepth);
|
||||||
|
}
|
||||||
|
enhancements->Get("StereoActivePreset", &iStereoActivePreset, 0);
|
||||||
|
iStereoConvergence = oStereoPresets[iStereoActivePreset].convergence;
|
||||||
|
iStereoDepth = oStereoPresets[iStereoActivePreset].depth;
|
||||||
|
|
||||||
CHECK_SETTING("Video_Stereoscopy", "StereoEFBMonoDepth", bStereoEFBMonoDepth);
|
CHECK_SETTING("Video_Stereoscopy", "StereoEFBMonoDepth", bStereoEFBMonoDepth);
|
||||||
CHECK_SETTING("Video_Stereoscopy", "StereoDepthPercentage", iStereoDepthPercentage);
|
CHECK_SETTING("Video_Stereoscopy", "StereoDepthPercentage", iStereoDepthPercentage);
|
||||||
CHECK_SETTING("Video_Stereoscopy", "StereoConvergenceMinimum", iStereoConvergenceMinimum);
|
CHECK_SETTING("Video_Stereoscopy", "StereoConvergenceMinimum", iStereoConvergenceMinimum);
|
||||||
|
|
|
@ -51,6 +51,14 @@ enum StereoMode
|
||||||
STEREO_3DVISION
|
STEREO_3DVISION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr int STEREOSCOPY_PRESETS_NUM = 3;
|
||||||
|
|
||||||
|
struct StereoscopyPreset final
|
||||||
|
{
|
||||||
|
int depth;
|
||||||
|
int convergence;
|
||||||
|
};
|
||||||
|
|
||||||
// NEVER inherit from this class.
|
// NEVER inherit from this class.
|
||||||
struct VideoConfig final
|
struct VideoConfig final
|
||||||
{
|
{
|
||||||
|
@ -84,6 +92,8 @@ struct VideoConfig final
|
||||||
int iStereoDepth;
|
int iStereoDepth;
|
||||||
int iStereoConvergence;
|
int iStereoConvergence;
|
||||||
bool bStereoSwapEyes;
|
bool bStereoSwapEyes;
|
||||||
|
std::array<StereoscopyPreset, STEREOSCOPY_PRESETS_NUM> oStereoPresets;
|
||||||
|
int iStereoActivePreset;
|
||||||
|
|
||||||
// Information
|
// Information
|
||||||
bool bShowFPS;
|
bool bShowFPS;
|
||||||
|
|
Loading…
Reference in New Issue