mirror of https://github.com/PCSX2/pcsx2.git
Added callbacks for OSD Log and Monitor. Added wrappers in PCSX2 main for callbacks. Added some basic info calls (e.g. Saving loading FPS)
This commit is contained in:
parent
44e671bb0a
commit
fce2814735
|
@ -570,6 +570,8 @@ typedef void(CALLBACK *_PS2EsetEmuVersion)(const char *emuId, u32 version); // H
|
|||
// GS
|
||||
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef void(CALLBACK *_GSosdLog)(const char *utf8, u32 color);
|
||||
typedef void(CALLBACK *_GSosdMonitor)(const char *key, const char *value, u32 color);
|
||||
typedef s32(CALLBACK *_GSopen)(void *pDsp, const char *Title, int multithread);
|
||||
typedef s32(CALLBACK *_GSopen2)(void *pDsp, u32 flags);
|
||||
typedef void(CALLBACK *_GSvsync)(int field);
|
||||
|
@ -729,6 +731,8 @@ typedef void(CALLBACK *_FWirqCallback)(void (*callback)());
|
|||
|
||||
// GS
|
||||
#ifndef BUILTIN_GS_PLUGIN
|
||||
extern _GSosdLog GSosdLog;
|
||||
extern _GSosdMonitor GSosdMonitor;
|
||||
extern _GSopen GSopen;
|
||||
extern _GSopen2 GSopen2;
|
||||
extern _GSvsync GSvsync;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Utilities/pxStreams.h"
|
||||
|
||||
#include "svnrev.h"
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
SysPluginBindings SysPlugins;
|
||||
|
||||
|
@ -155,6 +156,8 @@ static s32 CALLBACK fallback_test() { return 0; }
|
|||
|
||||
#ifndef BUILTIN_GS_PLUGIN
|
||||
_GSvsync GSvsync;
|
||||
_GSosdLog GSosdLog;
|
||||
_GSosdMonitor GSosdMonitor;
|
||||
_GSopen GSopen;
|
||||
_GSopen2 GSopen2;
|
||||
_GSgifTransfer GSgifTransfer;
|
||||
|
@ -422,6 +425,8 @@ static const LegacyApi_ReqMethod s_MethMessReq_GS[] =
|
|||
|
||||
static const LegacyApi_OptMethod s_MethMessOpt_GS[] =
|
||||
{
|
||||
{ "GSosdLog", (vMeth**)&GSosdLog },
|
||||
{ "GSosdMonitor", (vMeth**)&GSosdMonitor },
|
||||
{ "GSopen2", (vMeth**)&GSopen2 },
|
||||
{ "GSreset", (vMeth**)&GSreset },
|
||||
{ "GSsetupRecording", (vMeth**)&GSsetupRecording },
|
||||
|
@ -838,7 +843,7 @@ static char* PS2E_CALLBACK pcsx2_GetStringAlloc( const char* name, void* (PS2E_C
|
|||
|
||||
static void PS2E_CALLBACK pcsx2_OSD_WriteLn( int icon, const char* msg )
|
||||
{
|
||||
return; // not implemented...
|
||||
OSDlog( Color_StrongYellow, false, msg );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
|
|
@ -1213,3 +1213,19 @@ void Pcsx2App::DisableWindowLogging() const
|
|||
AffinityAssert_AllowFrom_MainUI();
|
||||
Console_SetActiveHandler( (emuLog!=NULL) ? (IConsoleWriter&)ConsoleWriter_File : (IConsoleWriter&)ConsoleWriter_Stdout );
|
||||
}
|
||||
|
||||
void OSDlog(ConsoleColors color, bool console, const std::string& str)
|
||||
{
|
||||
if (GSosdLog)
|
||||
GSosdLog(str.c_str(), wxGetApp().GetProgramLog()->GetRGBA(color));
|
||||
|
||||
if (console)
|
||||
Console.WriteLn(color, str.c_str());
|
||||
}
|
||||
|
||||
void OSDmonitor(ConsoleColors color, const std::string key, const std::string value) {
|
||||
if(!GSosdMonitor) return;
|
||||
|
||||
GSosdMonitor(wxString(key).utf8_str(), wxString(value).utf8_str(), wxGetApp().GetProgramLog()->GetRGBA(color));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "App.h"
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
static const bool EnableThreadedLoggingTest = false; //true;
|
||||
|
@ -222,3 +223,29 @@ protected:
|
|||
|
||||
void OnLoggingChanged();
|
||||
};
|
||||
|
||||
void OSDlog(ConsoleColors color, bool console, const std::string& str);
|
||||
|
||||
template<typename ... Args>
|
||||
void OSDlog(ConsoleColors color, bool console, const std::string& format, Args ... args) {
|
||||
if (!GSosdLog && !console) return;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
size_t size = _snprintf( nullptr, 0, format.c_str(), args ... ) + 1; // Extra space for '\0'
|
||||
#else
|
||||
size_t size = snprintf( nullptr, 0, format.c_str(), args ... ) + 1; // Extra space for '\0'
|
||||
#endif
|
||||
|
||||
std::vector<char> buf(size);
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
_snprintf( buf.data(), size, format.c_str(), args ... );
|
||||
#else
|
||||
snprintf( buf.data(), size, format.c_str(), args ... );
|
||||
#endif
|
||||
|
||||
OSDlog(color, console, buf.data());
|
||||
}
|
||||
|
||||
void OSDmonitor(ConsoleColors color, const std::string key, const std::string value);
|
||||
|
||||
|
|
|
@ -22,8 +22,12 @@
|
|||
#include "GS.h"
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include <wx/utils.h>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
static const KeyAcceleratorCode FULLSCREEN_TOGGLE_ACCELERATOR_GSPANEL=KeyAcceleratorCode( WXK_RETURN ).Alt();
|
||||
|
||||
|
@ -614,12 +618,15 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
m_CpuUsage.UpdateStats();
|
||||
|
||||
cpuUsage.Write(L"EE: %3d%%", m_CpuUsage.GetEEcorePct());
|
||||
OSDmonitor(Color_StrongRed, "EE", std::to_string(m_CpuUsage.GetEEcorePct()).c_str());
|
||||
cpuUsage.Write(L" | GS: %3d%%", m_CpuUsage.GetGsPct());
|
||||
OSDmonitor(Color_StrongGreen, "GS", std::to_string(m_CpuUsage.GetGsPct()).c_str());
|
||||
|
||||
if (THREAD_VU1)
|
||||
cpuUsage.Write(L" | VU: %3d%%", m_CpuUsage.GetVUPct());
|
||||
|
||||
pxNonReleaseCode(cpuUsage.Write(L" | UI: %3d%%", m_CpuUsage.GetGuiPct()));
|
||||
OSDmonitor(Color_StrongYellow, "UI", std::to_string(m_CpuUsage.GetGuiPct()).c_str());
|
||||
}
|
||||
|
||||
const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2);
|
||||
|
@ -631,6 +638,9 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
title.Replace(L"${limiter}", limiterStr);
|
||||
title.Replace(L"${speed}", pxsFmt(L"%3d%%", lround(percentage)));
|
||||
title.Replace(L"${vfps}", pxsFmt(L"%.02f", fps));
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(2) << fps;
|
||||
OSDmonitor(Color_StrongBlue, "FPS", out.str());
|
||||
title.Replace(L"${cpuusage}", cpuUsage);
|
||||
title.Replace(L"${omodef}", omodef);
|
||||
title.Replace(L"${omodei}", omodei);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "MainFrame.h"
|
||||
#include "GSFrame.h"
|
||||
#include "ApplyState.h"
|
||||
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include "AppAccelerators.h"
|
||||
#include "AppSaveStates.h"
|
||||
|
@ -70,10 +70,12 @@ namespace Implementations
|
|||
g_Conf->EmuOptions.GS.FrameSkipEnable = !g_Conf->EmuOptions.GS.FrameSkipEnable;
|
||||
SetGSConfig().FrameSkipEnable = g_Conf->EmuOptions.GS.FrameSkipEnable;
|
||||
|
||||
if( EmuConfig.GS.FrameSkipEnable )
|
||||
Console.WriteLn( "(FrameSkipping) Enabled : FrameDraws=%d, FrameSkips=%d", g_Conf->EmuOptions.GS.FramesToDraw, g_Conf->EmuOptions.GS.FramesToSkip );
|
||||
else
|
||||
Console.WriteLn( "(FrameSkipping) Disabled." );
|
||||
if( EmuConfig.GS.FrameSkipEnable ) {
|
||||
OSDlog( Color_StrongRed, true, "(FrameSkipping) Enabled." );
|
||||
OSDlog( Color_StrongRed, true, " FrameDraws=%d, FrameSkips=%d", g_Conf->EmuOptions.GS.FramesToDraw, g_Conf->EmuOptions.GS.FramesToSkip );
|
||||
} else {
|
||||
OSDlog( Color_StrongRed, true, "(FrameSkipping) Disabled." );
|
||||
}
|
||||
}
|
||||
|
||||
void Framelimiter_TurboToggle()
|
||||
|
@ -85,7 +87,7 @@ namespace Implementations
|
|||
g_Conf->EmuOptions.GS.FrameLimitEnable = true;
|
||||
g_LimiterMode = Limit_Turbo;
|
||||
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.TurboScalar;
|
||||
Console.WriteLn("(FrameLimiter) Turbo + FrameLimit ENABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) Turbo + FrameLimit ENABLED." );
|
||||
g_Conf->EmuOptions.GS.FrameSkipEnable = !!g_Conf->Framerate.SkipOnTurbo;
|
||||
}
|
||||
else if( g_LimiterMode == Limit_Turbo )
|
||||
|
@ -96,12 +98,12 @@ namespace Implementations
|
|||
|
||||
if ( g_Conf->Framerate.SkipOnLimit)
|
||||
{
|
||||
Console.WriteLn("(FrameLimiter) Turbo DISABLED. Frameskip ENABLED" );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) Turbo DISABLED. Frameskip ENABLED" );
|
||||
g_Conf->EmuOptions.GS.FrameSkipEnable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLn("(FrameLimiter) Turbo DISABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) Turbo DISABLED." );
|
||||
g_Conf->EmuOptions.GS.FrameSkipEnable = false;
|
||||
}
|
||||
}
|
||||
|
@ -113,12 +115,12 @@ namespace Implementations
|
|||
|
||||
if ( g_Conf->Framerate.SkipOnTurbo)
|
||||
{
|
||||
Console.WriteLn("(FrameLimiter) Turbo + Frameskip ENABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) Turbo + Frameskip ENABLED." );
|
||||
g_Conf->EmuOptions.GS.FrameSkipEnable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLn("(FrameLimiter) Turbo ENABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) Turbo ENABLED." );
|
||||
g_Conf->EmuOptions.GS.FrameSkipEnable = false;
|
||||
}
|
||||
}
|
||||
|
@ -139,13 +141,13 @@ namespace Implementations
|
|||
{
|
||||
g_LimiterMode = Limit_Nominal;
|
||||
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.NominalScalar;
|
||||
Console.WriteLn("(FrameLimiter) SlowMotion DISABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) SlowMotion DISABLED." );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_LimiterMode = Limit_Slomo;
|
||||
g_Conf->EmuOptions.GS.LimitScalar = g_Conf->Framerate.SlomoScalar;
|
||||
Console.WriteLn("(FrameLimiter) SlowMotion ENABLED." );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) SlowMotion ENABLED." );
|
||||
g_Conf->EmuOptions.GS.FrameLimitEnable = true;
|
||||
}
|
||||
pauser.AllowResume();
|
||||
|
@ -156,7 +158,7 @@ namespace Implementations
|
|||
ScopedCoreThreadPause pauser;
|
||||
g_Conf->EmuOptions.GS.FrameLimitEnable = !g_Conf->EmuOptions.GS.FrameLimitEnable;
|
||||
GSsetVsync( g_Conf->EmuOptions.GS.FrameLimitEnable && g_Conf->EmuOptions.GS.VsyncEnable );
|
||||
Console.WriteLn("(FrameLimiter) %s.", g_Conf->EmuOptions.GS.FrameLimitEnable ? "ENABLED" : "DISABLED" );
|
||||
OSDlog( Color_StrongRed, true, "(FrameLimiter) %s.", g_Conf->EmuOptions.GS.FrameLimitEnable ? "ENABLED" : "DISABLED" );
|
||||
pauser.AllowResume();
|
||||
}
|
||||
|
||||
|
@ -173,18 +175,18 @@ namespace Implementations
|
|||
void GSwindow_CycleAspectRatio()
|
||||
{
|
||||
AspectRatioType& art = g_Conf->GSWindow.AspectRatio;
|
||||
wxString arts(L"Not modified");
|
||||
const char *arts = "Not modified";
|
||||
if (art == AspectRatio_Stretch && switchAR) //avoids a double 4:3 when coming from FMV aspect ratio switch
|
||||
art = AspectRatio_4_3;
|
||||
switch( art )
|
||||
{
|
||||
case AspectRatio_Stretch: art = AspectRatio_4_3; arts = L"AspectRatio_4_3"; break;
|
||||
case AspectRatio_4_3: art = AspectRatio_16_9; arts = L"AspectRatio_16:9"; break;
|
||||
case AspectRatio_16_9: art = AspectRatio_Stretch; arts = L"AspectRatio_Stretch";break;
|
||||
case AspectRatio_Stretch: art = AspectRatio_4_3; arts = "AspectRatio_4_3"; break;
|
||||
case AspectRatio_4_3: art = AspectRatio_16_9; arts = "AspectRatio_16:9"; break;
|
||||
case AspectRatio_16_9: art = AspectRatio_Stretch; arts = "AspectRatio_Stretch";break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
Console.WriteLn(L"(GSwindow) Aspect ratio: %s.", WX_STR(arts));
|
||||
OSDlog( Color_StrongBlue, true, "(GSwindow) Aspect ratio: %s.", arts );
|
||||
UpdateImagePosition();
|
||||
}
|
||||
|
||||
|
@ -192,7 +194,7 @@ namespace Implementations
|
|||
{
|
||||
g_Conf->GSWindow.OffsetX = x;
|
||||
g_Conf->GSWindow.OffsetY = y;
|
||||
Console.WriteLn(L"(GSwindow) Offset: x=%f, y=%f", x,y);
|
||||
OSDlog( Color_StrongBlue, true, "(GSwindow) Offset: x=%f, y=%f", x,y);
|
||||
|
||||
UpdateImagePosition();
|
||||
|
||||
|
@ -223,7 +225,7 @@ namespace Implementations
|
|||
if( zoom <= 0 )
|
||||
return;
|
||||
g_Conf->GSWindow.StretchY = zoom;
|
||||
Console.WriteLn(L"(GSwindow) Vertical stretch: %f", zoom);
|
||||
OSDlog( Color_StrongBlue, true, "(GSwindow) Vertical stretch: %f", zoom);
|
||||
|
||||
UpdateImagePosition();
|
||||
}
|
||||
|
@ -247,10 +249,10 @@ namespace Implementations
|
|||
return;
|
||||
g_Conf->GSWindow.Zoom = zoom;
|
||||
|
||||
if ( zoom == 0 )
|
||||
Console.WriteLn(L"(GSwindow) Zoom: 0 (auto, no black bars)");
|
||||
else
|
||||
Console.WriteLn(L"(GSwindow) Zoom: %f", zoom);
|
||||
if ( zoom == 0 )
|
||||
OSDlog( Color_StrongBlue, true, "(GSwindow) Zoom: 0 (auto, no black bars)");
|
||||
else
|
||||
OSDlog( Color_StrongBlue, true, "(GSwindow) Zoom: %f", zoom);
|
||||
|
||||
UpdateImagePosition();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <wx/dir.h>
|
||||
#include <wx/stopwatch.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
// IMPORTANT! If this gets a macro redefinition error it means PluginCallbacks.h is included
|
||||
// in a global-scope header, and that's a BAD THING. Include it only into modules that need
|
||||
// it, because some need to be able to alter its behavior using defines. Like this:
|
||||
|
@ -34,6 +36,8 @@ struct Component_FileMcd;
|
|||
|
||||
#include "svnrev.h"
|
||||
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include <wx/ffile.h>
|
||||
#include <map>
|
||||
|
||||
|
@ -359,7 +363,23 @@ s32 FileMemoryCard::Save( uint slot, const u8 *src, u32 adr, int size )
|
|||
}
|
||||
|
||||
if( !Seek(mcfp, adr) ) return 0;
|
||||
return mcfp.Write( m_currentdata.GetPtr(), size ) != 0;
|
||||
|
||||
int status = mcfp.Write( m_currentdata.GetPtr(), size );
|
||||
|
||||
if( status ) {
|
||||
static auto last = std::chrono::time_point<std::chrono::system_clock>();
|
||||
|
||||
std::chrono::duration<float> elapsed = std::chrono::system_clock::now() - last;
|
||||
if(elapsed > std::chrono::seconds(5)) {
|
||||
wxString name, ext;
|
||||
wxFileName::SplitPath(m_file[slot].GetName(), NULL, NULL, &name, &ext);
|
||||
OSDlog( Color_StrongYellow, false, "Memory Card %s written.", (const char *)(name + "." + ext).c_str() );
|
||||
last = std::chrono::system_clock::now();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FileMemoryCard::EraseBlock( uint slot, u32 adr )
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "App.h"
|
||||
#include "AppSaveStates.h"
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
|
@ -126,7 +127,7 @@ void States_registerLoadBackupMenuItem( wxMenuItem* loadBackupMenuItem )
|
|||
|
||||
static void OnSlotChanged()
|
||||
{
|
||||
Console.Warning( " > Selected savestate slot %d", StatesC);
|
||||
OSDlog( Color_StrongGreen, true, " > Selected savestate slot %d", StatesC );
|
||||
|
||||
if( GSchangeSaveState != NULL )
|
||||
GSchangeSaveState(StatesC, SaveStateBase::GetFilename(StatesC).mb_str());
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "ZipTools/ThreadedZipTools.h"
|
||||
#include "Utilities/pxStreams.h"
|
||||
|
||||
#include "ConsoleLogger.h"
|
||||
|
||||
#include <wx/wfstream.h>
|
||||
#include <memory>
|
||||
|
||||
|
@ -672,7 +674,7 @@ void StateCopy_SaveToSlot( uint num )
|
|||
wxRenameFile( file, copy );
|
||||
}
|
||||
|
||||
Console.WriteLn( Color_StrongGreen, "Saving savestate to slot %d...", num );
|
||||
OSDlog( Color_StrongGreen, true, "Saving savestate to slot %d...", num );
|
||||
Console.Indent().WriteLn( Color_StrongGreen, L"filename: %s", WX_STR(file) );
|
||||
|
||||
StateCopy_SaveToFile( file );
|
||||
|
@ -688,7 +690,7 @@ void StateCopy_LoadFromSlot( uint slot, bool isFromBackup )
|
|||
return;
|
||||
}
|
||||
|
||||
Console.WriteLn( Color_StrongGreen, L"Loading savestate from slot %d...%s", slot, WX_STR(wxString( isFromBackup?L" (backup)":L"" )) );
|
||||
OSDlog( Color_StrongGreen, true, "Loading savestate from slot %d...%s", slot, isFromBackup?" (backup)":"" );
|
||||
Console.Indent().WriteLn( Color_StrongGreen, L"filename: %s", WX_STR(file) );
|
||||
|
||||
StateCopy_LoadFromFile( file );
|
||||
|
|
|
@ -501,6 +501,16 @@ static int _GSopen(void** dsp, const char* title, GSRendererType renderer, int t
|
|||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSosdLog(const char *utf8, uint32 color)
|
||||
{
|
||||
if(s_gs && s_gs->m_dev) s_gs->m_dev->m_osd.Log(utf8, color);
|
||||
}
|
||||
|
||||
EXPORT_C_(void) GSosdMonitor(const char *key, const char *value, uint32 color)
|
||||
{
|
||||
if(s_gs && s_gs->m_dev) s_gs->m_dev->m_osd.Monitor(key, value, color);
|
||||
}
|
||||
|
||||
EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
|
||||
{
|
||||
static bool stored_toggle_state = false;
|
||||
|
|
|
@ -9,6 +9,8 @@ EXPORTS
|
|||
GSsetBaseMem
|
||||
GSinit
|
||||
GSshutdown
|
||||
GSosdLog
|
||||
GSosdMonitor
|
||||
GSopen
|
||||
GSopen2
|
||||
GSclose
|
||||
|
|
Loading…
Reference in New Issue