diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 681c8eac4c..37705b1f21 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + @@ -586,14 +606,6 @@ RelativePath=".\Src\CommonTypes.h" > - - - - diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 93c70a1702..8d342e15e7 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -81,6 +81,7 @@ #define DEBUGGER_CONFIG "Debugger.ini" #define LOGGER_CONFIG "Logger.ini" #define TOTALDB "totaldb.dsy" +#define MAIN_LOG "dolphin.log" #define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX #define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX @@ -148,6 +149,8 @@ #define MAINRAM_DUMP_FILE FULL_DUMP_DIR MEMORY_DUMP_FILE #define GC_SRAM_FILE FULL_USERDATA_DIR GC_USER_DIR DIR_SEP GC_SRAM +#define MAIN_LOG_FILE FULL_LOGS_DIR MAIN_LOG + // Sys files #define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI #define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS diff --git a/Source/Core/Common/Src/ConsoleListener.cpp b/Source/Core/Common/Src/ConsoleListener.cpp new file mode 100644 index 0000000000..e84fc9d079 --- /dev/null +++ b/Source/Core/Common/Src/ConsoleListener.cpp @@ -0,0 +1,137 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + + +#include // System: To be able to add strings with "+" +#include +#ifdef _WIN32 +#include +#else +#include +#endif + +#include "Common.h" +#include "LogManager.h" // Common + + +/* Start console window - width and height is the size of console window */ +ConsoleListener::ConsoleListener(int Width, int Height, char * Name) : + Listener("console") +{ +#ifdef _WIN32 + // Open the console window and create the window handle for GetStdHandle() + AllocConsole(); + + // Save the window handle that AllocConsole() created + m_hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + + // Set the console window title + SetConsoleTitle(Name); + + // Set the total letter space + COORD co = {Width, Height}; + SetConsoleScreenBufferSize(m_hStdOut, co); + + /* Set the window size in number of letters. The height is hardcoded here + because it can be changed with MoveWindow() later */ + SMALL_RECT coo = {0,0, (Width - 1),50}; // Top, left, right, bottom + SetConsoleWindowInfo(m_hStdOut, TRUE, &coo); +#endif + +} + + +/* Close the console window and close the eventual file handle */ +ConsoleListener::~ConsoleListener() +{ +#ifdef _WIN32 + FreeConsole(); // Close the console window +#else + fflush(NULL); +#endif +} + +// Logs the message to screen +void ConsoleListener::Log(LogTypes::LOG_LEVELS, const char *text) +{ + +#if defined(_WIN32) + DWORD cCharsWritten; // We will get a value back here + + WriteConsole(m_hStdOut, text, (DWORD)strlen(text), + &cCharsWritten, NULL); +#else + fprintf(stderr, "%s", text); +#endif +} + + +// Clear console screen +void ConsoleListener::ClearScreen() +{ +#if defined(_WIN32) + COORD coordScreen = { 0, 0 }; + DWORD cCharsWritten; + CONSOLE_SCREEN_BUFFER_INFO csbi; + DWORD dwConSize; + + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + + GetConsoleScreenBufferInfo(hConsole, &csbi); + dwConSize = csbi.dwSize.X * csbi.dwSize.Y; + FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, + coordScreen, &cCharsWritten); + GetConsoleScreenBufferInfo(hConsole, &csbi); + FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, + coordScreen, &cCharsWritten); + SetConsoleCursorPosition(hConsole, coordScreen); +#endif +} + + +/* Get window handle of console window to be able to resize it. We use + GetConsoleTitle() and FindWindow() to locate the console window handle. */ +#if defined(_WIN32) +HWND GetHwnd(void) +{ +#define MY_BUFSIZE 1024 // Buffer size for console window titles + HWND hwndFound; // This is what is returned to the caller + char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle + char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle + + // Fetch current window title. + GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); + + // Format a "unique" NewWindowTitle + wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId()); + + // Change current window title + SetConsoleTitle(pszNewWindowTitle); + + // Ensure window title has been updated + Sleep(40); + + // Look for NewWindowTitle + hwndFound = FindWindow(NULL, pszNewWindowTitle); + + // Restore original window title + SetConsoleTitle(pszOldWindowTitle); + + return(hwndFound); +} +#endif // _WIN32 + diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index bda0891303..ae0cf9b958 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -32,8 +32,6 @@ #include "FileUtil.h" #include "StringUtil.h" #include "DynamicLibrary.h" -#include "ConsoleWindow.h" - DynamicLibrary::DynamicLibrary() { @@ -61,7 +59,6 @@ const char *DllGetLastError() */ int DynamicLibrary::Load(const char* filename) { - INFO_LOG(COMMON, "DL: Loading dynamic library %s", filename); if (!filename || strlen(filename) == 0) { @@ -85,6 +82,8 @@ int DynamicLibrary::Load(const char* filename) DEBUG_LOG(COMMON, "DL: LoadLibrary: %s(%p)", filename, library); if (!library) { + fprintf(stderr, "DL: Error loading DLL %s: %s", filename, + DllGetLastError()); ERROR_LOG(COMMON, "DL: Error loading DLL %s: %s", filename, DllGetLastError()); return 0; diff --git a/Source/Core/Common/Src/Log.h b/Source/Core/Common/Src/Log.h index 5de365a133..ed7fa540df 100644 --- a/Source/Core/Common/Src/Log.h +++ b/Source/Core/Common/Src/Log.h @@ -18,6 +18,12 @@ #ifndef _LOG_H #define _LOG_H +#define ERROR_LEVEL 1 // Critical errors +#define WARNING_LEVEL 2 // Something is suspicious. +#define NOTICE_LEVEL 3 // Important information +#define INFO_LEVEL 4 // General information. +#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. + namespace LogTypes { @@ -41,6 +47,7 @@ enum LOG_TYPE { MASTER_LOG, MEMMAP, OSREPORT, + PAD, PERIPHERALINTERFACE, PIXELENGINE, SERIALINTERFACE, @@ -56,15 +63,18 @@ enum LOG_TYPE { WII_IPC_NET, WII_IPC_SD, WII_IPC_WIIMOTE, - + WIIMOTE, + NUMBER_OF_LOGS // Must be last }; +// FIXME: should this be removed? enum LOG_LEVELS { - LERROR = 1, // Bad errors - that still don't deserve a PanicAlert. - LWARNING, // Something is suspicious. - LINFO, // General information. - LDEBUG, // Strictly for detailed debugging - might make things slow. + LERROR = ERROR_LEVEL, + LWARNING = WARNING_LEVEL, + LNOTICE = NOTICE_LEVEL, + LINFO = INFO_LEVEL, + LDEBUG = DEBUG_LEVEL, }; } // namespace @@ -73,47 +83,52 @@ enum LOG_LEVELS { /* FIXME: - Debug_run() - run only in debug time - - Compile the log functions according to LOGLEVEL */ -#ifdef LOGGING -#define LOGLEVEL 4 //LogTypes::LDEBUG +#if defined LOGGING || defined _DEBUG || defined DEBUGFAST +#define LOGLEVEL DEBUG_LEVEL #else #ifndef LOGLEVEL -#define LOGLEVEL 2 //LogTypes::LWARNING +#define LOGLEVEL NOTICE_LEVEL #endif // loglevel #endif // logging #define ERROR_LOG(...) {} #define WARN_LOG(...) {} +#define NOTICE_LOG(...) {} #define INFO_LOG(...) {} #define DEBUG_LOG(...) {} -extern void __Log(int logNumber, const char* text, ...); +// FIXME can we get rid of this? +#include "LogManager.h" // Let the compiler optimize this out -#define GENERIC_LOG(t,v, ...) {if (v <= LOGLEVEL) __Log(t + (v)*100, __VA_ARGS__);} +#define GENERIC_LOG(t, v, ...) {if (v <= LOGLEVEL) LogManager::GetInstance()->Log(v, t, __VA_ARGS__);} -#if LOGLEVEL >= 1 //LogTypes::LERROR +#if LOGLEVEL >= ERROR_LEVEL #undef ERROR_LOG #define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__)} -#endif // loglevel LERROR+ +#endif // loglevel ERROR+ -#if LOGLEVEL >= 2 //LogTypes::LWARNING +#if LOGLEVEL >= WARNING_LEVEL #undef WARN_LOG #define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)} -#endif // loglevel LWARNING+ +#endif // loglevel WARNING+ -#if LOGLEVEL >= 3 //LogTypes::LINFO +#if LOGLEVEL >= NOTICE_LEVEL +#undef NOTICE_LOG +#define NOTICE_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__)} +#endif // loglevel NOTICE+ +#if LOGLEVEL >= INFO_LEVEL #undef INFO_LOG #define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)} -#endif // loglevel LINFO+ +#endif // loglevel INFO+ -#if LOGLEVEL >= 4 //LogTypes::LDEBUG +#if LOGLEVEL >= DEBUG_LEVEL #undef DEBUG_LOG #define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__)} -#endif // loglevel LDEBUG+ +#endif // loglevel DEBUG+ -#if LOGLEVEL >= 4 //LogTypes::LDEBUG +#if LOGLEVEL >= DEBUG_LEVEL #define _dbg_assert_(_t_, _a_) \ if (!(_a_)) {\ ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ @@ -135,7 +150,7 @@ extern void __Log(int logNumber, const char* text, ...); #define _dbg_assert_(_t_, _a_) ; #define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ; #endif // dbg_assert -#endif // LOGLEVEL LDEBUG +#endif // LOGLEVEL DEBUG #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) #ifdef _WIN32 diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp new file mode 100644 index 0000000000..bc3e327b94 --- /dev/null +++ b/Source/Core/Common/Src/LogManager.cpp @@ -0,0 +1,161 @@ +#include "LogManager.h" +#include "Timer.h" +#include "../../Core/Src/PowerPC/PowerPC.h" // Core + +LogManager *LogManager::m_logManager = NULL; + +LogManager::LogManager() { + // create log files + m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); + m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot"); + m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common"); + m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO"); + m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad"); + m_Log[LogTypes::PIXELENGINE] = new LogContainer("PE", "PixelEngine"); + m_Log[LogTypes::COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc"); + m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "VideoInt"); + m_Log[LogTypes::SERIALINTERFACE] = new LogContainer("SI", "SerialInt"); + m_Log[LogTypes::PERIPHERALINTERFACE]= new LogContainer("PI", "PeripheralInt"); + m_Log[LogTypes::MEMMAP] = new LogContainer("MI", "MI & memmap"); + m_Log[LogTypes::STREAMINGINTERFACE] = new LogContainer("Stream", "StreamingInt"); + m_Log[LogTypes::DSPINTERFACE] = new LogContainer("DSP", "DSPInterface"); + m_Log[LogTypes::DVDINTERFACE] = new LogContainer("DVD", "DVDInterface"); + m_Log[LogTypes::GPFIFO] = new LogContainer("GP", "GPFifo"); + m_Log[LogTypes::EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt"); + m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt"); + m_Log[LogTypes::GEKKO] = new LogContainer("GEKKO", "IBM CPU"); + m_Log[LogTypes::HLE] = new LogContainer("HLE", "HLE"); + m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE"); + m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Plugin"); + m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Plugin"); + m_Log[LogTypes::DYNA_REC] = new LogContainer("JIT", "Dynamic Recompiler"); + m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console"); + m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport"); + m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote"); + m_Log[LogTypes::WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge"); + m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC"); + m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE"); + m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); + m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES"); + m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO","WII IPC FILEIO"); + m_Log[LogTypes::WII_IPC_SD] = new LogContainer("WII_IPC_SD", "WII IPC SD"); + m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); + m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE"); + m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); + + logMutex = new Common::CriticalSection(1); + m_fileLog = new FileLogListener(MAIN_LOG_FILE); + m_consoleLog = new ConsoleListener(); + + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + m_Log[i]->setEnable(true); + m_Log[i]->addListener(m_fileLog); + m_Log[i]->addListener(m_consoleLog); + } +} + +LogManager::~LogManager() { + delete [] &m_Log; + delete logMutex; + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog); + } + delete m_fileLog; + delete m_consoleLog; +} + +void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, + const char *format, ...) { + va_list args; + + char temp[MAX_MSGLEN]; + char msg[MAX_MSGLEN + 512]; + LogContainer *log = m_Log[type]; + + if (! log->isEnable() || level > log->getLevel()) + return; + + va_start(args, format); + CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); + va_end(args); + sprintf(msg, "%s: %i %s %s\n", + Common::Timer::GetTimeFormatted().c_str(), + // PowerPC::ppcState.DebugCount, + (int)level, + log->getShortName(), + temp); + + logMutex->Enter(); + log->trigger(level, msg); + logMutex->Leave(); + +} + +void LogManager::removeListener(LogTypes::LOG_TYPE type, Listener *listener) { + logMutex->Enter(); + m_Log[type]->removeListener(listener); + logMutex->Leave(); +} + +// LogContainer +void LogContainer::addListener(Listener *listener) { + std::vector::iterator i; + bool exists = false; + + for(i=listeners.begin();i!=listeners.end();i++) { + if ((*i) == listener) { + exists = true; + break; + } + } + + if (! exists) + listeners.push_back(listener); +} + +void LogContainer::removeListener(Listener *listener) { + std::vector::iterator i; + for(i=listeners.begin();i!=listeners.end();i++) { + if ((*i) == listener) { + listeners.erase(i); + break; + } + } +} + +bool LogContainer::isListener(Listener *listener) { + std::vector::iterator i; + for(i=listeners.begin();i!=listeners.end();i++) { + if ((*i) == listener) { + return true; + } + } + return false; +} + +void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) { + std::vector::const_iterator i; + for(i=listeners.begin();i!=listeners.end();i++) { + (*i)->Log(level, msg); + } +} + +FileLogListener::FileLogListener(const char *filename) : Listener("File") { + m_filename = strndup(filename, 255); + m_logfile = fopen(filename, "a+"); + setEnable(true); +} + +FileLogListener::~FileLogListener() { + free(m_filename); + fclose(m_logfile); +} + +void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) { + if (!m_enable || !isValid()) + return; + + fwrite(msg, (strlen(msg) + 1) * sizeof(char), 1, m_logfile); + fflush(m_logfile); +} diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h new file mode 100644 index 0000000000..b911037101 --- /dev/null +++ b/Source/Core/Common/Src/LogManager.h @@ -0,0 +1,206 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _LOGMANAGER_H +#define _LOGMANAGER_H + +#include "Log.h" +#include "Thread.h" +#include "StringUtil.h" +#ifdef _WIN32 +#include +#endif +#include +#include +#include + +#define MAX_MESSAGES 8000 +#define MAX_MSGLEN 512 + + +class Listener { +public: + Listener(const char *name) : m_name(name) {} + virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0; + virtual const char *getName() { return m_name; } + +private: + const char *m_name; +}; + +class FileLogListener : public Listener { +public: + FileLogListener(const char *filename); + ~FileLogListener(); + + void Log(LogTypes::LOG_LEVELS, const char *msg); + + bool isValid() { + return (m_logfile != NULL); + } + + bool isEnable() { + return m_enable; + } + + void setEnable(bool enable) { + m_enable = enable; + } +private: + char *m_filename; + FILE *m_logfile; + bool m_enable; + +}; + +class ConsoleListener : public Listener +{ +public: + ConsoleListener(int Width = 150, int Height = 100, + char * Name = "Console"); + ~ConsoleListener(); + + void Log(LogTypes::LOG_LEVELS, const char *text); + void ClearScreen(); + +private: +#ifdef _WIN32 + HWND GetHwnd(void); + HANDLE m_hStdOut; +#endif +}; + +class LogContainer { +public: + + LogContainer(const char* shortName, const char* fullName, + bool enable = false) : m_enable(enable) { + strncpy(m_fullName, fullName, 128); + strncpy(m_shortName, shortName, 32); + m_level = LogTypes::LWARNING; + } + + const char *getShortName() { + return m_shortName; + } + + const char *getFullName() { + return m_fullName; + } + + bool isListener(Listener *listener); + + void addListener(Listener *listener); + + void removeListener(Listener *listener); + + void trigger(LogTypes::LOG_LEVELS, const char *msg); + + bool isEnable() { + return m_enable; + } + + void setEnable(bool enable) { + m_enable = enable; + } + + LogTypes::LOG_LEVELS getLevel() { + return m_level; + } + + void setLevel(LogTypes::LOG_LEVELS level) { + m_level = level; + } + +private: + char m_fullName[128]; + char m_shortName[32]; + bool m_enable; + LogTypes::LOG_LEVELS m_level; + + std::vector listeners; +}; + +class LogManager +{ +private: + + LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; + Common::CriticalSection* logMutex; + FileLogListener *m_fileLog; + ConsoleListener *m_consoleLog; + static LogManager *m_logManager; // FIXME: find a way without singletone + + +public: + static u32 GetMaxLevel() { + return LOGLEVEL; + } + + void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, + const char *fmt, ...); + + void setLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level){ + m_Log[type]->setLevel(level); + } + + void setEnable(LogTypes::LOG_TYPE type, bool enable) { + m_Log[type]->setEnable(enable); + } + + const char *getShortName(LogTypes::LOG_TYPE type) { + return m_Log[type]->getShortName(); + } + + const char *getFullName(LogTypes::LOG_TYPE type) { + return m_Log[type]->getFullName(); + } + + bool isListener(LogTypes::LOG_TYPE type, Listener *listener) { + return m_Log[type]->isListener(listener); + } + + void addListener(LogTypes::LOG_TYPE type, Listener *listener) { + m_Log[type]->addListener(listener); + } + + void removeListener(LogTypes::LOG_TYPE type, Listener *listener); + + FileLogListener *getFileListener() { + return m_fileLog; + } + + ConsoleListener *getConsoleListener() { + return m_consoleLog; + } + + static LogManager* GetInstance() { + if (! m_logManager) + m_logManager = new LogManager(); + + return m_logManager; + } + + static void SetInstance(LogManager *logManager) { + m_logManager = logManager; + } + + LogManager(); + ~LogManager(); +}; + +#endif // LOGMANAGER_H diff --git a/Source/Core/Common/Src/Plugin.cpp b/Source/Core/Common/Src/Plugin.cpp index d39d1683d3..4ad3958ba8 100644 --- a/Source/Core/Common/Src/Plugin.cpp +++ b/Source/Core/Common/Src/Plugin.cpp @@ -57,17 +57,17 @@ CPlugin::CPlugin(const char* _szName) : valid(false) (m_hInstLib.Get("Shutdown")); m_DoState = reinterpret_cast (m_hInstLib.Get("DoState")); - } - - // Check if the plugin has all the functions it shold have - if (m_GetDllInfo != 0 && - m_DllConfig != 0 && - m_DllDebugger != 0 && - m_SetDllGlobals != 0 && - m_Initialize != 0 && - m_Shutdown != 0 && - m_DoState != 0) - valid = true; + + // Check if the plugin has all the functions it shold have + if (m_GetDllInfo != 0 && + m_DllConfig != 0 && + m_DllDebugger != 0 && + m_SetDllGlobals != 0 && + m_Initialize != 0 && + m_Shutdown != 0 && + m_DoState != 0) + valid = true; + } // Save the filename for this plugin Filename = _szName; diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 76b8f4423d..097763d39f 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -8,7 +8,7 @@ files = [ "CDUtils.cpp", "ChunkFile.cpp", "ColorUtil.cpp", - "ConsoleWindow.cpp", + "ConsoleListener.cpp", "CPUDetect.cpp", "DynamicLibrary.cpp", "ExtendedTrace.cpp", @@ -16,6 +16,7 @@ files = [ "FileUtil.cpp", "Hash.cpp", "IniFile.cpp", + "LogManager.cpp", "MappedFile.cpp", "MathUtil.cpp", "MemArena.cpp", diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp index 72d56b17e1..b4ddb1b5be 100644 --- a/Source/Core/Common/Src/Thread.cpp +++ b/Source/Core/Common/Src/Thread.cpp @@ -202,13 +202,13 @@ VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) { if (lpParam == NULL) { - Console::Print("TimerRoutine lpParam is NULL\n"); + DEBUG_LOG(CONSOLE, "TimerRoutine lpParam is NULL\n"); } else { // lpParam points to the argument; in this case it is an int - //Console::Print("Timer[%i] will call back\n", *(int*)lpParam); + //DEBUG_LOG(CONSOLE, "Timer[%i] will call back\n", *(int*)lpParam); } // Call back @@ -221,7 +221,7 @@ bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition) { Id = _Id; - //Console::Print("TimerWait[%i]: %i %i %i\n", Id, StartWait, DoneWaiting, OptCondition); + //DEBUG_LOG(CONSOLE, "TimerWait[%i]: %i %i %i\n", Id, StartWait, DoneWaiting, OptCondition); FunctionPointer[Id] = WaitCB; @@ -234,7 +234,7 @@ bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition) // Delete all timers in the timer queue. if (!DeleteTimerQueue(hTimerQueue)) - Console::Print("DeleteTimerQueue failed (%d)\n", GetLastError()); + DEBUG_LOG(CONSOLE, "DeleteTimerQueue failed (%d)\n", GetLastError()); hTimer = NULL; hTimerQueue = NULL; @@ -251,7 +251,7 @@ bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition) hTimerQueue = CreateTimerQueue(); if (NULL == hTimerQueue) { - Console::Print("CreateTimerQueue failed (%d)\n", GetLastError()); + DEBUG_LOG(CONSOLE, "CreateTimerQueue failed (%d)\n", GetLastError()); return false; } } @@ -260,7 +260,7 @@ bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition) if (!CreateTimerQueueTimer( &hTimer, hTimerQueue, (WAITORTIMERCALLBACK)TimerRoutine, &Id , 10, 0, 0)) { - Console::Print("CreateTimerQueueTimer failed (%d)\n", GetLastError()); + DEBUG_LOG(CONSOLE, "CreateTimerQueueTimer failed (%d)\n", GetLastError()); return false; } diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h index 903ee878b0..83e5ec2d11 100644 --- a/Source/Core/Common/Src/Thread.h +++ b/Source/Core/Common/Src/Thread.h @@ -34,10 +34,12 @@ #endif #endif -#include "Common.h" -/////////////////////////////////// +// Don't include common.h here as it will break LogManager +#include "CommonTypes.h" +#include +#include -////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// // Definitions // ------------ // This may not be defined outside _WIN32 diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 1ccefc0c89..9b14b65e42 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -2264,14 +2264,6 @@ RelativePath=".\Src\Host.h" > - - - - diff --git a/Source/Core/Core/Src/ActionReplay.cpp b/Source/Core/Core/Src/ActionReplay.cpp index 1a00cd21be..a1944f226f 100644 --- a/Source/Core/Core/Src/ActionReplay.cpp +++ b/Source/Core/Core/Src/ActionReplay.cpp @@ -178,7 +178,7 @@ void LogInfo(const char *format, ...) { if (!b_RanOnce) { - if (LogManager::GetLevel() >= LogTypes::LINFO || logSelf) + if (LogManager::GetMaxLevel() >= LogTypes::LINFO || logSelf) { char* temp = (char*)alloca(strlen(format)+512); va_list args; diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 958abf6696..5181352aa9 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -20,6 +20,7 @@ #include "Common.h" #include "IniFile.h" #include "ConfigManager.h" +#include "PluginManager.h" #include "FileUtil.h" SConfig SConfig::m_Instance; @@ -27,6 +28,7 @@ SConfig SConfig::m_Instance; SConfig::SConfig() { + // Make sure we have log manager LoadSettings(); } @@ -39,6 +41,7 @@ SConfig::~SConfig() void SConfig::SaveSettings() { + NOTICE_LOG(BOOT, "Saving Settings to %s", CONFIG_FILE); IniFile ini; #if defined(__APPLE__) ini.Load(File::GetConfigDirectory()); // yes we must load first to not kill unknown stuff @@ -71,7 +74,10 @@ void SConfig::SaveSettings() ini.Set("Interface", "ShowWiimoteLeds", m_LocalCoreStartupParameter.bWiiLeds); ini.Set("Interface", "ShowWiimoteSpeakers", m_LocalCoreStartupParameter.bWiiSpeakers); // interface(UI) language - ini.Set("Interface", "Language", m_InterfaceLanguage); + ini.Set("Interface", "Language", m_InterfaceLanguage); + ini.Set("Interface", "ShowToolbar", m_InterfaceToolbar); + ini.Set("Interface", "ShowStatusbar", m_InterfaceStatusbar); + ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow); // Core ini.Set("Core", "HLEBios", m_LocalCoreStartupParameter.bHLEBios); @@ -122,7 +128,9 @@ void SConfig::SaveSettings() void SConfig::LoadSettings() -{ +{ + + NOTICE_LOG(BOOT, "Loading Settings from %s", CONFIG_FILE); IniFile ini; #if defined(__APPLE__) ini.Load(File::GetConfigDirectory()); @@ -166,7 +174,10 @@ void SConfig::LoadSettings() ini.Get("Interface", "ShowWiimoteLeds", &m_LocalCoreStartupParameter.bWiiLeds, false); ini.Get("Interface", "ShowWiimoteSpeakers", &m_LocalCoreStartupParameter.bWiiSpeakers, false); // interface(UI) language - ini.Get("Interface", "Language", (int*)&m_InterfaceLanguage, 0); + ini.Get("Interface", "Language", (int*)&m_InterfaceLanguage, 0); + ini.Get("Interface", "ShowToolbar", &m_InterfaceToolbar, true); + ini.Get("Interface", "ShowStatusbar", &m_InterfaceStatusbar, true); + ini.Get("Interface", "ShowLogWindow", &m_InterfaceLogWindow, true); // Core ini.Get("Core", "HLEBios", &m_LocalCoreStartupParameter.bHLEBios, true); diff --git a/Source/Core/Core/Src/ConfigManager.h b/Source/Core/Core/Src/ConfigManager.h index 3372c1623e..ba5c66fcf4 100644 --- a/Source/Core/Core/Src/ConfigManager.h +++ b/Source/Core/Core/Src/ConfigManager.h @@ -61,6 +61,11 @@ struct SConfig // interface language INTERFACE_LANGUAGE m_InterfaceLanguage; + // other interface settings + bool m_InterfaceToolbar; + bool m_InterfaceStatusbar; + bool m_InterfaceLogWindow; + // save settings void SaveSettings(); diff --git a/Source/Core/Core/Src/Console.cpp b/Source/Core/Core/Src/Console.cpp index 4fabfa9a0c..14d6a1ad3b 100644 --- a/Source/Core/Core/Src/Console.cpp +++ b/Source/Core/Core/Src/Console.cpp @@ -30,8 +30,8 @@ #include "PowerPCDisasm.h" #include "Console.h" -#define CASE(x) else if (memcmp(cmd, x, 4*sizeof(TCHAR))==0) #define CASE1(x) if (memcmp(cmd, x, 2*sizeof(TCHAR))==0) +#define CASE(x) else if (memcmp(cmd, x, 4*sizeof(TCHAR))==0) void Console_Submit(const char *cmd) { @@ -53,7 +53,7 @@ void Console_Submit(const char *cmd) if (addr) { -#if LOGLEVEL >= 3 +#if LOGLEVEL >= INFO_LEVEL u32 EA = #endif Memory::CheckDTLB(addr, Memory::FLAG_NO_EXCEPTION); @@ -120,7 +120,8 @@ void Console_Submit(const char *cmd) TCHAR temp[256]; sscanf(cmd, "%s %08x %08x", temp, &start, &end); char disasm[256]; - for (u32 addr = start; addr <= end; addr += 4) { + for (u32 addr = start; addr <= end; addr += 4) + { u32 data = Memory::ReadUnchecked_U32(addr); DisassembleGekko(data, addr, disasm, 256); printf("%08x: %08x: %s\n", addr, data, disasm); @@ -149,7 +150,8 @@ void Console_Submit(const char *cmd) { g_symbolDB.List(); } - else { + else + { printf("blach\n"); ERROR_LOG(CONSOLE, "Invalid command"); } diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 1b6c5bc153..fe169e7d8e 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -28,7 +28,6 @@ #include "Thread.h" #include "Timer.h" #include "Common.h" -#include "ConsoleWindow.h" #include "StringUtil.h" #include "Console.h" @@ -161,7 +160,7 @@ void ReconnectPad() CPluginManager &Plugins = CPluginManager::GetInstance(); Plugins.FreePad(0); Plugins.GetPad(0)->Config(g_pWindowHandle); - Console::Print("ReconnectPad()\n"); + INFO_LOG(CONSOLE, "ReconnectPad()\n"); } // This doesn't work yet, I don't understand how the connection work yet @@ -171,7 +170,7 @@ void ReconnectWiimote() /* JP: Yes, it's basically nothing right now, I could not figure out how to reset the Wiimote for reconnection */ HW::InitWiimote(); - Console::Print("ReconnectWiimote()\n"); + INFO_LOG(CONSOLE, "ReconnectWiimote()\n"); } // ----------------------------------------- @@ -182,7 +181,7 @@ void ReconnectWiimote() VideoThreadRunning = false; VideoThreadEvent.SetTimer(); VideoThreadEvent2.SetTimer(); - //Console::Print("VideoThreadEnd\n"); + //INFO_LOG(CONSOLE, "VideoThreadEnd\n"); } #endif // --------------------------- @@ -207,7 +206,8 @@ bool Init() SCoreStartupParameter &_CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; g_CoreStartupParameter = _CoreParameter; - LogManager::Init(); + NOTICE_LOG(BOOT, "Starting core"); + // FIXME DEBUG_LOG(BOOT, dump_params()); Host_SetWaitCursor(true); // Start the thread again @@ -241,8 +241,8 @@ void Stop() #ifdef SETUP_TIMER_WAITING if (!StopUpToVideoDone) { - Console::Print("--------------------------------------------------------------\n"); - Console::Print("Stop [Main Thread]: Shutting down...\n"); + INFO_LOG(CONSOLE, "--------------------------------------------------------------\n"); + INFO_LOG(CONSOLE, "Stop [Main Thread]: Shutting down...\n"); // Reset variables StopReachedEnd = false; EmuThreadReachedEnd = false; @@ -265,7 +265,7 @@ void Stop() // If dual core mode, the CPU thread should immediately exit here. if (_CoreParameter.bUseDualCore) { - Console::Print("Stop [Main Thread]: Wait for Video Loop to exit...\n"); + INFO_LOG(CONSOLE, "Stop [Main Thread]: Wait for Video Loop to exit...\n"); CPluginManager::GetInstance().GetVideo()->Video_ExitLoop(); } @@ -276,7 +276,7 @@ void Stop() //if (!VideoThreadEvent.TimerWait(Stop, 1, EmuThreadReachedEnd) || !EmuThreadReachedEnd) return; if (!VideoThreadEvent.TimerWait(Stop, 1)) return; - //Console::Print("Stop() will continue\n"); + //INFO_LOG(CONSOLE, "Stop() will continue\n"); #endif // Video_EnterLoop() should now exit so that EmuThread() will continue concurrently with the rest @@ -284,9 +284,8 @@ void Stop() // Close the trace file Core::StopTrace(); -#ifndef SETUP_TIMER_WAITING // This hangs - LogManager::Shutdown(); -#endif + NOTICE_LOG(BOOT, "Shutting core"); + // Update mouse pointer Host_SetWaitCursor(false); #ifdef SETUP_AVOID_CHILD_WINDOW_RENDERING_HANG @@ -307,8 +306,8 @@ void Stop() Host_UpdateGUI(); StopUpToVideoDone = false; StopReachedEnd = true; - //Console::Print("Stop() reached the end\n"); - if (EmuThreadReachedEnd) Console::Print("--------------------------------------------------------------\n"); + //INFO_LOG(CONSOLE, "Stop() reached the end\n"); + if (EmuThreadReachedEnd) INFO_LOG(CONSOLE, "--------------------------------------------------------------\n"); #endif } @@ -521,7 +520,7 @@ THREAD_RETURN EmuThread(void *pArg) #ifdef SETUP_TIMER_WAITING VideoThreadEvent2.TimerWait(EmuThreadEnd, 2); - //Console::Print("Video loop [Video Thread]: Stopped\n"); + //INFO_LOG(CONSOLE, "Video loop [Video Thread]: Stopped\n"); return 0; } @@ -530,23 +529,23 @@ void EmuThreadEnd() CPluginManager &Plugins = CPluginManager::GetInstance(); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; - //Console::Print("Video loop [Video Thread]: EmuThreadEnd [StopEnd:%i]\n", StopReachedEnd); + //INFO_LOG(CONSOLE, "Video loop [Video Thread]: EmuThreadEnd [StopEnd:%i]\n", StopReachedEnd); //if (!VideoThreadEvent2.TimerWait(EmuThreadEnd, 2)) return; if (!VideoThreadEvent2.TimerWait(EmuThreadEnd, 2, StopReachedEnd) || !StopReachedEnd) { - Console::Print("Stop [Video Thread]: Waiting for Stop() and Video Loop to end...\n"); + INFO_LOG(CONSOLE, "Stop [Video Thread]: Waiting for Stop() and Video Loop to end...\n"); return; } - //Console::Print("EmuThreadEnd() will continue\n"); + //INFO_LOG(CONSOLE, "EmuThreadEnd() will continue\n"); /* There will be a few problems with the OpenGL ShutDown() after this, for example the "Release Device Context Failed" error message */ #endif - Console::Print("Stop [Video Thread]: Stop() and Video Loop Ended\n"); - Console::Print("Stop [Video Thread]: Shutting down HW and Plugins\n"); + INFO_LOG(CONSOLE, "Stop [Video Thread]: Stop() and Video Loop Ended\n"); + INFO_LOG(CONSOLE, "Stop [Video Thread]: Shutting down HW and Plugins\n"); // We have now exited the Video Loop and will shut down @@ -582,10 +581,10 @@ void EmuThreadEnd() Host_UpdateMainFrame(); #ifdef SETUP_TIMER_WAITING EmuThreadReachedEnd = true; - //Console::Print("EmuThread() reached the end\n"); + //INFO_LOG(CONSOLE, "EmuThread() reached the end\n"); Host_UpdateGUI(); - Console::Print("Stop [Video Thread]: Done\n"); - if (StopReachedEnd) Console::Print("--------------------------------------------------------------\n"); + INFO_LOG(CONSOLE, "Stop [Video Thread]: Done\n"); + if (StopReachedEnd) INFO_LOG(CONSOLE, "--------------------------------------------------------------\n"); delete g_EmuThread; // Wait for emuthread to close. g_EmuThread = 0; #endif @@ -715,9 +714,9 @@ void Callback_VideoCopiedToXFB() // __________________________________________________________________________________________________ // Callback_DSPLog // WARNING - THIS MAY EXECUTED FROM DSP THREAD -void Callback_DSPLog(const TCHAR* _szMessage, int _v) + void Callback_DSPLog(const TCHAR* _szMessage, int _v) { - GENERIC_LOG(LogTypes::AUDIO, _v, _szMessage); + GENERIC_LOG(LogTypes::AUDIO, (LogTypes::LOG_LEVELS)_v, _szMessage); } // __________________________________________________________________________________________________ @@ -729,10 +728,11 @@ void Callback_DSPInterrupt() } // __________________________________________________________________________________________________ -// Callback_PADLog +// Callback_PADLog // void Callback_PADLog(const TCHAR* _szMessage) { + // FIXME add levels INFO_LOG(SERIALINTERFACE, _szMessage); } @@ -769,7 +769,7 @@ void Callback_KeyPress(int key, bool shift, bool control) // void Callback_WiimoteLog(const TCHAR* _szMessage, int _v) { - GENERIC_LOG(LogTypes::WII_IPC_WIIMOTE, _v, _szMessage); + GENERIC_LOG(LogTypes::WII_IPC_WIIMOTE, (LogTypes::LOG_LEVELS)_v, _szMessage); } // TODO: Get rid of at some point diff --git a/Source/Core/Core/Src/CoreRerecording.cpp b/Source/Core/Core/Src/CoreRerecording.cpp index 25c3382f62..050d3c232e 100644 --- a/Source/Core/Core/Src/CoreRerecording.cpp +++ b/Source/Core/Core/Src/CoreRerecording.cpp @@ -115,7 +115,7 @@ void RerecordingStart() ReRecTimer.Start(); // Logging - //Console::Print("RerecordingStart: %i\n", g_FrameCounter); + //DEBUG_LOG(CONSOLE, "RerecordingStart: %i\n", g_FrameCounter); } // Reset the frame counter @@ -159,7 +159,7 @@ void WindBack(int Counter) ReRecTimer.WindBackStartingTime((u64)CurrentTimeSeconds * 1000); // Logging - Console::Print("WindBack: %i %u\n", Counter, (u64)CurrentTimeSeconds); + DEBUG_LOG(CONSOLE, "WindBack: %i %u\n", Counter, (u64)CurrentTimeSeconds); } //////////////////////////////////////// diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index cefc6a96cb..c3f1631509 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -241,7 +241,7 @@ void CEXIMemoryCard::TransferByte(u8 &byte) { command = byte; // first byte is command byte = 0xFF; // would be tristate, but we don't care. - WARN_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: command %02x", byte) + WARN_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: command %02x", command) if(command == cmdClearStatus) { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h index e06ac407d7..0b9d6cc2e1 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h @@ -136,7 +136,7 @@ protected: of 4 byte commands. */ // ---------------- void DumpCommands(u32 _CommandAddress, size_t _NumberOfCommands = 8, - int LogType = LogTypes::WII_IPC_HLE, int Verbosity = 0) + LogTypes::LOG_TYPE LogType = LogTypes::WII_IPC_HLE, LogTypes::LOG_LEVELS Verbosity =LogTypes::LDEBUG) { GENERIC_LOG(LogType, Verbosity, "CommandDump of %s", GetDeviceName().c_str()); @@ -184,8 +184,8 @@ protected: INFO_LOG(WII_IPC_HLE,"%s - IOCtlV OutBuffer[%i]:", GetDeviceName().c_str(), i); INFO_LOG(WII_IPC_HLE, " OutBuffer: 0x%08x (0x%x):", OutBuffer, OutBufferSize); - #if defined LOGLEVEL && LOGLEVEL > 2 - DumpCommands(OutBuffer, OutBufferSize, LogTypes::WII_IPC_HLE, 1); + #if defined LOGLEVEL && LOGLEVEL > NOTICE_LEVEL + DumpCommands(OutBuffer, OutBufferSize, LogTypes::WII_IPC_HLE, LogTypes::LINFO); #endif } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 94962bb7fd..ce2b239961 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -18,8 +18,6 @@ ////////////////////////////////////////////////////////////////////////// // Include -#include "ConsoleWindow.h" // Common - #include "../Core.h" // Local core functions #include "../Debugger/Debugger_SymbolMap.h" #include "../Host.h" @@ -1811,7 +1809,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) "anyway. It is strongly recommed to save and/or restart the\n" "emulation."); } - Console::Print("IPC CommandDisconnect\n"); + INFO_LOG(CONSOLE, "IPC CommandDisconnect\n"); // Send message to plugin /* diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index 18b5baabc7..35517c2bc4 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -54,8 +54,6 @@ if it works I'd rather be without FreeLibrary() between Start and Stop. //////////////////////////////////////*/ - - ////////////////////////////////////////////////////////////////////////////////////////// // Include // ŻŻŻŻŻŻŻŻŻŻŻŻ @@ -71,7 +69,6 @@ #include "FileSearch.h" // Common #include "FileUtil.h" #include "StringUtil.h" -#include "ConsoleWindow.h" #include "Setup.h" // Create the plugin manager class @@ -84,13 +81,16 @@ CPluginManager CPluginManager::m_Instance; // ŻŻŻŻŻŻŻŻŻŻŻŻ // The plugin manager is some sort of singleton that runs during Dolphin's entire lifespan. -CPluginManager::CPluginManager() : - m_params(SConfig::GetInstance().m_LocalCoreStartupParameter) +CPluginManager::CPluginManager() { m_PluginGlobals = new PLUGIN_GLOBALS; + + // Start LogManager + m_PluginGlobals->logManager = LogManager::GetInstance(); m_PluginGlobals->eventHandler = EventHandler::GetInstance(); m_PluginGlobals->config = (void *)&SConfig::GetInstance(); - m_PluginGlobals->messageLogger = NULL; + + m_params = &(SConfig::GetInstance().m_LocalCoreStartupParameter); // Set initial values to NULL. m_video = NULL; @@ -104,7 +104,7 @@ CPluginManager::CPluginManager() : // This will call FreeLibrary() for all plugins CPluginManager::~CPluginManager() { - Console::Print("Delete CPluginManager\n"); + INFO_LOG(CONSOLE, "Delete CPluginManager\n"); delete m_PluginGlobals; delete m_dsp; @@ -113,7 +113,7 @@ CPluginManager::~CPluginManager() { if (m_pad[i] && OkayToInitPlugin(i)) { - Console::Print("Delete: %i\n", i); + INFO_LOG(CONSOLE, "Delete: %i\n", i); delete m_pad[i]; } m_pad[i] = NULL; @@ -138,13 +138,13 @@ bool CPluginManager::InitPlugins() PanicAlert("Can't init DSP Plugin"); return false; } - Console::Print("Before GetVideo\n"); + INFO_LOG(CONSOLE, "Before GetVideo\n"); if (!GetVideo()) { PanicAlert("Can't init Video Plugin"); return false; } - Console::Print("After GetVideo\n"); + INFO_LOG(CONSOLE, "After GetVideo\n"); // Check if we get at least one pad or wiimote bool pad = false; @@ -154,7 +154,7 @@ bool CPluginManager::InitPlugins() for (int i = 0; i < MAXPADS; i++) { // Check that the plugin has a name - if (!m_params.m_strPadPlugin[i].empty()) + if (!m_params->m_strPadPlugin[i].empty()) GetPad(i); // Check that GetPad succeeded if (m_pad[i] != NULL) @@ -167,9 +167,9 @@ bool CPluginManager::InitPlugins() } // Init wiimote - if (m_params.bWii) { + if (m_params->bWii) { for (int i = 0; i < MAXWIIMOTES; i++) { - if (!m_params.m_strWiimotePlugin[i].empty()) + if (!m_params->m_strWiimotePlugin[i].empty()) GetWiimote(i); if (m_wiimote[i] != NULL) @@ -257,7 +257,8 @@ CPluginInfo::CPluginInfo(const char *_rFilename) // We are now done with this plugin and will call FreeLibrary() delete plugin; - } + } else + PanicAlert("PluginInfo: %s is not valid", _rFilename); } /////////////////////////////////////////// @@ -276,10 +277,6 @@ void CPluginManager::GetPluginInfo(CPluginInfo *&info, std::string Filename) if (m_PluginInfos.at(i).GetFilename() == Filename) { info = &m_PluginInfos.at(i); - if (info == NULL) - { - PanicAlert("error reading info from dll"); - } return; } } @@ -292,29 +289,23 @@ void *CPluginManager::LoadPlugin(const char *_rFilename, int Number) { // Create a string of the filename std::string Filename = _rFilename; + + if (!File::Exists(_rFilename)) { + PanicAlert("Error loading %s: can't find file", _rFilename); + return NULL; + } /* Avoid calling LoadLibrary() again and instead point to the plugin info that we found when Dolphin was started */ CPluginInfo *info = NULL; - if (!Filename.empty()){ - GetPluginInfo(info, Filename); - if (info == NULL) - { - PanicAlert("Can't open %s, it's missing", _rFilename); - return NULL; - } - } - else{ - PanicAlert("error with dll Filename (its NULL)"); + GetPluginInfo(info, Filename); + if (! info) { + PanicAlert("Error loading %s: can't read info", _rFilename); return NULL; } - + PLUGIN_TYPE type = info->GetPluginInfo().Type; Common::CPlugin *plugin = NULL; - // Check again that the file exists, the first check is when CPluginInfo info is created - if (!File::Exists(_rFilename)) - return NULL; - switch (type) { case PLUGIN_TYPE_VIDEO: @@ -355,7 +346,7 @@ int CPluginManager::OkayToInitPlugin(int Plugin) { // Compare it to the earlier plugins for (int i = 0; i < Plugin; i++) - if (m_params.m_strPadPlugin[Plugin] == m_params.m_strPadPlugin[i]) + if (m_params->m_strPadPlugin[Plugin] == m_params->m_strPadPlugin[i]) return i; // No there is no duplicate plugin @@ -376,18 +367,18 @@ void CPluginManager::ScanForPlugins() // Get plugins dir CFileSearch::XStringVector Directories; - #if defined(__APPLE__) - Directories.push_back(File::GetPluginsDirectory()); - #else - Directories.push_back(std::string(PLUGINS_DIR)); - #endif +#if defined(__APPLE__) + Directories.push_back(File::GetPluginsDirectory()); +#else + Directories.push_back(std::string(PLUGINS_DIR)); +#endif CFileSearch::XStringVector Extensions; - Extensions.push_back("*" PLUGIN_SUFFIX); + Extensions.push_back("*" PLUGIN_SUFFIX); // Get all DLL files in the plugins dir CFileSearch FileSearch(Extensions, Directories); const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames(); - + if (rFilenames.size() > 0) { for (size_t i = 0; i < rFilenames.size(); i++) @@ -399,7 +390,7 @@ void CPluginManager::ScanForPlugins() printf("Bad Path %s\n", rFilenames[i].c_str()); return; } - + CPluginInfo PluginInfo(orig_name.c_str()); if (PluginInfo.IsValid()) { @@ -424,16 +415,16 @@ void CPluginManager::ScanForPlugins() Common::PluginPAD *CPluginManager::GetPad(int controller) { if (m_pad[controller] != NULL) - if (m_pad[controller]->GetFilename() == m_params.m_strPadPlugin[controller]) + if (m_pad[controller]->GetFilename() == m_params->m_strPadPlugin[controller]) return m_pad[controller]; // Else do this if (OkayToInitPlugin(controller) == -1) { - m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params.m_strPadPlugin[controller].c_str(), controller); - Console::Print("LoadPlugin: %i\n", controller); + m_pad[controller] = (Common::PluginPAD*)LoadPlugin(m_params->m_strPadPlugin[controller].c_str(), controller); + INFO_LOG(CONSOLE, "LoadPlugin: %i\n", controller); } else { - Console::Print("Pointed: %i to %i\n", controller, OkayToInitPlugin(controller)); + INFO_LOG(CONSOLE, "Pointed: %i to %i\n", controller, OkayToInitPlugin(controller)); m_pad[controller] = m_pad[OkayToInitPlugin(controller)]; } return m_pad[controller]; @@ -442,21 +433,21 @@ Common::PluginPAD *CPluginManager::GetPad(int controller) Common::PluginWiimote *CPluginManager::GetWiimote(int controller) { if (m_wiimote[controller] != NULL) - if (m_wiimote[controller]->GetFilename() == m_params.m_strWiimotePlugin[controller]) + if (m_wiimote[controller]->GetFilename() == m_params->m_strWiimotePlugin[controller]) return m_wiimote[controller]; // Else load a new plugin - m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin(m_params.m_strWiimotePlugin[controller].c_str()); + m_wiimote[controller] = (Common::PluginWiimote*)LoadPlugin(m_params->m_strWiimotePlugin[controller].c_str()); return m_wiimote[controller]; } Common::PluginDSP *CPluginManager::GetDSP() { if (m_dsp != NULL) - if (m_dsp->GetFilename() == m_params.m_strDSPPlugin) + if (m_dsp->GetFilename() == m_params->m_strDSPPlugin) return m_dsp; // Else load a new plugin - m_dsp = (Common::PluginDSP*)LoadPlugin(m_params.m_strDSPPlugin.c_str()); + m_dsp = (Common::PluginDSP*)LoadPlugin(m_params->m_strDSPPlugin.c_str()); return m_dsp; } @@ -467,7 +458,7 @@ Common::PluginVideo *CPluginManager::GetVideo() if (m_video != NULL) { // Check if the video plugin has been changed - if (m_video->GetFilename() == m_params.m_strVideoPlugin) + if (m_video->GetFilename() == m_params->m_strVideoPlugin) return m_video; // Then free the current video plugin, else @@ -475,7 +466,7 @@ Common::PluginVideo *CPluginManager::GetVideo() } // and load a new plugin - m_video = (Common::PluginVideo*)LoadPlugin(m_params.m_strVideoPlugin.c_str()); + m_video = (Common::PluginVideo*)LoadPlugin(m_params->m_strVideoPlugin.c_str()); return m_video; } diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h index e3b4aebbeb..60a8769452 100644 --- a/Source/Core/Core/Src/PluginManager.h +++ b/Source/Core/Core/Src/PluginManager.h @@ -76,7 +76,7 @@ private: Common::PluginWiimote *m_wiimote[4]; Common::PluginDSP *m_dsp; - SCoreStartupParameter& m_params; + SCoreStartupParameter * m_params; CPluginManager(); ~CPluginManager(); void GetPluginInfo(CPluginInfo *&info, std::string Filename); diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index 8bb6570903..8d3b274c7c 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -12,7 +12,6 @@ files = ["ActionReplay.cpp", "CoreRerecording.cpp", "CoreTiming.cpp", "Host.cpp", - "LogManager.cpp", "MemTools.cpp", "PatchEngine.cpp", "PluginManager.cpp", diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index d5b6f56774..771380fb23 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -642,14 +642,6 @@ RelativePath=".\src\JitWindow.h" > - - - - diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 868031e18e..60b46928c7 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -37,7 +37,6 @@ #include "Debugger.h" #include "RegisterWindow.h" -#include "LogWindow.h" #include "BreakpointWindow.h" #include "MemoryWindow.h" #include "JitWindow.h" @@ -121,8 +120,7 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) EVT_MENU(IDM_JITPOFF, CCodeWindow::OnCPUMode) EVT_MENU(IDM_JITSROFF, CCodeWindow::OnCPUMode) - EVT_MENU(IDM_LOGWINDOW, CCodeWindow::OnToggleLogWindow) // Views - EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow) + EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow) //views EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow) EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow) EVT_MENU(IDM_JITWINDOW, CCodeWindow::OnToggleJitWindow) @@ -167,7 +165,6 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter /* Remember to initialize potential new controls with NULL there, otherwise m_dialog = true and things may crash */ - , m_LogWindow(NULL) , m_RegisterWindow(NULL) , m_BreakpointWindow(NULL) , m_MemoryWindow(NULL) @@ -208,7 +205,6 @@ CCodeWindow::~CCodeWindow() this->Save(file); if (m_BreakpointWindow) m_BreakpointWindow->Save(file); - if (m_LogWindow) m_LogWindow->Save(file); if (m_RegisterWindow) m_RegisterWindow->Save(file); if (m_MemoryWindow) m_MemoryWindow->Save(file); if (m_JitWindow) m_JitWindow->Save(file); @@ -236,7 +232,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) NotifyMapLoaded(); break; - case IDM_UPDATELOGDISPLAY: + /* case IDM_UPDATELOGDISPLAY: if (m_LogWindow) { @@ -244,7 +240,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) } break; - + */ case IDM_UPDATEDISASMDIALOG: Update(); @@ -295,7 +291,6 @@ void CCodeWindow::Load_( IniFile &ini ) DebuggerFont.SetNativeFontInfoUserDesc(wxString(fontDesc.c_str(), wxConvUTF8)); // Decide what windows to use - ini.Get("ShowOnStart", "LogWindow", &bLogWindow, true); ini.Get("ShowOnStart", "RegisterWindow", &bRegisterWindow, true); ini.Get("ShowOnStart", "BreakpointWindow", &bBreakpointWindow, true); ini.Get("ShowOnStart", "MemoryWindow", &bMemoryWindow, true); @@ -318,6 +313,11 @@ void CCodeWindow::Load( IniFile &ini ) ini.Get("CodeWindow", "w", &w, GetSize().GetWidth()); ini.Get("CodeWindow", "h", &h, GetSize().GetHeight()); this->SetSize(x, y, w, h); + ini.Get("MainWindow", "x", &x, 100); + ini.Get("MainWindow", "y", &y, 100); + ini.Get("MainWindow", "w", &w, 800); + ini.Get("MainWindow", "h", &h, 600); + GetParent()->SetSize(x, y, w, h); } @@ -327,6 +327,10 @@ void CCodeWindow::Save(IniFile &ini) const ini.Set("CodeWindow", "y", GetPosition().y); ini.Set("CodeWindow", "w", GetSize().GetWidth()); ini.Set("CodeWindow", "h", GetSize().GetHeight()); + ini.Set("MainWindow", "x", GetParent()->GetPosition().x); + ini.Set("MainWindow", "y", GetParent()->GetPosition().y); + ini.Set("MainWindow", "w", GetParent()->GetSize().GetWidth()); + ini.Set("MainWindow", "h", GetParent()->GetSize().GetHeight()); ini.Set("ShowOnStart", "DebuggerFont", std::string(DebuggerFont.GetNativeFontInfoUserDesc().mb_str())); @@ -335,7 +339,6 @@ void CCodeWindow::Save(IniFile &ini) const ini.Set("ShowOnStart", "BootToPause", GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE)); // Save windows settings - ini.Set("ShowOnStart", "LogWindow", GetMenuBar()->IsChecked(IDM_LOGWINDOW)); ini.Set("ShowOnStart", "RegisterWindow", GetMenuBar()->IsChecked(IDM_REGISTERWINDOW)); ini.Set("ShowOnStart", "BreakpointWindow", GetMenuBar()->IsChecked(IDM_BREAKPOINTWINDOW)); ini.Set("ShowOnStart", "MemoryWindow", GetMenuBar()->IsChecked(IDM_MEMORYWINDOW)); @@ -375,15 +378,6 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart // ================= - // Additional dialogs -#if LOGLEVEL > 0 - if (bLogWindow) - { - m_LogWindow = new CLogWindow(this); - m_LogWindow->Show(true); - } -#endif - if (bRegisterWindow) { m_RegisterWindow = new CRegisterWindow(this); @@ -504,12 +498,6 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam // --------------- wxMenu* pDebugDialogs = new wxMenu; - if (LogManager::GetLevel() > 0) - { - wxMenuItem* pLogWindow = pDebugDialogs->Append(IDM_LOGWINDOW, _T("&LogManager"), wxEmptyString, wxITEM_CHECK); - pLogWindow->Check(bLogWindow); - } - wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK); pRegister->Check(bRegisterWindow); diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index 398df860fa..2ab3436855 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -27,7 +27,6 @@ #include "CoreParameter.h" class CRegisterWindow; -class CLogWindow; class CBreakPointWindow; class CMemoryWindow; class CJitWindow; @@ -146,7 +145,6 @@ class CCodeWindow // Settings bool bAutomaticStart; bool bBootToPause; - bool bLogWindow; bool bRegisterWindow; bool bBreakpointWindow; bool bMemoryWindow; @@ -156,7 +154,6 @@ class CCodeWindow // Sub dialogs wxMenuBar* pMenuBar; - CLogWindow* m_LogWindow; CRegisterWindow* m_RegisterWindow; CBreakPointWindow* m_BreakpointWindow; CMemoryWindow* m_MemoryWindow; @@ -195,7 +192,6 @@ class CCodeWindow void OnToggleRegisterWindow(wxCommandEvent& event); void OnToggleBreakPointWindow(wxCommandEvent& event); - void OnToggleLogWindow(wxCommandEvent& event); void OnToggleMemoryWindow(wxCommandEvent& event); void OnToggleJitWindow(wxCommandEvent& event); void OnToggleSoundWindow(wxCommandEvent& event); diff --git a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp index 0093a6159c..d6db3feb6b 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp @@ -41,7 +41,6 @@ #include "Debugger.h" #include "RegisterWindow.h" -#include "LogWindow.h" #include "BreakpointWindow.h" #include "MemoryWindow.h" #include "JitWindow.h" @@ -308,44 +307,6 @@ void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event) { } - - - -///////////////////////////////////////////////////////////////////////////////////////////////// -// Show and hide windows -///////////////////////////////////////////////////////////////////////////////////////////////// -void CCodeWindow::OnToggleLogWindow(wxCommandEvent& event) -{ - if (LogManager::GetLevel() > 0) - { - bool show = GetMenuBar()->IsChecked(event.GetId()); - - if (show) - { - if (!m_LogWindow) - { - m_LogWindow = new CLogWindow(this); - } - - m_LogWindow->Show(true); - } - else // hide - { - // If m_dialog is NULL, then possibly the system - // didn't report the checked menu item status correctly. - // It should be true just after the menu item was selected, - // if there was no modeless dialog yet. - wxASSERT(m_LogWindow != NULL); - - if (m_LogWindow) - { - m_LogWindow->Hide(); - } - } - } -} - - void CCodeWindow::OnToggleRegisterWindow(wxCommandEvent& event) { bool show = GetMenuBar()->IsChecked(event.GetId()); diff --git a/Source/Core/DebuggerWX/Src/Debugger.h b/Source/Core/DebuggerWX/Src/Debugger.h index 8a383d89ab..7a32f67410 100644 --- a/Source/Core/DebuggerWX/Src/Debugger.h +++ b/Source/Core/DebuggerWX/Src/Debugger.h @@ -18,17 +18,6 @@ #ifndef _DEBUGGER_H #define _DEBUGGER_H -enum -{ - IDM_LOG, - IDM_UPDATELOG, - IDM_CLEARLOG, - IDM_LOGCHECKS, - IDM_OPTIONS, - IDM_ENABLEALL, - IDM_RADIO0, - IDM_SUBMITCMD = 300, -}; #define wxUSE_XPM_IN_MSW 1 #define USE_XPM_BITMAPS 1 diff --git a/Source/Core/DebuggerWX/Src/MemoryWindow.h b/Source/Core/DebuggerWX/Src/MemoryWindow.h index c0d790e533..12fde57d8c 100644 --- a/Source/Core/DebuggerWX/Src/MemoryWindow.h +++ b/Source/Core/DebuggerWX/Src/MemoryWindow.h @@ -29,7 +29,6 @@ #include "CoreParameter.h" class CRegisterWindow; -class CLogWindow; class CBreakPointWindow; class CMemoryWindow diff --git a/Source/Core/DebuggerWX/Src/SConscript b/Source/Core/DebuggerWX/Src/SConscript index 044509d665..2eeb171a3e 100644 --- a/Source/Core/DebuggerWX/Src/SConscript +++ b/Source/Core/DebuggerWX/Src/SConscript @@ -5,21 +5,21 @@ Import('env') if not env['HAVE_WX']: Return() -files = ["LogWindow.cpp", - "BreakPointDlg.cpp", - "BreakpointView.cpp", - "CodeView.cpp", - "BreakpointWindow.cpp", - "CodeWindow.cpp", - "CodeWindowSJP.cpp", - "CodeView.cpp", - "MemoryCheckDlg.cpp", - "MemoryView.cpp", - "MemoryWindow.cpp", - "RegisterWindow.cpp", - "RegisterView.cpp", - "JitWindow.cpp", - ] +files = [ + "BreakPointDlg.cpp", + "BreakpointView.cpp", + "CodeView.cpp", + "BreakpointWindow.cpp", + "CodeWindow.cpp", + "CodeWindowSJP.cpp", + "CodeView.cpp", + "MemoryCheckDlg.cpp", + "MemoryView.cpp", + "MemoryWindow.cpp", + "RegisterWindow.cpp", + "RegisterView.cpp", + "JitWindow.cpp", + ] wxenv = env.Clone() wxenv.Append( CPPDEFINES = [ diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index e0688f5e69..5ce4872e26 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -1051,6 +1051,14 @@ RelativePath=".\Src\FrameWiimote.cpp" > + + + + diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 3be36d3e72..2130d4dc3f 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -21,7 +21,6 @@ #include "Core.h" // Core #include "HW/EXI.h" #include "HW/SI.h" -#include "ConsoleWindow.h" #include "Globals.h" // Local #include "ConfigMain.h" @@ -875,7 +874,7 @@ void CConfigMain::OnConfig(wxCommandEvent& event) void CConfigMain::CallConfig(wxChoice* _pChoice) { int Index = _pChoice->GetSelection(); - Console::Print("CallConfig: %i\n", Index); + INFO_LOG(CONSOLE, "CallConfig: %i\n", Index); if (Index >= 0) { @@ -888,7 +887,7 @@ void CConfigMain::CallConfig(wxChoice* _pChoice) void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename) { - Console::Print("FillChoiceBox\n"); + INFO_LOG(CONSOLE, "FillChoiceBox\n"); _pChoice->Clear(); @@ -924,7 +923,7 @@ bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename) { const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); _rFilename = pInfo->GetFilename(); - Console::Print("GetFilename: %i %s\n", Index, _rFilename.c_str()); + INFO_LOG(CONSOLE, "GetFilename: %i %s\n", Index, _rFilename.c_str()); return(true); } diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index f17ecb6f02..0d7a0e93ec 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -48,7 +48,6 @@ be accessed from Core::GetWindowHandle(). #include "FileUtil.h" #include "Timer.h" #include "Setup.h" -#include "ConsoleWindow.h" #include "ConfigManager.h" // Core #include "Core.h" @@ -190,7 +189,7 @@ int abc = 0; case WIIMOTE_RECONNECT: // The Wiimote plugin has been shut down, now reconnect the Wiimote - //Console::Print("WIIMOTE_RECONNECT\n"); + //INFO_LOG(CONSOLE, "WIIMOTE_RECONNECT\n"); Core::ReconnectWiimote(); return 0; @@ -210,7 +209,7 @@ int abc = 0; case OPENGL_VIDEO_STOP: // The Video thread has been shut down Core::VideoThreadEnd(); - //Console::Print("OPENGL_VIDEO_STOP\n"); + //INFO_LOG(CONSOLE, "OPENGL_VIDEO_STOP\n"); return 0; #endif // ----------------------------- @@ -273,6 +272,7 @@ EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen) EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore) EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle) EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar) +EVT_MENU(IDM_TOGGLE_LOGWINDOW, CFrame::OnToggleLogWindow) EVT_MENU(IDM_TOGGLE_STATUSBAR, CFrame::OnToggleStatusbar) EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState) @@ -293,13 +293,15 @@ END_EVENT_TABLE() // Creation and close, quit functions // ---------------------------------------------------------------------------- -CFrame::CFrame(wxFrame* parent, +CFrame::CFrame(bool showLogWindow, + wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) + , m_bLogWindow(showLogWindow || SConfig::GetInstance().m_InterfaceLogWindow) , m_pStatusBar(NULL), bRenderToMain(true) , HaveLeds(false), HaveSpeakers(false) , m_Panel(NULL) @@ -326,6 +328,8 @@ CFrame::CFrame(wxFrame* parent, // Give it a status bar m_pStatusBar = CreateStatusBar(1, wxST_SIZEGRIP, ID_STATUSBAR); + if (!SConfig::GetInstance().m_InterfaceStatusbar) + m_pStatusBar->Hide(); // Give it a menu bar CreateMenu(); @@ -334,6 +338,10 @@ CFrame::CFrame(wxFrame* parent, //m_Panel = new wxPanel(this, IDM_MPANEL); m_Panel = new CPanel(this, IDM_MPANEL); + m_LogWindow = new CLogWindow(this); + if (m_bLogWindow) + m_LogWindow->Show(); + m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT); @@ -348,6 +356,8 @@ CFrame::CFrame(wxFrame* parent, // Create the toolbar RecreateToolbar(); + if (!SConfig::GetInstance().m_InterfaceToolbar) + TheToolBar->Hide(); FitInside(); diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index bd5523c097..632ccf8c43 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -27,6 +27,7 @@ #include //////////////////////////////// #include "CDUtils.h" +#include "LogWindow.h" ////////////////////////////////////////////////////////////////////////// // A shortcut to access the bitmaps @@ -48,7 +49,8 @@ class CFrame : public wxFrame { public: - CFrame(wxFrame* parent, + CFrame(bool showLogWindow, + wxFrame* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Dolphin"), const wxPoint& pos = wxDefaultPosition, @@ -98,6 +100,8 @@ class CFrame : public wxFrame wxPanel* m_Panel; wxToolBar* TheToolBar; wxToolBarToolBase* m_ToolPlay; + bool m_bLogWindow; + CLogWindow* m_LogWindow; char **drives; @@ -199,6 +203,7 @@ class CFrame : public wxFrame void OnToggleThrottle(wxCommandEvent& event); void OnResize(wxSizeEvent& event); void OnToggleToolbar(wxCommandEvent& event); + void OnToggleLogWindow(wxCommandEvent& event); void OnToggleStatusbar(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); void OnDoubleClick(wxMouseEvent& event); void OnMotion(wxMouseEvent& event); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index b4749b32cd..1bcabf0d47 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -44,11 +44,11 @@ be accessed from Core::GetWindowHandle(). #include "GameListCtrl.h" #include "BootManager.h" #include "SDCardWindow.h" +#include "LogWindow.h" #include "Common.h" // Common #include "FileUtil.h" #include "Timer.h" -#include "ConsoleWindow.h" #include "Setup.h" #include "ConfigManager.h" // Core @@ -153,9 +153,11 @@ void CFrame::CreateMenu() // Tools menu wxMenu* toolsMenu = new wxMenu; toolsMenu->AppendCheckItem(IDM_TOGGLE_TOOLBAR, _T("View &Toolbar")); - toolsMenu->Check(IDM_TOGGLE_TOOLBAR, true); + toolsMenu->Check(IDM_TOGGLE_TOOLBAR, SConfig::GetInstance().m_InterfaceToolbar); toolsMenu->AppendCheckItem(IDM_TOGGLE_STATUSBAR, _T("View &Statusbar")); - toolsMenu->Check(IDM_TOGGLE_STATUSBAR, true); + toolsMenu->Check(IDM_TOGGLE_STATUSBAR, SConfig::GetInstance().m_InterfaceStatusbar); + toolsMenu->AppendCheckItem(IDM_TOGGLE_LOGWINDOW, _T("View &Logwindow")); + toolsMenu->Check(IDM_TOGGLE_LOGWINDOW, m_bLogWindow); toolsMenu->AppendSeparator(); toolsMenu->Append(IDM_MEMCARD, _T("&Memcard Manager")); toolsMenu->Append(IDM_CHEATS, _T("Action &Replay Manager")); @@ -350,7 +352,8 @@ void CFrame::InitBitmaps() ////////////////////////// // Update in case the bitmap has been updated - if (GetToolBar() != NULL) RecreateToolbar(); + if (GetToolBar() != NULL) + RecreateToolbar(); } @@ -733,7 +736,7 @@ void CFrame::OnToggleToolbar(wxCommandEvent& event) { wxToolBarBase* toolBar = GetToolBar(); - if (event.IsChecked()) + if (SConfig::GetInstance().m_InterfaceToolbar = event.IsChecked() == true) { CFrame::RecreateToolbar(); } @@ -749,7 +752,7 @@ void CFrame::OnToggleToolbar(wxCommandEvent& event) // Let us enable and disable the status bar void CFrame::OnToggleStatusbar(wxCommandEvent& event) { - if (event.IsChecked()) + if (SConfig::GetInstance().m_InterfaceStatusbar = event.IsChecked() == true) m_pStatusBar->Show(); else m_pStatusBar->Hide(); @@ -757,6 +760,17 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event) this->SendSizeEvent(); } +// Let us enable and disable the log window +void CFrame::OnToggleLogWindow(wxCommandEvent& event) +{ + if (SConfig::GetInstance().m_InterfaceLogWindow = event.IsChecked() == true) + m_LogWindow->Show(); + else + m_LogWindow->Hide(); + + this->SendSizeEvent(); +} + // Update the enabled/disabled status void CFrame::UpdateGUI() @@ -815,7 +829,8 @@ void CFrame::UpdateGUI() m_pMenuItemPlay->SetText(_("&Play")); } - if (GetToolBar() != NULL) GetToolBar()->Realize(); + if (GetToolBar() != NULL) + GetToolBar()->Realize(); if (!initialized) diff --git a/Source/Core/DolphinWX/Src/FrameWiimote.cpp b/Source/Core/DolphinWX/Src/FrameWiimote.cpp index 1ef7946528..fbbee20c42 100644 --- a/Source/Core/DolphinWX/Src/FrameWiimote.cpp +++ b/Source/Core/DolphinWX/Src/FrameWiimote.cpp @@ -23,7 +23,6 @@ #include "Frame.h" #include "FileUtil.h" #include "StringUtil.h" -#include "ConsoleWindow.h" #include "GameListCtrl.h" #include "BootManager.h" @@ -414,7 +413,7 @@ void CFrame::DoMoveIcons() for (int i = 0; i < 4; i++) m_StatBmp[i]->Hide(); else // if(!m_StatBmp[0]->IsShown()) for (int i = 0; i < 4; i++) m_StatBmp[i]->Show(); - //Console::Print("LED: %i ", Rect.GetWidth()); + //INFO_LOG(CONSOLE, "LED: %i ", Rect.GetWidth()); } // If there is not room for the speaker icons hide them @@ -430,7 +429,7 @@ void CFrame::DoMoveIcons() for(int i = 0; i < 3; i++) m_StatBmp[i + 4]->Hide(); else // if(!m_StatBmp[4]->IsShown()) for (int i = 0; i < 3; i++) m_StatBmp[i + 4]->Show(); - //Console::Print("Speaker: %i\n", Rect.GetWidth()); + //INFO_LOG(CONSOLE, "Speaker: %i\n", Rect.GetWidth()); } } diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 64b2fa34c2..37929c4e8d 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -183,7 +183,7 @@ void CGameListCtrl::Update() SetColumnWidth(COLUMN_COMPANY, 100); SetColumnWidth(COLUMN_NOTES, 150); SetColumnWidth(COLUMN_COUNTRY, 32); - SetColumnWidth(COLUMN_EMULATION_STATE, 150); + SetColumnWidth(COLUMN_EMULATION_STATE, 130); // add all items for (int i = 0; i < (int)m_ISOFiles.size(); i++) @@ -883,10 +883,15 @@ void CGameListCtrl::AutomaticColumnWidth() } else if (GetColumnCount() > 4) { - int resizable = rc.GetWidth() - (213 + GetColumnWidth(COLUMN_SIZE)); + int resizable = rc.GetWidth() - ( + GetColumnWidth(COLUMN_BANNER) + + GetColumnWidth(COLUMN_COUNTRY) + + GetColumnWidth(COLUMN_SIZE) + + GetColumnWidth(COLUMN_EMULATION_STATE) + + 5); // some pad to keep the horizontal scrollbar away :) SetColumnWidth(COLUMN_TITLE, wxMax(0.3*resizable, 100)); - SetColumnWidth(COLUMN_COMPANY, wxMax(0.2*resizable, 100)); + SetColumnWidth(COLUMN_COMPANY, wxMax(0.2*resizable, 90)); SetColumnWidth(COLUMN_NOTES, wxMax(0.5*resizable, 100)); } } diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index e9d4e9bcfd..c077d3684d 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -85,6 +85,7 @@ enum IDM_TOGGLE_DUALCORE, // Other IDM_TOGGLE_SKIPIDLE, IDM_TOGGLE_TOOLBAR, + IDM_TOGGLE_LOGWINDOW, IDM_TOGGLE_STATUSBAR, IDM_NOTIFYMAPLOADED, IDM_OPENCONTAININGFOLDER, diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp new file mode 100644 index 0000000000..ae91c32052 --- /dev/null +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -0,0 +1,360 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + + +#include +#include +#include +#include +#include + +#include "Core.h" // for Core::GetState() +#include "LogWindow.h" +#include "Console.h" + +#define UPDATETIME 1000 + +BEGIN_EVENT_TABLE(CLogWindow, wxDialog) + EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit) + EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear) + EVT_BUTTON(IDM_TOGGLEALL, CLogWindow::OnToggleAll) + EVT_RADIOBOX(IDM_VERBOSITY, CLogWindow::OnOptionsCheck) + EVT_CHECKBOX(IDM_WRITEFILE, CLogWindow::OnOptionsCheck) + EVT_CHECKBOX(IDM_WRITECONSOLE, CLogWindow::OnOptionsCheck) + EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck) + EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer) +END_EVENT_TABLE() + +CLogWindow::CLogWindow(wxWindow* parent) + : wxDialog(parent, wxID_ANY, wxT("Log/Console"), + wxPoint(100, 700), wxSize(800, 270), + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), + Listener("LogWindow") +{ + m_logManager = LogManager::GetInstance(); + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + m_logManager->addListener((LogTypes::LOG_TYPE)i, this); + m_fileLog = m_logManager->getFileListener(); + m_console = m_logManager->getConsoleListener(); + + m_writeFile = true; + m_writeConsole = true; + + CreateGUIControls(); + + LoadSettings(); +} + +void CLogWindow::CreateGUIControls() +{ + wxBoxSizer* sUber = new wxBoxSizer(wxHORIZONTAL), // whole plane + * sLeft = new wxBoxSizer(wxVERTICAL), // LEFT sizer + * sRight = new wxBoxSizer(wxVERTICAL), // RIGHT sizer + * sRightBottom = new wxBoxSizer(wxHORIZONTAL); // submit row + + // Left side: buttons (-submit), options, and log type selection + wxStaticBoxSizer* sbLeftOptions = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Options")); + + wxArrayString wxLevels; + for (int i = 0; i < LOGLEVEL; ++i) + wxLevels.Add(wxString::Format(wxT("%i"), i)); + m_verbosity = new wxRadioBox(this, IDM_VERBOSITY, wxT("Verbosity"), wxDefaultPosition, wxDefaultSize, wxLevels, 0, wxRA_SPECIFY_COLS, wxDefaultValidator); + sbLeftOptions->Add(m_verbosity); + + m_writeFileCB = new wxCheckBox(this, IDM_WRITEFILE, wxT("Write to File"), wxDefaultPosition, wxDefaultSize, 0); + sbLeftOptions->Add(m_writeFileCB); + + m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE, wxT("Write to Console"), wxDefaultPosition, wxDefaultSize, 0); + sbLeftOptions->Add(m_writeConsoleCB); + + sLeft->Add(sbLeftOptions, 0, wxEXPAND); + + wxBoxSizer* sLogCtrl = new wxBoxSizer(wxHORIZONTAL); + sLogCtrl->Add(new wxButton(this, IDM_TOGGLEALL, wxT("Toggle all"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1); + sLogCtrl->Add(new wxButton(this, IDM_CLEARLOG, wxT("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1); + sLeft->Add(sLogCtrl, 0, wxEXPAND); + + m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxDefaultSize); + sLeft->Add(m_checks, 1, wxEXPAND); + + // Right side: Log viewer and submit row + m_log = new wxTextCtrl(this, IDM_LOG, wxEmptyString, wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); + //m_log->SetFont(DebuggerFont); + + m_cmdline = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition); + //m_cmdline->SetFont(DebuggerFont); + + sRightBottom->Add(m_cmdline, 1, wxEXPAND); + sRightBottom->Add(new wxButton(this, IDM_SUBMITCMD, wxT("Submit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT)); + sRight->Add(m_log, 1, wxEXPAND | wxSHRINK); + sRight->Add(sRightBottom, 0, wxEXPAND); + + // Take care of the main sizer and some settings + sUber->Add(sLeft, 0, wxEXPAND); + sUber->Add(sRight, 1, wxEXPAND); + + SetSizer(sUber); + SetAffirmativeId(IDM_SUBMITCMD); + UpdateChecks(); + m_cmdline->SetFocus(); + + m_logTimer = new wxTimer(this, IDTM_UPDATELOG); + m_logTimer->Start(UPDATETIME); +} + +CLogWindow::~CLogWindow() +{ + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + { + m_logManager->removeListener((LogTypes::LOG_TYPE)i, this); + } + m_logTimer->Stop(); + delete m_logTimer; + + SaveSettings(); +} + +void CLogWindow::SaveSettings() +{ + IniFile ini; + ini.Set("LogWindow", "x", GetPosition().x); + ini.Set("LogWindow", "y", GetPosition().y); + ini.Set("LogWindow", "w", GetSize().GetWidth()); + ini.Set("LogWindow", "h", GetSize().GetHeight()); + ini.Set("Options", "Verbosity", m_verbosity->GetSelection()); + ini.Set("Options", "WriteToFile", m_writeFile); + ini.Set("Options", "WriteToConsole", m_writeConsole); + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + ini.Set("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i)); + ini.Save(LOGGER_CONFIG_FILE); +} + +void CLogWindow::LoadSettings() +{ + IniFile ini; + ini.Load(LOGGER_CONFIG_FILE); + int x,y,w,h,verbosity; + ini.Get("LogWindow", "x", &x, GetPosition().x); + ini.Get("LogWindow", "y", &y, GetPosition().y); + ini.Get("LogWindow", "w", &w, GetSize().GetWidth()); + ini.Get("LogWindow", "h", &h, GetSize().GetHeight()); + SetSize(x, y, w, h); + ini.Get("Options", "Verbosity", &verbosity, 2); + m_verbosity->SetSelection(verbosity); + ini.Get("Options", "WriteToFile", &m_writeFile, true); + m_writeFileCB->SetValue(m_writeFile); + ini.Get("Options", "WriteToConsole", &m_writeConsole, true); + m_writeConsoleCB->SetValue(m_writeConsole); + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + { + bool enable; + ini.Get("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true); + + if (enable) + m_logManager->addListener((LogTypes::LOG_TYPE)i, this); + else + m_logManager->removeListener((LogTypes::LOG_TYPE)i, this); + + if (m_writeFile && enable) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + else + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + + if (m_writeConsole && enable) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console); + else + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console); + } + UpdateChecks(); +} + +void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event)) +{ + Console_Submit(m_cmdline->GetValue().To8BitData()); + m_cmdline->SetValue(wxEmptyString); + NotifyUpdate(); +} + +void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event)) +{ + m_log->Clear(); + + //msgQueue.Clear() + for (unsigned int i = 0; i < msgQueue.size(); i++) + msgQueue.pop(); + + m_console->ClearScreen(); + NOTICE_LOG(CONSOLE, "Console cleared"); + NotifyUpdate(); +} + +// Enable or disable all boxes for the current verbosity level and save the changes. +void CLogWindow::OnToggleAll(wxCommandEvent& WXUNUSED (event)) +{ + static bool enable = false; + + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + { + m_checks->Check(i, enable); + m_logManager->setEnable((LogTypes::LOG_TYPE)i, enable); + + if (enable) + { + m_logManager->addListener((LogTypes::LOG_TYPE)i, this); + + if (m_writeFile) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + if (m_writeConsole) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console); + } + else + { + m_logManager->removeListener((LogTypes::LOG_TYPE)i, this); + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console); + } + } + + enable = !enable; + SaveSettings(); +} + +// Append checkboxes and update checked groups. +void CLogWindow::UpdateChecks() +{ + // This is only run once to append checkboxes to the wxCheckListBox. + if (m_checks->GetCount() == 0) + { + // [F|RES] hide the window while we fill it... wxwidgets gets trouble + // if you don't do it (at least the win version) + m_checks->Show(false); + + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + { + m_checks->Append(wxString::FromAscii(m_logManager->getFullName( (LogTypes::LOG_TYPE)i ))); + } + m_checks->Show(true); + } + + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + { + m_checks->Check(i, m_logManager->isListener((LogTypes::LOG_TYPE)i, this)); + } +} + +// When an option is changed, save the change +void CLogWindow::OnOptionsCheck(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case IDM_VERBOSITY: + { + // get selection + int v = m_verbosity->GetSelection(); + + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + { + m_logManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v); + } + } + break; + + case IDM_WRITEFILE: + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + { + m_writeFile = event.IsChecked(); + if (m_checks->IsChecked(i)) + { + if (m_writeFile) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + else + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + } + } + break; + + case IDM_WRITECONSOLE: + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + { + m_writeConsole = event.IsChecked(); + if (m_checks->IsChecked(i)) + { + if (m_writeConsole) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console); + else + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console); + } + } + break; + } + SaveSettings(); +} + +// When a checkbox is changed +void CLogWindow::OnLogCheck(wxCommandEvent& event) +{ + int i = event.GetInt(); + if (m_checks->IsChecked(i)) + { + m_logManager->addListener((LogTypes::LOG_TYPE)i, this); + + if (m_writeFile) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_fileLog); + if (m_writeConsole) + m_logManager->addListener((LogTypes::LOG_TYPE)i, m_console); + } + else + { + m_logManager->removeListener((LogTypes::LOG_TYPE)i, this); + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog); + m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_console); + } + SaveSettings(); +} + +void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event)) +{ + UpdateLog(); +} + +void CLogWindow::NotifyUpdate() +{ + UpdateChecks(); + UpdateLog(); +} + +void CLogWindow::UpdateLog() +{ + m_logTimer->Stop(); + for (unsigned int i = 0; i < msgQueue.size(); i++) + { + m_log->AppendText(msgQueue.front()); + msgQueue.pop(); + } + m_logTimer->Start(UPDATETIME); +} + +void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text) +{ + if (level > NOTICE_LEVEL) + return; + + if (msgQueue.size() >= 100) + msgQueue.pop(); + msgQueue.push(wxString::FromAscii(text)); +} diff --git a/Source/Core/DolphinWX/Src/LogWindow.h b/Source/Core/DolphinWX/Src/LogWindow.h new file mode 100644 index 0000000000..7c4b4547a7 --- /dev/null +++ b/Source/Core/DolphinWX/Src/LogWindow.h @@ -0,0 +1,80 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef LOGWINDOW_H_ +#define LOGWINDOW_H_ +#include "LogManager.h" +#include "IniFile.h" +#include + +enum +{ + IDM_LOG, + IDM_CLEARLOG, + IDM_LOGCHECKS, + IDM_OPTIONS, + IDM_TOGGLEALL, + IDM_WRITEFILE, + IDM_WRITECONSOLE, + IDTM_UPDATELOG, + IDM_VERBOSITY, + IDM_SUBMITCMD = 300, +}; + +class wxTextCtrl; +class wxCheckListBox; +class wxString; + +class CLogWindow : public wxDialog,Listener +{ +public: + CLogWindow(wxWindow* parent); + ~CLogWindow(); + void NotifyUpdate(); + + void SaveSettings(); + void LoadSettings(); + void Log(LogTypes::LOG_LEVELS, const char *text); + +private: + wxTextCtrl* m_log, * m_cmdline; + bool m_writeFile, m_writeConsole; + wxCheckBox* m_writeFileCB, * m_writeConsoleCB; + wxTimer *m_logTimer; + wxCheckListBox* m_checks; + wxRadioBox *m_verbosity; + FileLogListener *m_fileLog; + ConsoleListener *m_console; + LogManager *m_logManager; + std::queue msgQueue; + + DECLARE_EVENT_TABLE() + + void CreateGUIControls(); + void OnSubmit(wxCommandEvent& event); + void OnOptionsCheck(wxCommandEvent& event); + void OnLogCheck(wxCommandEvent& event); + void OnClear(wxCommandEvent& event); + void OnToggleAll(wxCommandEvent& event); + void OnLogTimer(wxTimerEvent& WXUNUSED(event)); + + void UpdateChecks(); + void UpdateLog(); + +}; + +#endif /*LOGWINDOW_H_*/ diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index b3462aa412..40b0ac78ca 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -35,10 +35,10 @@ #include "CPUDetect.h" #include "IniFile.h" #include "FileUtil.h" -#include "ConsoleWindow.h" #include "Setup.h" #include "Host.h" // Core +#include "PluginManager.h" #include "Globals.h" // Local #include "Main.h" @@ -62,6 +62,7 @@ IMPLEMENT_APP(DolphinApp) CFrame* main_frame = NULL; CCodeWindow* g_pCodeWindow = NULL; +LogManager *logManager = NULL; #ifdef WIN32 //Has no error handling. @@ -100,6 +101,7 @@ bool DolphinApp::OnInit() { //Console::Open(); + NOTICE_LOG(BOOT, "Starting application"); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; @@ -220,7 +222,7 @@ bool DolphinApp::OnInit() #endif // Load CONFIG_FILE settings - SConfig::GetInstance().LoadSettings(); + SConfig::GetInstance().LoadSettings(); // Enable the PNG image handler wxInitAllImageHandlers(); @@ -232,10 +234,7 @@ bool DolphinApp::OnInit() const char *title = "Dolphin SVN R " SVN_REV_STR; #endif - // --------------------------------------------------------------------------------------- // If we are debugging let use save the main window position and size - // TODO: Save position and size on exit - // ------------ IniFile ini; ini.Load(DEBUGGER_CONFIG_FILE); @@ -245,19 +244,17 @@ bool DolphinApp::OnInit() ini.Get("MainWindow", "y", &y, 100); ini.Get("MainWindow", "w", &w, 800); ini.Get("MainWindow", "h", &h, 600); - // ------------------- + if (UseDebugger) { - main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), + main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), wxPoint(x, y), wxSize(w, h)); } else { - main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), - wxPoint(100, 100), wxSize(w, h)); + main_frame = new CFrame(UseLogger, (wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title), + wxPoint(100, 100), wxSize(800, 600)); } - // ------------------ - // Create debugging window if (UseDebugger) @@ -265,16 +262,6 @@ bool DolphinApp::OnInit() g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, main_frame); g_pCodeWindow->Show(true); } - if(!UseDebugger && UseLogger) - { - #if LOGLEVEL > 0 - // We aren't using debugger, just logger - // Should be fine for a local copy - CLogWindow* m_LogWindow = new CLogWindow(main_frame); - m_LogWindow->Show(true); - #endif - } - // --------------------------------------------------- // Check the autoboot options. diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 892fbfd9bf..5bcbcba0ca 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -26,11 +26,7 @@ #include "BootManager.h" void* g_pCodeWindow = NULL; void* main_frame = NULL; -bool wxPanicAlert(const char* text, bool /*yes_no*/) -{ - return(true); -} - +LogManager *logManager = NULL; // OK, this thread boundary is DANGEROUS on linux // wxPostEvent / wxAddPendingEvent is the solution. @@ -195,6 +191,7 @@ int main(int argc, char* argv[]) return(1); } std::string bootFile(args_info.inputs[0]); + logManager = (LogManager *)CPluginManager::GetInstance().GetGlobals()->logManager; updateMainFrameEvent.Init(); cpu_info.Detect(); diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index e72ff4143b..1f5321c956 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -7,7 +7,6 @@ wxenv = env.Clone() files = [ 'BootManager.cpp', -# 'Config.cpp', 'cmdline.c', ] @@ -22,6 +21,7 @@ if wxenv['HAVE_WX']: 'ARCodeAddEdit.cpp', 'ConfigMain.cpp', 'Frame.cpp', + 'LogWindow.cpp', 'FrameTools.cpp', 'GameListCtrl.cpp', 'Globals.cpp', @@ -29,7 +29,6 @@ if wxenv['HAVE_WX']: 'ISOProperties.cpp', 'MemcardManager.cpp', 'MemoryCards/GCMemcard.cpp', -# 'PluginManager.cpp', 'PatchAddEdit.cpp', 'CheatsWindow.cpp', 'stdafx.cpp', diff --git a/Source/Core/InputCommon/Src/SDL.cpp b/Source/Core/InputCommon/Src/SDL.cpp index bc8402e8c5..6b04b94116 100644 --- a/Source/Core/InputCommon/Src/SDL.cpp +++ b/Source/Core/InputCommon/Src/SDL.cpp @@ -201,9 +201,9 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in #ifdef SHOW_PAD_STATUS // Show the status of all connected pads - if ((g_LastPad == 0 && Controller == 0) || Controller < g_LastPad) Console::ClearScreen(); + //if ((g_LastPad == 0 && Controller == 0) || Controller < g_LastPad) Console::ClearScreen(); g_LastPad = Controller; - Console::Print( + DEBUG_LOG(CONSOLE, "Pad | Number:%i Enabled:%i Handle:%i\n" "Main Stick | X:%03i Y:%03i\n" "C Stick | X:%03i Y:%03i\n" diff --git a/Source/Core/InputCommon/Src/SDL.h b/Source/Core/InputCommon/Src/SDL.h index 3cbd299e41..3d6560b147 100644 --- a/Source/Core/InputCommon/Src/SDL.h +++ b/Source/Core/InputCommon/Src/SDL.h @@ -45,7 +45,6 @@ #endif #include "Common.h" // Common -#include "ConsoleWindow.h" //////////////////////////// diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 2dfd7ffa2e..b70a3a2c41 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -24,7 +24,6 @@ #include "MemoryUtil.h" #include "Thread.h" #include "OpcodeDecoding.h" -#include "ConsoleWindow.h" #include "Fifo.h" diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 697a3b58bd..4dbfeee204 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -65,12 +65,10 @@ int TexDecoder_GetTextureSizeInBytes(int width, int height, int format) u32 TexDecoder_GetTlutHash(const u8* src, int len) { //char str[40000], st[20]; str[0]='\0';for (int i=0;i - - diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index d5743d4895..216410945f 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -98,7 +98,7 @@ typedef struct { void *eventHandler; void *config; - void *messageLogger; + void *logManager; } PLUGIN_GLOBALS; /////////////////////////////// diff --git a/Source/Plugins/Plugin_DSP_HLE/Plugin_DSP_HLE.vcproj b/Source/Plugins/Plugin_DSP_HLE/Plugin_DSP_HLE.vcproj index d6ad64216a..c73e8a0cbb 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Plugin_DSP_HLE.vcproj +++ b/Source/Plugins/Plugin_DSP_HLE/Plugin_DSP_HLE.vcproj @@ -69,7 +69,7 @@ /> #endif -#include "ConsoleWindow.h" // Open and close console - #include "Debugger.h" #include "PBView.h" #include "IniFile.h" @@ -61,7 +59,7 @@ void CDebugger::DoScrollBlocks() else if(GetAsyncKeyState(VK_NUMPAD2)) A += 0.11; - Console::Print("GetScrollPos:%i GetScrollRange:%i GetPosition:%i GetLastPosition:%i GetMaxWidth:%i \ + DEBUG_LOG(CONSOLE, "GetScrollPos:%i GetScrollRange:%i GetPosition:%i GetLastPosition:%i GetMaxWidth:%i \ GetLineLength:%i XYToPosition:%i\n \ GetScrollPos * GetLineLength + GetScrollRange:%i A:%f\n", m_bl95->GetScrollPos(wxVERTICAL), m_bl95->GetScrollRange(wxVERTICAL), diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp index 10fba2e918..776028e7b3 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Debugger.cpp @@ -31,8 +31,6 @@ #include #endif -#include "ConsoleWindow.h" // Open and close console - #include "Debugger.h" #include "PBView.h" #include "IniFile.h" @@ -165,17 +163,11 @@ void CDebugger::OnClose(wxCloseEvent& /*event*/) file.Save(DEBUGGER_CONFIG_FILE); EndModal(0); -#ifdef _WIN32 - Console::Close(); // Take the console window with it -#endif } void CDebugger::DoHide() { Hide(); -#ifdef _WIN32 - Console::Close(); // The console goes with the wx window -#endif } void CDebugger::DoShow() @@ -683,12 +675,13 @@ void CDebugger::ShowHideConsole(wxCommandEvent& event) void CDebugger::DoShowHideConsole() { -#ifdef _WIN32 - if(m_options->IsChecked(3)) - OpenConsole(); - else - CloseConsole(); -#endif +// #ifdef _WIN32 +// if(m_options->IsChecked(3)) +// OpenConsole(); +// else +// CloseConsole(); +// #endif + PanicAlert("oh crap"); } // ============== diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Logging.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Logging.cpp index 0b8299c25a..d0a9307f23 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Logging.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Debugger/Logging.cpp @@ -33,7 +33,6 @@ #endif #include "StringUtil.h" // Common -#include "ConsoleWindow.h" // Open, close, clear console window #include "../Debugger/Debugger.h" // Local #include "../Debugger/PBView.h" @@ -887,8 +886,8 @@ void Logging_(short* _pBuffer, int _iSize, int a, bool Wii, ParamBlockType &PBs, // ======================================================================================= // Print // ---------------- - Console::ClearScreen(); - Console::Print("%s", sbuff.c_str()); + // FIXME: Console::ClearScreen(); + INFO_LOG(CONSOLE, "%s", sbuff.c_str()); sbuff.clear(); strcpy(buffer, ""); // ================ diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Globals.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/Globals.cpp index f42ade67b6..f85653195a 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Globals.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Globals.cpp @@ -21,40 +21,6 @@ #include "Globals.h" #include "Common.h" -void __Log(int, const char *fmt, ...) -{ - DebugLog(fmt); -} - -void __Log_(int v, const char *fmt, ...) -{ - char Msg[512]; - va_list ap; - - va_start(ap, fmt); - vsprintf(Msg, fmt, ap); - va_end(ap); - - g_dspInitialize.pLog(Msg, v); -} - -void DebugLog(const char* _fmt, ...) -{ -#if defined(_DEBUG) || defined(DEBUGFAST) -//if(strncmp (_fmt, "AX", 2)) // match = 0, in that case this is ignored -{ - char Msg[512]; - va_list ap; - - va_start(ap, _fmt); - vsprintf(Msg, _fmt, ap); - va_end(ap); - - g_dspInitialize.pLog(Msg, 0); -} -#endif -} - extern u8* g_pMemory; // debugger externals that are needed even in Release builds diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/Globals.h b/Source/Plugins/Plugin_DSP_HLE/Src/Globals.h index 681b972b0d..094dc97173 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/Globals.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/Globals.h @@ -20,18 +20,9 @@ #include "Common.h" #include "pluginspecs_dsp.h" -#include "ConsoleWindow.h" #include "StringUtil.h" extern DSPInitialize g_dspInitialize; -void DebugLog(const char* _fmt, ...); -void __Log_(int v, const char *fmt, ...); - -#if defined(_DEBUG) || defined(DEBUGFAST) - #define LOG_(v, ...) __Log_(v, __VA_ARGS__); -#else - #define LOG_(_v_, ...) -#endif extern bool gSSBM; extern bool gSSBMremedy1; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp index c1fcd02717..27e1bda607 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp @@ -20,7 +20,6 @@ #include // System #include "Thread.h" // Common -#include "ConsoleWindow.h" #include "../Config.h" // Local #include "../Globals.h" diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp index 6cb7aed966..21a6bbdeb6 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp @@ -147,7 +147,7 @@ if(m_frame->ScanMails) #endif TmpMailLog += Msg; TmpMailLog += "\n"; - LOG_(1, Msg); // also write it to the log + DEBUG_LOG(DSPHLE, "%s", Msg); // also write it to the log #if defined(HAVE_WX) && HAVE_WX } } @@ -415,11 +415,11 @@ void CUCode_AX::HandleMail(u32 _uMail) if ((_uMail & 0xFFFF0000) == MAIL_AX_ALIST) { // a new List - DebugLog(" >>>> u32 MAIL : General Mail (%08x)", _uMail); + DEBUG_LOG(DSPHLE, " >>>> u32 MAIL : General Mail (%08x)", _uMail); } else { - DebugLog(" >>>> u32 MAIL : AXTask Mail (%08x)", _uMail); + DEBUG_LOG(DSPHLE, " >>>> u32 MAIL : AXTask Mail (%08x)", _uMail); AXTask(_uMail); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp index ed7be21fde..4a5aed0bff 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -178,7 +178,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs) && gSequenced) // on and off option { //PanicAlert("Update %i: %i = %04x", i, updpar, upddata); - //DebugLog("Update: %i = %04x", updpar, upddata); + //DEBUG_LOG(DSPHLE, "Update: %i = %04x", updpar, upddata); pDest[updpar] = upddata; } if (updpar == 7 && upddata == 1) on++; @@ -364,7 +364,7 @@ bool CUCode_AXWii::AXTask(u32& _uMail) /* case 0x0009: Addr__9 = Memory_Read_U32(uAddress); uAddress += 4; - DebugLog("AXLIST 6 address: %08x", Addr__9); + DEBUG_LOG(DSPHLE, "AXLIST 6 address: %08x", Addr__9); break;*/ case 0x000a: // AXLIST_COMPRESSORTABLE diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_CARD.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_CARD.cpp index 3289304014..f4fa51869a 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_CARD.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_CARD.cpp @@ -24,7 +24,7 @@ CUCode_CARD::CUCode_CARD(CMailHandler& _rMailHandler) : IUCode(_rMailHandler) { - DebugLog("CUCode_CARD - initialized"); + DEBUG_LOG(DSPHLE, "CUCode_CARD - initialized"); m_rMailHandler.PushMail(DSP_INIT); } @@ -52,7 +52,7 @@ void CUCode_CARD::HandleMail(u32 _uMail) } else { - DebugLog("CUCode_CARD - unknown cmd: %x (size %i)", _uMail); + DEBUG_LOG(DSPHLE, "CUCode_CARD - unknown cmd: %x (size %i)", _uMail); } m_rMailHandler.PushMail(DSP_DONE); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_InitAudioSystem.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_InitAudioSystem.cpp index 9cc863798a..6d725141da 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_InitAudioSystem.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_InitAudioSystem.cpp @@ -26,7 +26,7 @@ CUCode_InitAudioSystem::CUCode_InitAudioSystem(CMailHandler& _rMailHandler) , m_NextParameter(0) , IsInitialized(false) { - DebugLog("CUCode_InitAudioSystem - initialized"); + DEBUG_LOG(DSPHLE, "CUCode_InitAudioSystem - initialized"); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Jac.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Jac.cpp index 15b608ecce..cf83c02015 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Jac.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Jac.cpp @@ -24,7 +24,7 @@ CUCode_Jac::CUCode_Jac(CMailHandler& _rMailHandler) : IUCode(_rMailHandler) , m_bListInProgress(false) { - DebugLog("CUCode_Jac: init"); + DEBUG_LOG(DSPHLE, "CUCode_Jac: init"); m_rMailHandler.PushMail(0xDCD10000); m_rMailHandler.PushMail(0x80000000); } @@ -69,7 +69,7 @@ void CUCode_Jac::HandleMail(u32 _uMail) default: PanicAlert("UCode Jac"); - DebugLog("UCode Jac - unknown cmd: %x", _uMail & 0xFFFF); + DEBUG_LOG(DSPHLE, "UCode Jac - unknown cmd: %x", _uMail & 0xFFFF); break; } } @@ -105,8 +105,8 @@ void CUCode_Jac::ExecuteList() u16 cmd = Read16(); u16 sync = Read16(); - DebugLog("=============================================================================="); - DebugLog("UCode Jac - execute dlist (cmd: 0x%04x : sync: 0x%04x)", cmd, sync); + DEBUG_LOG(DSPHLE, "=============================================================================="); + DEBUG_LOG(DSPHLE, "UCode Jac - execute dlist (cmd: 0x%04x : sync: 0x%04x)", cmd, sync); switch (cmd) { @@ -121,11 +121,11 @@ void CUCode_Jac::ExecuteList() tmp[2] = Read32(); tmp[3] = Read32(); - DebugLog("DsetupTable"); - DebugLog("???: 0x%08x", tmp[0]); - DebugLog("DSPRES_FILTER (size: 0x40): 0x%08x", tmp[1]); - DebugLog("DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); - DebugLog("???: 0x%08x", tmp[3]); + DEBUG_LOG(DSPHLE, "DsetupTable"); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[0]); + DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size: 0x40): 0x%08x", tmp[1]); + DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[3]); } break; @@ -140,16 +140,16 @@ void CUCode_Jac::ExecuteList() tmp[1] = Read32(); tmp[2] = Read32(); - DebugLog("UpdateDSPChannel"); - DebugLog("audiomemory: 0x%08x", tmp[0]); - DebugLog("audiomemory: 0x%08x", tmp[1]); - DebugLog("DSPADPCM_FILTER (size: 0x40): 0x%08x", tmp[2]); + DEBUG_LOG(DSPHLE, "UpdateDSPChannel"); + DEBUG_LOG(DSPHLE, "audiomemory: 0x%08x", tmp[0]); + DEBUG_LOG(DSPHLE, "audiomemory: 0x%08x", tmp[1]); + DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x40): 0x%08x", tmp[2]); } break; default: PanicAlert("UCode Jac unknown cmd: %s (size %i)", cmd, m_numSteps); - DebugLog("Jac UCode - unknown cmd: %x (size %i)", cmd, m_numSteps); + DEBUG_LOG(DSPHLE, "Jac UCode - unknown cmd: %x (size %i)", cmd, m_numSteps); break; } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp index 36f58c3e78..7929ed9465 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp @@ -25,7 +25,7 @@ CUCode_Rom::CUCode_Rom(CMailHandler& _rMailHandler) , m_BootTask_numSteps(0) , m_NextParameter(0) { - DebugLog("UCode_Rom - initialized"); + DEBUG_LOG(DSPHLE, "UCode_Rom - initialized"); m_rMailHandler.Clear(); m_rMailHandler.PushMail(0x8071FEED); } @@ -98,13 +98,13 @@ void CUCode_Rom::BootUCode() crc = (crc << 3) | (crc >> 29); } - DebugLog("CurrentUCode SOURCE Addr: 0x%08x", m_CurrentUCode.m_RAMAddress); - DebugLog("CurrentUCode Length: 0x%08x", m_CurrentUCode.m_Length); - DebugLog("CurrentUCode DEST Addr: 0x%08x", m_CurrentUCode.m_IMEMAddress); - DebugLog("CurrentUCode ???: 0x%08x", m_CurrentUCode.m_Unk); - DebugLog("CurrentUCode init_vector: 0x%08x", m_CurrentUCode.m_StartPC); - DebugLog("CurrentUCode CRC: 0x%08x", crc); - DebugLog("BootTask - done"); + DEBUG_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_CurrentUCode.m_RAMAddress); + DEBUG_LOG(DSPHLE, "CurrentUCode Length: 0x%08x", m_CurrentUCode.m_Length); + DEBUG_LOG(DSPHLE, "CurrentUCode DEST Addr: 0x%08x", m_CurrentUCode.m_IMEMAddress); + DEBUG_LOG(DSPHLE, "CurrentUCode ???: 0x%08x", m_CurrentUCode.m_Unk); + DEBUG_LOG(DSPHLE, "CurrentUCode init_vector: 0x%08x", m_CurrentUCode.m_StartPC); + DEBUG_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", crc); + DEBUG_LOG(DSPHLE, "BootTask - done"); CDSPHandler::GetInstance().SetUCode(crc); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp index 43cfe66c61..b713b8cbe5 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda.cpp @@ -34,7 +34,7 @@ CUCode_Zelda::CUCode_Zelda(CMailHandler& _rMailHandler) , m_step(0) , m_readOffset(0) { - DebugLog("UCode_Zelda - add boot mails for handshake"); + DEBUG_LOG(DSPHLE, "UCode_Zelda - add boot mails for handshake"); m_rMailHandler.PushMail(DSP_INIT); m_rMailHandler.PushMail(0x80000000); // handshake memset(m_Buffer, 0, sizeof(m_Buffer)); @@ -126,8 +126,8 @@ void CUCode_Zelda::ExecuteList() u32 Command = (Temp >> 24) & 0x7f; u32 Sync = Temp >> 16; - DebugLog("=============================================================================="); - DebugLog("Zelda UCode - execute dlist (cmd: 0x%04x : sync: 0x%04x)", Command, Sync); + DEBUG_LOG(DSPHLE, "=============================================================================="); + DEBUG_LOG(DSPHLE, "Zelda UCode - execute dlist (cmd: 0x%04x : sync: 0x%04x)", Command, Sync); switch (Command) { @@ -140,11 +140,11 @@ void CUCode_Zelda::ExecuteList() tmp[2] = Read32(); tmp[3] = Read32(); - DebugLog("DsetupTable"); - DebugLog("???: 0x%08x", tmp[0]); - DebugLog("DSPRES_FILTER (size: 0x40): 0x%08x", tmp[1]); - DebugLog("DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); - DebugLog("???: 0x%08x", tmp[3]); + DEBUG_LOG(DSPHLE, "DsetupTable"); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[0]); + DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size: 0x40): 0x%08x", tmp[1]); + DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[3]); } break; @@ -159,14 +159,14 @@ void CUCode_Zelda::ExecuteList() // We're ready to mix mixer_HLEready = true; - DebugLog("Update the SoundThread to be in sync"); + DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync"); soundStream->Update(); //do it in this thread to avoid sync problems - DebugLog("DsyncFrame"); - DebugLog("???: 0x%08x", tmp[0]); - DebugLog("???: 0x%08x", tmp[1]); - DebugLog("DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); + DEBUG_LOG(DSPHLE, "DsyncFrame"); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[0]); + DEBUG_LOG(DSPHLE, "???: 0x%08x", tmp[1]); + DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", tmp[2]); } break; @@ -188,9 +188,9 @@ void CUCode_Zelda::ExecuteList() tmp[0] = Read32(); tmp[1] = Read32(); - DebugLog("DSetDolbyDelay"); - DebugLog("DOLBY2_DELAY_BUF (size 0x960): 0x%08x", tmp[0]); - DebugLog("DSPRES_FILTER (size 0x500): 0x%08x", tmp[1]); + DEBUG_LOG(DSPHLE, "DSetDolbyDelay"); + DEBUG_LOG(DSPHLE, "DOLBY2_DELAY_BUF (size 0x960): 0x%08x", tmp[0]); + DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size 0x500): 0x%08x", tmp[1]); } break; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp index 8bc61a8e67..d52e5bc91b 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCodes.cpp @@ -44,7 +44,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler) case 0xd73338cf: // IPL case 0x42f64ac4: // Luigi (after fix) case 0x4be6a5cb: // AC, Pikmin (after fix) - Console::Print("JAC ucode chosen\n"); + INFO_LOG(CONSOLE, "JAC ucode chosen\n"); return new CUCode_Jac(_rMailHandler); case 0x3ad3b7ac: // Naruto3 @@ -56,20 +56,20 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler) case 0x07f88145: // bustamove, ikaruga, fzero, robotech battle cry, star soldier, soul calibur2, // Zelda:OOT, Tony hawk, viewtiful joe case 0xe2136399: // billy hatcher, dragonballz, mario party 5, TMNT, ava1080 - Console::Print("AX ucode chosen, yay!\n"); + INFO_LOG(CONSOLE, "AX ucode chosen, yay!\n"); return new CUCode_AX(_rMailHandler); case 0x6CA33A6D: // DK Jungle Beat case 0x86840740: // zelda case 0x56d36052: // mario case 0x2fcdf1ec: // mariokart, zelda 4 swords - Console::Print("Zelda ucode chosen\n"); + INFO_LOG(CONSOLE, "Zelda ucode chosen\n"); return new CUCode_Zelda(_rMailHandler); // WII CRCs case 0x6c3f6f94: // zelda - PAL case 0xd643001f: // mario galaxy - PAL - Console::Print("Zelda Wii ucode chosen\n"); + INFO_LOG(CONSOLE, "Zelda Wii ucode chosen\n"); return new CUCode_Zelda(_rMailHandler); case 0x5ef56da3: // AX demo @@ -79,7 +79,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler) case 0xb7eb9a9c: // Wii Pikmin - JAP case 0x4cc52064: // Bleach: Versus Crusade case 0xd9c4bf34: // WiiMenu ... pray - Console::Print("Wii - AXWii chosen\n"); + INFO_LOG(CONSOLE, "Wii - AXWii chosen\n"); return new CUCode_AXWii(_rMailHandler, _CRC); default: diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp index b7672c1965..e159276b78 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp @@ -26,7 +26,6 @@ CDebugger* m_frame = NULL; #endif -#include "ConsoleWindow.h" // Common: For the Windows console #include "ChunkFile.h" #include "WaveFile.h" #include "PCHW/Mixer.h" @@ -40,6 +39,7 @@ CDebugger* m_frame = NULL; #include "PCHW/NullSoundStream.h" // Declarations and definitions +PLUGIN_GLOBALS* globals = NULL; DSPInitialize g_dspInitialize; u8* g_pMemory; extern std::vector sMailLog, sMailTime; @@ -127,12 +127,13 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle #endif +/* // Open and close console void OpenConsole() { #if defined (_WIN32) Console::Open(155, 100, "Sound Debugging"); // give room for 100 rows - Console::Print("OpenConsole > Console opened\n"); + DEBUG_LOG(CONSOLE, "OpenConsole > Console opened\n"); MoveWindow(Console::GetHwnd(), 0,400, 1280,550, true); // move window, TODO: make this // adjustable from the debugging window #endif @@ -144,7 +145,7 @@ void CloseConsole() FreeConsole(); #endif } - +*/ // Exported fuctions @@ -186,7 +187,11 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo) #endif } -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { + +void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +{ + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); } void DllConfig(HWND _hParent) diff --git a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj index 125ca31bf4..ff1aeb5d63 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj +++ b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj @@ -1,7 +1,7 @@ 20 && logall) {Console::ClearScreen();} + //FIXME if (n > 20 && logall) {Console::ClearScreen();} for (int i = 0; i < _num; i++) { // --------------------------------------------------------------------------------------- @@ -68,7 +67,7 @@ int ReadOutPBs(AXParamBlock * _pPBs, int _num) // Create a shortcut that let us update struct members short * pDest = (short *) & _pPBs[i]; - if (n > 20 && logall) {Console::Print("%c%i:", 223, i);} // logging + if (n > 20 && logall) {DEBUG_LOG(DSPHLE, "%c%i:", 223, i);} // logging // -------------- // Here we update the PB. We do it by going through all 192 / 2 = 96 u16 values @@ -80,7 +79,7 @@ int ReadOutPBs(AXParamBlock * _pPBs, int _num) { if (pSrc[p] != 0 && n > 20 && logall) { - Console::Print("%i %04x | ", p, Common::swap16(pSrc[p])); + DEBUG_LOG(DSPHLE, "%i %04x | ", p, Common::swap16(pSrc[p])); } } @@ -88,7 +87,7 @@ int ReadOutPBs(AXParamBlock * _pPBs, int _num) } - if(n > 20 && logall) {Console::Print("\n");} // logging + if(n > 20 && logall) {DEBUG_LOG(DSPHLE, "\n");} // logging // -------------- // Here we update the block address to the starting point of the next PB blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo; diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/disassemble.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/disassemble.cpp index b29289fdad..0b7ceb8894 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/disassemble.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/disassemble.cpp @@ -258,7 +258,7 @@ char* gd_dis_params(gd_globals_t* gdg, opc_t* opc, uint16 op1, uint16 op2, char* break; default: - ErrorLog("Unknown parameter type: %x\n", opc->params[j].type); + ERROR_LOG(DSPHLE, "Unknown parameter type: %x\n", opc->params[j].type); exit(-1); break; } @@ -313,7 +313,7 @@ uint16 gd_dis_get_opcode_size(gd_globals_t* gdg) if (!opc) { - ErrorLog("get_opcode_size ARGH"); + ERROR_LOG(DSPHLE, "get_opcode_size ARGH"); exit(0); } @@ -341,7 +341,7 @@ uint16 gd_dis_get_opcode_size(gd_globals_t* gdg) if (!opc_ext) { - ErrorLog("get_opcode_size ext ARGH"); + ERROR_LOG(DSPHLE, "get_opcode_size ext ARGH"); } return(opc_ext->size); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp index 2f0b1b8fcb..79a2154af1 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp @@ -91,7 +91,7 @@ uint16 dsp_read_aram() default: val = (g_dspInitialize.pARAM_Read_U8(Address) << 8) | g_dspInitialize.pARAM_Read_U8(Address + 1); Address += 2; - ErrorLog("Unknown DSP Format %i", gdsp_ifx_regs[DSP_FORMAT]); + ERROR_LOG(DSPHLE, "Unknown DSP Format %i", gdsp_ifx_regs[DSP_FORMAT]); break; } diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_ext_op.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_ext_op.cpp index 51aee169ba..3eec84083f 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_ext_op.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_ext_op.cpp @@ -41,7 +41,7 @@ void dsp_op_ext_r_epi(uint16 _Opcode) switch (op) { case 0x00: - ErrorLog("dsp_op_ext_r_epi"); + ERROR_LOG(DSPHLE, "dsp_op_ext_r_epi"); break; case 0x01: diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interface.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interface.cpp index f19c84ad31..07afe04b83 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interface.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interface.cpp @@ -133,7 +133,7 @@ void gdsp_mbox_write_l(uint8 mbx, uint16 val) if (mbx == GDSP_MBOX_DSP) { - DebugLog("- Write DSP Mail: 0x%08x (pc=0x%04x)\n", gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.err_pc); + DEBUG_LOG(DSPHLE, "- Write DSP Mail: 0x%08x (pc=0x%04x)\n", gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.err_pc); } } @@ -199,9 +199,9 @@ void gdsp_ifx_write(uint16 addr, uint16 val) default: /* if ((addr & 0xff) >= 0xa0 && reg_names[addr - 0xa0]) - DebugLog("%04x MW %s (%04x)\n", g_dsp.pc, reg_names[addr - 0xa0], val); + DEBUG_LOG(DSPHLE, "%04x MW %s (%04x)\n", g_dsp.pc, reg_names[addr - 0xa0], val); else - DebugLog("%04x MW %04x (%04x)\n", g_dsp.pc, addr, val);*/ + DEBUG_LOG(DSPHLE, "%04x MW %04x (%04x)\n", g_dsp.pc, addr, val);*/ gdsp_ifx_regs[addr] = val; break; } @@ -259,7 +259,7 @@ void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size) } g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size); - DebugLog("*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc); + DEBUG_LOG(DSPHLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc); #if DUMP_DSP_IMEM DumpDSPCode(addr, size, g_dsp.iram_crc ); @@ -269,7 +269,7 @@ void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size) void gdsp_idma_out(uint16 dsp_addr, uint32 addr, uint32 size) { - ErrorLog("*** idma_out IRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); + ERROR_LOG(DSPHLE, "*** idma_out IRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); } @@ -277,7 +277,7 @@ void gdsp_ddma_in(uint16 dsp_addr, uint32 addr, uint32 size) { if ((addr & 0x7FFFFFFF) > 0x01FFFFFF) { - ErrorLog("*** ddma_in read from invalid addr (0x%08x)\n", addr); + ERROR_LOG(DSPHLE, "*** ddma_in read from invalid addr (0x%08x)\n", addr); return; } @@ -288,7 +288,7 @@ void gdsp_ddma_in(uint16 dsp_addr, uint32 addr, uint32 size) *(uint16*)&dst[dsp_addr + i] = *(uint16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF]; } - DebugLog("*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size); + DEBUG_LOG(DSPHLE, "*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size); } @@ -296,7 +296,7 @@ void gdsp_ddma_out(uint16 dsp_addr, uint32 addr, uint32 size) { if ((addr & 0x7FFFFFFF) > 0x01FFFFFF) { - ErrorLog("*** gdsp_ddma_out to invalid addr (0x%08x)\n", addr); + ERROR_LOG(DSPHLE, "*** gdsp_ddma_out to invalid addr (0x%08x)\n", addr); return; } @@ -307,7 +307,7 @@ void gdsp_ddma_out(uint16 dsp_addr, uint32 addr, uint32 size) *(uint16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF] = *(uint16*)&src[dsp_addr + i]; } - DebugLog("*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); + DEBUG_LOG(DSPHLE, "*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); } @@ -330,7 +330,7 @@ void gdsp_dma() if ((ctl > 3) || (len > 0x4000)) { - ErrorLog("DMA ERROR pc: %04x ctl: %04x addr: %08x da: %04x size: %04x\n", g_dsp.pc, ctl, addr, dsp_addr, len); + ERROR_LOG(DSPHLE, "DMA ERROR pc: %04x ctl: %04x addr: %08x da: %04x size: %04x\n", g_dsp.pc, ctl, addr, dsp_addr, len); exit(0); } diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_memory.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_memory.cpp index 380c2c8396..c2a051431f 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_memory.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_memory.cpp @@ -88,7 +88,7 @@ uint16 dsp_dmem_read(uint16 addr) break; case 0x8: // 8xxx DROM - DebugLog("someone reads from ROM\n"); + DEBUG_LOG(DSPHLE, "someone reads from ROM\n"); val = g_dsp.drom[addr & DSP_DROM_MASK]; val = dsp_swap16(val); break; @@ -103,7 +103,7 @@ uint16 dsp_dmem_read(uint16 addr) break; default: // error -// ErrorLog("%04x DSP ERROR: Read from UNKNOWN (%04x) memory\n", g_dsp.pc, addr); +// ERROR_LOG(DSPHLE, "%04x DSP ERROR: Read from UNKNOWN (%04x) memory\n", g_dsp.pc, addr); val = 0; break; } @@ -117,7 +117,7 @@ bool dsp_dmem_write(uint16 addr, uint16 val) switch (addr >> 12) { case 0x8: // 8xxx DROM - DebugLog("someone writes to ROM\n"); + DEBUG_LOG(DSPHLE, "someone writes to ROM\n"); /* val = dsp_swap16(val); g_dsp.drom[addr & DSP_DROM_MASK] = val;*/ break; @@ -132,7 +132,7 @@ bool dsp_dmem_write(uint16 addr, uint16 val) break; default: // error - DebugLog("%04x DSP ERROR: Write to UNKNOWN (%04x) memory\n", g_dsp.pc, addr); + DEBUG_LOG(DSPHLE, "%04x DSP ERROR: Write to UNKNOWN (%04x) memory\n", g_dsp.pc, addr); break; } diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_opcodes.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_opcodes.cpp index 179e9849c8..a3e22ec058 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_opcodes.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_opcodes.cpp @@ -187,7 +187,7 @@ bool CheckCondition(uint8 _Condition) break; default: - // DebugLog("Unknown condition check: 0x%04x\n", _Condition & 0xf); + // DEBUG_LOG(DSPHLE, "Unknown condition check: 0x%04x\n", _Condition & 0xf); break; } @@ -200,7 +200,7 @@ bool CheckCondition(uint8 _Condition) void dsp_op_unknown(uint16 opc) { _assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception"); - ErrorLog("dsp_op_unknown somewhere"); + ERROR_LOG(DSPHLE, "dsp_op_unknown somewhere"); g_dsp.pc = g_dsp.err_pc; } @@ -244,7 +244,7 @@ void dsp_opc_jmpa(uint16 opc) if ((opc & 0xf) != 0xf) { - ErrorLog("dsp_opc_jmpa"); + ERROR_LOG(DSPHLE, "dsp_opc_jmpa"); } reg = (opc >> 5) & 0x7; @@ -274,7 +274,7 @@ void dsp_opc_rti(uint16 opc) { if ((opc & 0xf) != 0xf) { - ErrorLog("dsp_opc_rti"); + ERROR_LOG(DSPHLE, "dsp_opc_rti"); } g_dsp.r[R_SR] = dsp_reg_load_stack(DSP_STACK_D); @@ -452,7 +452,7 @@ void dsp_opc_ilrr(uint16 opc) break; default: - ErrorLog("dsp_opc_ilrr"); + ERROR_LOG(DSPHLE, "dsp_opc_ilrr"); } } @@ -544,14 +544,14 @@ void dsp_opc_mulc(uint16 opc) // NEW void dsp_opc_mulcmvz(uint16 opc) { - ErrorLog("dsp_opc_mulcmvz ni"); + ERROR_LOG(DSPHLE, "dsp_opc_mulcmvz ni"); } // NEW void dsp_opc_mulcmv(uint16 opc) { - ErrorLog("dsp_opc_mulcmv ni"); + ERROR_LOG(DSPHLE, "dsp_opc_mulcmv ni"); } @@ -735,7 +735,7 @@ void dsp_opc_andfc(uint16 opc) { if (opc & 0xf) { - ErrorLog("dsp_opc_andfc"); + ERROR_LOG(DSPHLE, "dsp_opc_andfc"); } uint8 reg = (opc >> 8) & 0x1; @@ -761,7 +761,7 @@ void dsp_opc_andf(uint16 opc) if (opc & 0xf) { - ErrorLog("dsp_opc_andf"); + ERROR_LOG(DSPHLE, "dsp_opc_andf"); } reg = 0x1e + ((opc >> 8) & 0x1); @@ -783,7 +783,7 @@ void dsp_opc_subf(uint16 opc) { if (opc & 0xf) { - ErrorLog("dsp_opc_subf"); + ERROR_LOG(DSPHLE, "dsp_opc_subf"); } uint8 reg = 0x1e + ((opc >> 8) & 0x1); @@ -800,7 +800,7 @@ void dsp_opc_xori(uint16 opc) { if (opc & 0xf) { - ErrorLog("dsp_opc_xori"); + ERROR_LOG(DSPHLE, "dsp_opc_xori"); } uint8 reg = 0x1e + ((opc >> 8) & 0x1); @@ -815,7 +815,7 @@ void dsp_opc_andi(uint16 opc) { if (opc & 0xf) { - ErrorLog("dsp_opc_andi"); + ERROR_LOG(DSPHLE, "dsp_opc_andi"); } uint8 reg = 0x1e + ((opc >> 8) & 0x1); @@ -832,7 +832,8 @@ void dsp_opc_ori(uint16 opc) { if (opc & 0xf) { - return(ErrorLog("dsp_opc_ori")); + ERROR_LOG(DSPHLE, "dsp_opc_ori"); + return; } uint8 reg = 0x1e + ((opc >> 8) & 0x1); @@ -980,7 +981,7 @@ void dsp_opc_neg(uint16 opc) void dsp_opc_movnp(uint16 opc) { - ErrorLog("dsp_opc_movnp\n"); + ERROR_LOG(DSPHLE, "dsp_opc_movnp\n"); } @@ -1525,7 +1526,7 @@ void dsp_op0(uint16 opc) break; default: - ErrorLog("dsp_op0"); + ERROR_LOG(DSPHLE, "dsp_op0"); break; } @@ -1565,7 +1566,7 @@ void dsp_op0(uint16 opc) break; default: - ErrorLog("dsp_op0"); + ERROR_LOG(DSPHLE, "dsp_op0"); break; } @@ -1628,7 +1629,7 @@ void dsp_op0(uint16 opc) break; default: - ErrorLog("dsp_op0"); + ERROR_LOG(DSPHLE, "dsp_op0"); break; } @@ -1671,7 +1672,7 @@ void dsp_op0(uint16 opc) break; default: - ErrorLog("dsp_op0"); + ERROR_LOG(DSPHLE, "dsp_op0"); break; } @@ -1699,7 +1700,7 @@ void dsp_op0(uint16 opc) break; default: - ErrorLog("dsp_op0"); + ERROR_LOG(DSPHLE, "dsp_op0"); break; } } @@ -1756,7 +1757,7 @@ void dsp_op1(uint16 opc) break; default: - ErrorLog("dsp_op1"); + ERROR_LOG(DSPHLE, "dsp_op1"); break; } } @@ -1814,7 +1815,7 @@ void dsp_op3(uint16 opc) break; default: - ErrorLog("dsp_op3"); + ERROR_LOG(DSPHLE, "dsp_op3"); break; } @@ -1857,7 +1858,7 @@ void dsp_op4(uint16 opc) break; default: - ErrorLog("dsp_op4"); + ERROR_LOG(DSPHLE, "dsp_op4"); break; } @@ -1895,7 +1896,7 @@ void dsp_op5(uint16 opc) break; default: - ErrorLog("dsp_op5: %x", (opc >> 8) & 0xf); + ERROR_LOG(DSPHLE, "dsp_op5: %x", (opc >> 8) & 0xf); break; } @@ -1933,7 +1934,7 @@ void dsp_op6(uint16 opc) break; default: - ErrorLog("dsp_op6"); + ERROR_LOG(DSPHLE, "dsp_op6"); break; } @@ -1985,7 +1986,7 @@ void dsp_op7(uint16 opc) break; default: - ErrorLog("dsp_op7"); + ERROR_LOG(DSPHLE, "dsp_op7"); break; } @@ -2032,7 +2033,7 @@ void dsp_op8(uint16 opc) break; default: - ErrorLog("dsp_op8"); + ERROR_LOG(DSPHLE, "dsp_op8"); break; } @@ -2078,7 +2079,7 @@ void dsp_op9(uint16 opc) break; default: - ErrorLog("dsp_op9"); + ERROR_LOG(DSPHLE, "dsp_op9"); break; } @@ -2116,7 +2117,7 @@ void dsp_opab(uint16 opc) break; default: - ErrorLog("dsp_opab"); + ERROR_LOG(DSPHLE, "dsp_opab"); } dsp_op_ext_ops_epi(opc); @@ -2153,7 +2154,7 @@ void dsp_opcd(uint16 opc) break; default: - ErrorLog("dsp_opcd"); + ERROR_LOG(DSPHLE, "dsp_opcd"); } dsp_op_ext_ops_epi(opc); @@ -2183,7 +2184,7 @@ void dsp_ope(uint16 opc) break; default: - ErrorLog("dsp_ope"); + ERROR_LOG(DSPHLE, "dsp_ope"); } dsp_op_ext_ops_epi(opc); @@ -2224,7 +2225,7 @@ void dsp_opf(uint16 opc) break; default: - ErrorLog("dsp_opf"); + ERROR_LOG(DSPHLE, "dsp_opf"); break; } diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index a6190c921d..2692b3ba4b 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -23,7 +23,6 @@ #include "WaveFile.h" #include "CommonTypes.h" #include "Mixer.h" -#include "ConsoleWindow.h" // For Console::Open, Console::Print #include "Globals.h" // Local #include "gdsp_interpreter.h" @@ -57,6 +56,7 @@ // ======================================================================================= // Global declarations and definitions // -------------- +PLUGIN_GLOBALS* globals = NULL; DSPInitialize g_dspInitialize; #define GDSP_MBOX_CPU 0 @@ -114,7 +114,10 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo) #endif } -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { +void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +{ + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); } void DllAbout(HWND _hParent) @@ -135,13 +138,13 @@ void DllDebugger(HWND _hParent, bool Show) #if defined (_DEBUG) || defined (DEBUGFAST) g_Dialog.Create(NULL); //_hParent); g_Dialog.ShowWindow(SW_SHOW); - MoveWindow(g_Dialog.m_hWnd, 450,0, 780,530, true); + // MoveWindow(g_Dialog.m_hWnd, 450,0, 780,530, true); // Open the console window - Console::Open(155, 100, "Sound Debugging"); // give room for 100 rows - Console::Print("DllDebugger > Console opened\n"); + // Console::Open(155, 100, "Sound Debugging"); // give room for 100 rows + // Console::Print("DllDebugger > Console opened\n"); // Todo: Make this adjustable from the Debugging window - MoveWindow(Console::GetHwnd(), 0,400, 1280,500, true); + // MoveWindow(Console::GetHwnd(), 0,400, 1280,500, true); #else MessageBox(0, "Can't open debugging window in the Release build of this plugin.", "DSP LLE", 0); #endif @@ -235,14 +238,14 @@ void Initialize(void *init) { bCanWork = false; PanicAlert("No DSP ROM"); - ErrorLog("Cannot load DSP ROM\n"); + ERROR_LOG(DSPHLE, "Cannot load DSP ROM\n"); } if (!gdsp_load_coef((char *)DSP_COEF_FILE)) { bCanWork = false; PanicAlert("No DSP COEF"); - ErrorLog("Cannot load DSP COEF\n"); + ERROR_LOG(DSPHLE, "Cannot load DSP COEF\n"); } if(!bCanWork) @@ -350,7 +353,7 @@ void DSP_WriteMailboxHigh(bool _CPUMailbox, u16 _uHighMail) { if (gdsp_mbox_peek(GDSP_MBOX_CPU) & 0x80000000) { - ErrorLog("Mailbox isnt empty ... strange"); + ERROR_LOG(DSPHLE, "Mailbox isnt empty ... strange"); } #if PROFILE @@ -364,7 +367,7 @@ void DSP_WriteMailboxHigh(bool _CPUMailbox, u16 _uHighMail) } else { - ErrorLog("CPU cant write to DSP mailbox"); + ERROR_LOG(DSPHLE, "CPU cant write to DSP mailbox"); } } @@ -377,7 +380,7 @@ void DSP_WriteMailboxLow(bool _CPUMailbox, u16 _uLowMail) u32 uAddress = gdsp_mbox_peek(GDSP_MBOX_CPU); u16 errpc = g_dsp.err_pc; - DebugLog("Write CPU Mail: 0x%08x (pc=0x%04x)\n", uAddress, errpc); + DEBUG_LOG(DSPHLE, "Write CPU Mail: 0x%08x (pc=0x%04x)\n", uAddress, errpc); // --------------------------------------------------------------------------------------- // I couldn't find any better way to detect the AX mails so this had to do. Please feel free @@ -385,13 +388,13 @@ void DSP_WriteMailboxLow(bool _CPUMailbox, u16 _uLowMail) // -------------- if ((errpc == 0x0054 || errpc == 0x0055) && m_addressPBs == 0) { - DebugLog("AXTask ======== 0x%08x (pc=0x%04x)", uAddress, errpc); + DEBUG_LOG(DSPHLE, "AXTask ======== 0x%08x (pc=0x%04x)", uAddress, errpc); AXTask(uAddress); } } else { - ErrorLog("CPU cant write to DSP mailbox"); + ERROR_LOG(DSPHLE, "CPU cant write to DSP mailbox"); } } @@ -433,7 +436,3 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate) -void __Log(int, const char *fmt, ...) -{ - //DebugLog(fmt); -} diff --git a/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj b/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj index 30c56237eb..732db63072 100644 --- a/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj +++ b/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj @@ -1,7 +1,7 @@ SetValue(pad[0].bRecording); m_CheckPlayback[0]->SetValue(pad[0].bPlayback); - Console::Print("m_CheckRecording: %i\n", pad[0].bRecording, pad[0].bPlayback); + //DEBUG_LOG(CONSOLE, "m_CheckRecording: %i\n", pad[0].bRecording, pad[0].bPlayback); #endif ////////////////////////////////////// diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp index 14b835269e..d0666cedfa 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp @@ -26,7 +26,6 @@ #include "pluginspecs_pad.h" #include "PadSimple.h" #include "IniFile.h" -#include "ConsoleWindow.h" #include "StringUtil.h" #include "FileUtil.h" #include "ChunkFile.h" @@ -80,17 +79,12 @@ SPADInitialize g_PADInitialize; // Pre defined maxium storage limit #define RECORD_SIZE (1024 * 128) +PLUGIN_GLOBALS* globals = NULL; SPADStatus recordBuffer[RECORD_SIZE]; int count = 0; bool g_EmulatorRunning = false; //////////////////////////////// - -// TODO: fix this dirty hack to stop missing symbols -void __Log(int log, const char *format, ...) {} -void __Logv(int log, int v, const char *format, ...) {} - - //****************************************************************************** // Supporting functions //****************************************************************************** @@ -612,7 +606,11 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo) } -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {} +void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +{ + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); +} void DllConfig(HWND _hParent) { diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h index 0e503f0d17..6f2441d9c4 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h +++ b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h @@ -19,7 +19,6 @@ #define __PADSIMPLE_H__ #include "Setup.h" // Common -#include "ConsoleWindow.h" // Controls enum diff --git a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp index f7f69d2a8b..8043ca8d8b 100644 --- a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp +++ b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp @@ -67,11 +67,6 @@ SPADInitialize g_PADInitialize; SPADStatus recordBuffer[RECORD_SIZE]; int count = 0; -// TODO: fix this dirty hack to stop missing symbols -void __Log(int log, const char *format, ...) {} -void __Logv(int log, int v, const char *format, ...) {} - - void RecordInput(const SPADStatus& _rPADStatus) { if (count >= RECORD_SIZE) @@ -215,7 +210,9 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo) } void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { - globals = _pPluginGlobals; + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); + } void DllConfig(HWND _hParent) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index cff545cc4c..6ba0c3e60d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -48,6 +48,7 @@ HINSTANCE g_hInstance = NULL; SVideoInitialize g_VideoInitialize; +PLUGIN_GLOBALS* globals = NULL; int initCount = 0; @@ -163,6 +164,8 @@ void GetDllInfo (PLUGIN_INFO* _PluginInfo) } void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); } void DllAbout(HWND _hParent) @@ -268,32 +271,6 @@ void Video_AddMessage(const char* pstr, u32 milliseconds) Renderer::AddMessage(pstr,milliseconds); } -void DebugLog(const char* _fmt, ...) -{ -#ifdef _DEBUG - char Msg[512]; - va_list ap; - - va_start(ap, _fmt); - vsprintf(Msg, _fmt, ap); - va_end(ap); - - g_VideoInitialize.pLog(Msg, FALSE); -#endif -} - -void __Log(int log, const char *format, ...) -{ -// char temp[512]; - //va_list args; - //va_start(args, format); - //CharArrayFromFormatV(temp, 512, format, args); - //va_end(args); - - DebugLog(format); //"%s", temp); -} - - HRESULT ScreenShot(const char *File) { if (D3D::dev == NULL) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp index 9b9f29410d..6947080798 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp @@ -17,7 +17,6 @@ #include "../Globals.h" // The precompiled header #include "IniFile.h" // Common -#include "ConsoleWindow.h" // Move console window #include "../Config.h" // Config settings #include "Debugger.h" @@ -57,20 +56,21 @@ void CDebugger::OnClose(wxCloseEvent& event) SaveSettings(); event.Skip(); // This means wxDialog's Destroy is used - CloseConsole(); // The console goes with the wx window + // CloseConsole(); // The console goes with the wx window } void CDebugger::DoShowHideConsole() { - if(m_Check[1]->IsChecked() + /* if(m_Check[1]->IsChecked() #ifdef _WIN32 // Check to see if we already have a console - && Console::GetHwnd() == NULL +// && Console::GetHwnd() == NULL #endif ) OpenConsole(); else CloseConsole(); + */ } void CDebugger::SaveSettings() const @@ -113,9 +113,6 @@ void CDebugger::LoadSettings() file.Get("VideoWindow", "h", &h, GetSize().GetHeight()); SetSize(x, y, w, h); - file.Get("VideoWindow", "WriteToFile", &LocalLogFile, m_Check[0]->IsChecked()); - m_Check[0]->SetValue(LocalLogFile); - bool Console; file.Get("VideoWindow", "Console", &Console, m_Check[1]->IsChecked()); m_Check[1]->SetValue(Console); @@ -168,9 +165,6 @@ void CDebugger::GeneralSettings(wxCommandEvent& event) { switch (event.GetId()) { - case ID_SAVETOFILE: - LocalLogFile = event.IsChecked(); - break; case ID_SHOWCONSOLE: DoShowHideConsole(); break; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 05a6d6bd51..77780bb717 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -76,13 +76,13 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl // --------------- ConfigDialog::~ConfigDialog() { - Console::Print("ConfigDialog Closed\n"); + INFO_LOG(CONSOLE, "ConfigDialog Closed\n"); } void ConfigDialog::OnClose(wxCloseEvent& event) { g_Config.Save(); - Console::Print("OnClose\n"); + INFO_LOG(CONSOLE, "OnClose\n"); // notice that we don't run wxEntryCleanup(); here so the dll will still be loaded /* JP: Yes, it seems like Close() does not do that. It only runs EndModal() or something @@ -98,7 +98,7 @@ void ConfigDialog::OnClose(wxCloseEvent& event) void ConfigDialog::CloseClick(wxCommandEvent& WXUNUSED (event)) { - Console::Print("CloseClick\n"); + INFO_LOG(CONSOLE, "CloseClick\n"); // If we run wxEntryCleanup() the class will be entirely deleted, and the destructor will be run //g_Config.Save(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index f97c14b135..9b64d1f359 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -30,16 +30,17 @@ #include "main.h" #include "IniFile.h" -#include "ConsoleWindow.h" #include + +/* FIXME should be done from logmanager // Open and close the Windows console window void OpenConsole() { - Console::Open(100, 300, "OpenGL Plugin Output"); // give room for 300 rows - Console::Print("OpenGL console opened\n"); - #ifdef _WIN32 +// Console::Open(100, 300, "OpenGL Plugin Output"); // give room for 300 rows + INFO_LOG(CONSOLE, "OpenGL console opened\n"); + // #ifdef _WIN32 MoveWindow(Console::GetHwnd(), 0,400, 1280,550, true); // Move window. Todo: make this // adjustable from the debugging window #endif @@ -47,59 +48,7 @@ void OpenConsole() void CloseConsole() { - Console::Close(); + // Console::Close(); } +*/ - -////////////////////////////////////////////////////////////////////////////////////////// -// Write logs - -// The log file handle -static FILE* pfLog = NULL; - -// This is on by default, but can be controlled from the debugging window -bool LocalLogFile = true; - -#if LOGLEVEL > 0 -void __Log(const char *fmt, ...) -{ - size_t len = strlen(fmt); - if (!len) - return; - char* Msg = (char*)alloca(len + 512); - va_list ap; - - va_start(ap, fmt); - vsnprintf(Msg, len + 512, fmt, ap); - va_end(ap); - - g_VideoInitialize.pLog(Msg, FALSE); - - // If we have no file to write to, create one - if (pfLog == NULL && LocalLogFile) - pfLog = fopen(FULL_LOGS_DIR "oglgfx.txt", "w"); - - // Write to file - if (pfLog != NULL && LocalLogFile) - fwrite(Msg, strlen(Msg), 1, pfLog); - - Console::Print(Msg); -} - -void __Log(int type, const char *fmt, ...) -{ - int len = (int)strlen(fmt); - if (!len) - return; - char* Msg = (char*)alloca(len + 512); - va_list ap; - - va_start(ap, fmt); - vsnprintf(Msg, len + 512, fmt, ap); - va_end(ap); - - g_VideoInitialize.pLog(Msg, FALSE); - Console::Print(Msg); -} - -#endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index 29dc43c47d..d229998bc5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -24,19 +24,10 @@ #include "VideoCommon.h" #include "pluginspecs_video.h" -#include "ConsoleWindow.h" - - -// Compile without WxWidgets in Windows to, for debugging purposes -//#define HAVE_WX 0 - -// Turns file logging on and off -extern bool LocalLogFile; - // A global plugin specification extern PLUGIN_GLOBALS* globals; -void OpenConsole(); -void CloseConsole(); +//void OpenConsole(); +//void CloseConsole(); #endif // _GLOBALS_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index 2662937517..4ddb2eeadd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -41,8 +41,8 @@ ////////////////////////////////////////////////////////////////////////////////////////// // Declarations and definitions // ŻŻŻŻŻŻŻŻŻŻ -void OpenConsole(); -void CloseConsole(); +//void OpenConsole(); +//void CloseConsole(); HINSTANCE g_hInstance; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 5ca0ae30cf..45fc7035fe 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -972,7 +972,7 @@ void ComputeBackbufferRectangle(TRectangle *rc) // Adjust the X and Y offset FloatXOffset = FloatXOffset - (IncreasedWidth / 2.0 / WidthRatio / Ratio); FloatYOffset = FloatYOffset - (IncreasedHeight / 2.0 / HeightRatio / Ratio); - //Console::Print("Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f\n", Ratio, IncreasedHeight, FloatYOffset); + //DEBUG_LOG(CONSOLE, "Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f\n", Ratio, IncreasedHeight, FloatYOffset); } // round(float) = floor(float + 0.5) @@ -1410,15 +1410,15 @@ void UpdateViewport() GetWindowRect(Child, &RcChild); //Console::ClearScreen(); - Console::Print("----------------------------------------------------------------\n"); - Console::Print("Top window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top); - Console::Print("Parent window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top); - Console::Print("Child window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcChild.left, RcChild.top, RcChild.right - RcChild.left, RcChild.bottom - RcChild.top); - Console::Print("----------------------------------------------------------------\n"); - Console::Print("Res. MValue: X:%f Y:%f XOffs:%f YOffs:%f\n", OpenGL_GetXmax(), OpenGL_GetYmax(), OpenGL_GetXoff(), OpenGL_GetYoff()); - Console::Print("GLViewPort: X:%03i Y:%03i Width:%03i Height:%03i\n", GLx, GLy, GLWidth, GLHeight); - Console::Print("GLDepthRange: Near:%f Far:%f\n", GLNear, GLFar); - Console::Print("GLScissor: X:%03i Y:%03i Width:%03i Height:%03i\n", GLScissorX, GLScissorY, GLScissorW, GLScissorH); - Console::Print("----------------------------------------------------------------\n"); + DEBUG_LOG(CONSOLE, "----------------------------------------------------------------\n"); + DEBUG_LOG(CONSOLE, "Top window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top); + DEBUG_LOG(CONSOLE, "Parent window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top); + DEBUG_LOG(CONSOLE, "Child window: X:%03i Y:%03i Width:%03i Height:%03i\n", RcChild.left, RcChild.top, RcChild.right - RcChild.left, RcChild.bottom - RcChild.top); + DEBUG_LOG(CONSOLE, "----------------------------------------------------------------\n"); + DEBUG_LOG(CONSOLE, "Res. MValue: X:%f Y:%f XOffs:%f YOffs:%f\n", OpenGL_GetXmax(), OpenGL_GetYmax(), OpenGL_GetXoff(), OpenGL_GetYoff()); + DEBUG_LOG(CONSOLE, "GLViewPort: X:%03i Y:%03i Width:%03i Height:%03i\n", GLx, GLy, GLWidth, GLHeight); + DEBUG_LOG(CONSOLE, "GLDepthRange: Near:%f Far:%f\n", GLNear, GLFar); + DEBUG_LOG(CONSOLE, "GLScissor: X:%03i Y:%03i Width:%03i Height:%03i\n", GLScissorX, GLScissorY, GLScissorW, GLScissorH); + DEBUG_LOG(CONSOLE, "----------------------------------------------------------------\n"); */ } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index c6efe420d7..d9cc9ea40d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -59,7 +59,7 @@ // Definitions // -------------------------- SVideoInitialize g_VideoInitialize; -PLUGIN_GLOBALS* globals; +PLUGIN_GLOBALS* globals = NULL; // Logging int GLScissorX, GLScissorY, GLScissorW, GLScissorH; @@ -95,6 +95,8 @@ void GetDllInfo (PLUGIN_INFO* _PluginInfo) void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); } // This is used for the fuctions right below here, in DllConfig() @@ -318,22 +320,6 @@ void Video_ExitLoop() } ///////////////////////// - -void DebugLog(const char* _fmt, ...) -{ -#if defined(_DEBUG) || defined(DEBUGFAST) - - char* Msg = (char*)alloca(strlen(_fmt)+512); - va_list ap; - - va_start( ap, _fmt ); - vsnprintf( Msg, strlen(_fmt)+512, _fmt, ap ); - va_end( ap ); - - g_VideoInitialize.pLog(Msg, FALSE); -#endif -} - void Video_Screenshot(const char *_szFilename) { Renderer::SetScreenshot(_szFilename); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/nmain.cpp b/Source/Plugins/Plugin_VideoOGL/Src/nmain.cpp index b694952aa9..7d358fe827 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/nmain.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/nmain.cpp @@ -244,21 +244,6 @@ void Video_EnterLoop() Fifo_EnterLoop(g_VideoInitialize); } -void DebugLog(const char* _fmt, ...) -{ -#if defined(_DEBUG) || defined(DEBUGFAST) - - char* Msg = (char*)alloca(strlen(_fmt)+512); - va_list ap; - - va_start( ap, _fmt ); - vsnprintf( Msg, strlen(_fmt)+512, _fmt, ap ); - va_end( ap ); - - g_VideoInitialize.pLog(Msg, FALSE); -#endif -} - bool ScreenShot(TCHAR *File) { char str[64]; diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index 14aabb9ba3..be5d2cbe69 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -214,7 +214,7 @@ void Config::Load(bool ChangePad) // ============================= // Logging - Console::Print("Load()\n"); + INFO_LOG(CONSOLE, "Load()\n"); } void Config::Save(int Slot) @@ -352,5 +352,5 @@ void Config::Save(int Slot) // ============================= // Logging - Console::Print("Save()\n"); + INFO_LOG(CONSOLE, "Save()\n"); } diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index afd8635acb..8a4bf6e294 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -265,7 +265,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event) // Input button clicked void ConfigDialog::OnButtonClick(wxCommandEvent& event) { - //Console::Print("OnButtonClick: %i\n", g_Pressed); + //INFO_LOG(CONSOLE, "OnButtonClick: %i\n", g_Pressed); // Don't allow space to start a new Press Key option, that will interfer with setting a key to space if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; } @@ -391,7 +391,7 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot) // Then change it back to "" ToBlank(); - Console::Print("WiiMoteEmu::PadMapping[%i].ID = %i\n", Page, m_Joyname[Page]->GetSelection()); + INFO_LOG(CONSOLE, "WiiMoteEmu::PadMapping[%i].ID = %i\n", Page, m_Joyname[Page]->GetSelection()); } ////////////////////////////////////// @@ -1439,7 +1439,7 @@ void ConfigDialog::DoConnectReal() } else { - Console::Print("Post Message: %i\n", g_RealWiiMoteInitialized); + INFO_LOG(CONSOLE, "Post Message: %i\n", g_RealWiiMoteInitialized); if (g_RealWiiMoteInitialized) { WiiMoteReal::Shutdown(); @@ -1471,11 +1471,11 @@ void ConfigDialog::DoUseReal() if (g_Config.bNunchuckConnected || g_Config.bClassicControllerConnected) UsingExtension = true; - Console::Print("\nDoUseReal() Connect extension: %i\n", !UsingExtension); + INFO_LOG(CONSOLE, "\nDoUseReal() Connect extension: %i\n", !UsingExtension); DoExtensionConnectedDisconnected(UsingExtension ? 0 : 1); UsingExtension = !UsingExtension; - Console::Print("\nDoUseReal() Connect extension: %i\n", !UsingExtension); + INFO_LOG(CONSOLE, "\nDoUseReal() Connect extension: %i\n", !UsingExtension); DoExtensionConnectedDisconnected(UsingExtension ? 1 : 0); if(g_EmulatorRunning) @@ -1650,7 +1650,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) if (m_RecordHotKeyNunchuck[i]->GetSelection() == m_RecordHotKeyNunchuck[CurrentChoiceBox]->GetSelection()) m_RecordHotKeyNunchuck[i]->SetSelection(10); if (m_RecordHotKeyIR[i]->GetSelection() == m_RecordHotKeyIR[CurrentChoiceBox]->GetSelection()) m_RecordHotKeyIR[i]->SetSelection(10); - //Console::Print("HotKey: %i %i\n", + //INFO_LOG(CONSOLE, "HotKey: %i %i\n", // m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection()); } break; @@ -1710,7 +1710,7 @@ void ConfigDialog::UpdateControls() // ------------- void ConfigDialog::UpdateGUI(int Slot) { - //Console::Print("UpdateGUI: \n"); + //INFO_LOG(CONSOLE, "UpdateGUI: \n"); // Update the gamepad settings UpdateGUIButtonMapping(Page); diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index f050e60b93..5176dff8ef 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -61,12 +61,12 @@ void ConfigDialog::PadOpen(int Open) // Open for slot 1, 2, 3 or 4 // Check that we got a good pad if (!WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Open].ID).Good) { - Console::Print("A bad pad was selected\n"); + INFO_LOG(CONSOLE, "A bad pad was selected\n"); WiiMoteEmu::PadState[Open].joy = NULL; return; } - Console::Print("Update the Slot %i handle to Id %i\n", Page, WiiMoteEmu::PadMapping[Open].ID); + INFO_LOG(CONSOLE, "Update the Slot %i handle to Id %i\n", Page, WiiMoteEmu::PadMapping[Open].ID); WiiMoteEmu::PadState[Open].joy = SDL_JoystickOpen(WiiMoteEmu::PadMapping[Open].ID); } void ConfigDialog::PadClose(int Close) // Close for slot 1, 2, 3 or 4 @@ -118,7 +118,7 @@ void ConfigDialog::SetButtonTextAll(int id, char text[128]) void ConfigDialog::SaveButtonMappingAll(int Slot) { - //Console::Print("SaveButtonMappingAll()\n"); + //INFO_LOG(CONSOLE, "SaveButtonMappingAll()\n"); for (int i = 0; i < 4; i++) { @@ -211,7 +211,7 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller) m_bCcRd[controller]->SetLabel(wxString::FromAscii(InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Cc.Rd).c_str())); #endif - //Console::Print("m_bWmA[%i] = %i = %s\n", controller, WiiMoteEmu::PadMapping[controller].Wm.A, InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str()); + //INFO_LOG(CONSOLE, "m_bWmA[%i] = %i = %s\n", controller, WiiMoteEmu::PadMapping[controller].Wm.A, InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.A).c_str()); } /* Populate the PadMapping array with the dialog items settings (for example @@ -257,7 +257,7 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From m_AnalogTriggerL[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tl = value; m_AnalogTriggerR[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tr = value; - //Console::Print("WiiMoteEmu::PadMapping[%i].ID = %i, m_Joyname[%i]->GetSelection() = %i\n", + //INFO_LOG(CONSOLE, "WiiMoteEmu::PadMapping[%i].ID = %i, m_Joyname[%i]->GetSelection() = %i\n", // controller, WiiMoteEmu::PadMapping[controller].ID, FromSlot, m_Joyname[FromSlot]->GetSelection()); // Replace "-1" with "" @@ -320,7 +320,7 @@ void ConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key) case IDB_CC_RD: WiiMoteEmu::PadMapping[Controller].Cc.Rd = Key; break; } - //Console::Print("WiiMoteEmu::PadMapping[%i].Wm.A = %i", Controller, WiiMoteEmu::PadMapping[Controller].Wm.A); + //INFO_LOG(CONSOLE, "WiiMoteEmu::PadMapping[%i].Wm.A = %i", Controller, WiiMoteEmu::PadMapping[Controller].Wm.A); } // Replace the harder to understand -1 with "" for the sake of user friendliness @@ -421,14 +421,14 @@ void ConfigDialog::SetButtonText(int id, char text[128], int _Page) case IDB_CC_RD: m_bCcRd[controller]->SetLabel(wxString::FromAscii(text)); break; default: break; } - //Console::Print("SetButtonText: %s\n", text); + //INFO_LOG(CONSOLE, "SetButtonText: %s\n", text); } // Get the text in the textbox for the buttons // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ wxString ConfigDialog::GetButtonText(int id, int _Page) { - //Console::Print("GetButtonText: %i\n", id); + //INFO_LOG(CONSOLE, "GetButtonText: %i\n", id); // Set controller value int controller; @@ -510,7 +510,7 @@ void ConfigDialog::DoGetButtons(int GetId) bool Stop = false; // Stop the timer // ======================= - //Console::Print("Before (%i) Id:%i %i IsRunning:%i\n", + //INFO_LOG(CONSOLE, "Before (%i) Id:%i %i IsRunning:%i\n", // GetButtonWaitingTimer, GetButtonWaitingID, GetId, m_ButtonMappingTimer->IsRunning()); // If the Id has changed or the timer is not running we should start one @@ -539,7 +539,7 @@ void ConfigDialog::DoGetButtons(int GetId) #if wxUSE_TIMER m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) ); #endif - Console::Print("Timer Started for Pad:%i GetId:%i\n" + INFO_LOG(CONSOLE, "Timer Started for Pad:%i GetId:%i\n" "Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i\n", WiiMoteEmu::PadMapping[Controller].ID, GetId, Axis, LeftRight, XInput, Button, Hat); @@ -578,7 +578,7 @@ void ConfigDialog::DoGetButtons(int GetId) SetButtonText(GetId, format); /* Debug - Console::Print("Keyboard: %i\n", g_Pressed);*/ + INFO_LOG(CONSOLE, "Keyboard: %i\n", g_Pressed);*/ } // Time's up @@ -610,7 +610,7 @@ void ConfigDialog::DoGetButtons(int GetId) several disabled slots. */ SaveButtonMappingAll(Controller); - Console::Print("Timer Stopped for Pad:%i GetId:%i\n", + INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i GetId:%i\n", WiiMoteEmu::PadMapping[Controller].ID, GetId); } @@ -630,7 +630,7 @@ void ConfigDialog::DoGetButtons(int GetId) // Debugging /* - Console::Print("Change: %i %i %i %i '%s' '%s' '%s' '%s'\n", + INFO_LOG(CONSOLE, "Change: %i %i %i %i '%s' '%s' '%s' '%s'\n", WiiMoteEmu::PadMapping[0].halfpress, WiiMoteEmu::PadMapping[1].halfpress, WiiMoteEmu::PadMapping[2].halfpress, WiiMoteEmu::PadMapping[3].halfpress, m_JoyButtonHalfpress[0]->GetValue().c_str(), m_JoyButtonHalfpress[1]->GetValue().c_str(), m_JoyButtonHalfpress[2]->GetValue().c_str(), m_JoyButtonHalfpress[3]->GetValue().c_str() );*/ @@ -657,7 +657,7 @@ void ConfigDialog::Convert2Box(int &x) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void ConfigDialog::PadGetStatus() { - //Console::Print("SDL_WasInit: %i\n", SDL_WasInit(0)); + //INFO_LOG(CONSOLE, "SDL_WasInit: %i\n", SDL_WasInit(0)); /* Return if it's not detected. The ID should never be less than zero here, it can only be that because of a manual ini file change, but we make that check anway. */ diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp index 75a168265a..4dcd490c2c 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp @@ -37,7 +37,7 @@ void ConfigDialog::LoadFile() { - Console::Print("LoadFile()\n"); + INFO_LOG(CONSOLE, "LoadFile()\n"); IniFile file; file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini"); @@ -79,7 +79,7 @@ void ConfigDialog::LoadFile() } void ConfigDialog::SaveFile() { - Console::Print("SaveFile\n"); + INFO_LOG(CONSOLE, "SaveFile\n"); IniFile file; file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini"); @@ -115,7 +115,7 @@ void ConfigDialog::SaveFile() } file.Save(FULL_CONFIG_DIR "WiimoteMovement.ini"); - Console::Print("SaveFile()\n"); + INFO_LOG(CONSOLE, "SaveFile()\n"); } ///////////////////////////// @@ -371,7 +371,7 @@ void ConfigDialog::ConvertToString() TmpStr += StringFromFormat("%s", m_vRecording.at(i).z >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).z).c_str() : StringFromFormat("%04i", m_vRecording.at(i).z).c_str()); if (i < ((int)m_vRecording.size() - 1)) TmpStr += ","; - //Console::Print("%s\n", TmpStr.c_str()); + //INFO_LOG(CONSOLE, "%s\n", TmpStr.c_str()); // Write the IR data TmpIR += ArrayToString(m_vRecording.at(i).IR, IRBytes, 0, 30, false); @@ -391,7 +391,7 @@ void ConfigDialog::ConvertToString() } // Debug - Console::Print("Saved: [%i / %i] %03i %03i %03i\n", i, m_vRecording.size(), m_vRecording.at(i).x, m_vRecording.at(i).y, m_vRecording.at(i).z); + INFO_LOG(CONSOLE, "Saved: [%i / %i] %03i %03i %03i\n", i, m_vRecording.size(), m_vRecording.at(i).x, m_vRecording.at(i).y, m_vRecording.at(i).z); } // Recordings per second @@ -424,7 +424,7 @@ void ConfigDialog::ConvertToString() file.Save(FULL_CONFIG_DIR "WiimoteMovement.ini"); - Console::Print("Save recording to WiimoteMovement.ini\n"); + INFO_LOG(CONSOLE, "Save recording to WiimoteMovement.ini\n"); } // Timeout the recording @@ -493,7 +493,7 @@ void ConfigDialog::DoRecordA(bool Pressed) else { m_RecordButton[m_iRecordTo]->SetLabel(wxT("Done")); - Console::Print("Done: %i %i\n", m_bWaitForRecording, m_bRecording); + INFO_LOG(CONSOLE, "Done: %i %i\n", m_bWaitForRecording, m_bRecording); //m_bAllowA = true; ConvertToString(); } @@ -504,11 +504,11 @@ void ConfigDialog::DoRecordA(bool Pressed) void ConfigDialog::DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int _IRBytes) { //std::string Tmp1 = ArrayToString(_IR, 20, 0, 30); - //Console::Print("DoRecordMovement: %s\n", Tmp1.c_str()); + //INFO_LOG(CONSOLE, "DoRecordMovement: %s\n", Tmp1.c_str()); if (!m_bRecording) return; - //Console::Print("DoRecordMovement: %03i %03i %03i\n", _x, _y, _z); + //INFO_LOG(CONSOLE, "DoRecordMovement: %03i %03i %03i\n", _x, _y, _z); SRecording Tmp; Tmp.x = _x; diff --git a/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp b/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp index 4c05a9e904..7c0a27e260 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/DataReports.cpp @@ -95,11 +95,11 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr) DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous); DEBUG_LOG(WII_IPC_WIIMOTE, " All The Time: %x (not only on data change)", dr->all_the_time); DEBUG_LOG(WII_IPC_WIIMOTE, " Mode: 0x%02x", dr->mode); - Console::Print("Data reporting:\n"); - Console::Print(" Continuous: %x\n", dr->continuous); - Console::Print(" All The Time: %x (not only on data change)\n", dr->all_the_time); - Console::Print(" Mode: 0x%02x\n", dr->mode); - Console::Print(" Channel: 0x%04x\n", _channelID); + INFO_LOG(CONSOLE, "Data reporting:\n"); + INFO_LOG(CONSOLE, " Continuous: %x\n", dr->continuous); + INFO_LOG(CONSOLE, " All The Time: %x (not only on data change)\n", dr->all_the_time); + INFO_LOG(CONSOLE, " Mode: 0x%02x\n", dr->mode); + INFO_LOG(CONSOLE, " Channel: 0x%04x\n", _channelID); g_ReportingMode = dr->mode; g_ReportingChannel = _channelID; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h index 95eba711f1..2c56e82973 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h @@ -32,8 +32,6 @@ #include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd extern SWiimoteInitialize g_WiimoteInitialize; -//extern void __Log(int log, const char *format, ...); -//extern void __Log(int log, int v, const char *format, ...); namespace WiiMoteEmu { diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp index 7de00ab0f5..4e9841c4a8 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp @@ -67,7 +67,7 @@ void TiltTest(u8 x, u8 y, u8 z) std::string To = StringFromFormat("%s\nTo: X:%i Y:%i Z:%i Roll:%s Pitch:%s", From.c_str(), x, y, z, (_Roll >= 0) ? StringFromFormat(" %03i", (int)_Roll).c_str() : StringFromFormat("%04i", (int)_Roll).c_str(), (_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str()); - Console::Print("%s\n", To.c_str()); + INFO_LOG(CONSOLE, "%s\n", To.c_str()); } //////////////////////////////////// diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 19920964a1..229e26a618 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -127,10 +127,10 @@ void GetMousePos(float& x, float& y) } // Logging /* - Console::ClearScreen(); - Console::Print("Screen Width:%4.0f Height:%4.0f Ratio:%1.2f\n", WinWidth, WinHeight, Ratio); - Console::Print("Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset); - Console::Print("----------------------------------------------------------------\n"); +// Console::ClearScreen(); + INFO_LOG(CONSOLE, "Screen Width:%4.0f Height:%4.0f Ratio:%1.2f\n", WinWidth, WinHeight, Ratio); + INFO_LOG(CONSOLE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset); + INFO_LOG(CONSOLE, "----------------------------------------------------------------\n"); */ } // ------------------------------------- @@ -157,9 +157,9 @@ void GetMousePos(float& x, float& y) // Logging /* - Console::Print("Crop Ratio:%1.2f IncrWidth:%3.0f IncrHeight:%3.0f\n", Ratio, IncreasedWidth, IncreasedHeight); - Console::Print("Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset); - Console::Print("----------------------------------------------------------------\n"); + INFO_LOG(CONSOLE, "Crop Ratio:%1.2f IncrWidth:%3.0f IncrHeight:%3.0f\n", Ratio, IncreasedWidth, IncreasedHeight); + INFO_LOG(CONSOLE, "Picture Width:%4.1f Height:%4.1f YOffset:%4.0f XOffset:%4.0f\n", PictureWidth, PictureHeight, YOffset, XOffset); + INFO_LOG(CONSOLE, "----------------------------------------------------------------\n"); */ } // ------------------------------------- @@ -172,9 +172,9 @@ void GetMousePos(float& x, float& y) // Logging // ------------- /* - Console::Print("GetCursorPos: %i %i\n", point.x, point.y); - Console::Print("GetClientRect: %i %i %i %i\n", Rect.left, Rect.right, Rect.top, Rect.bottom); - Console::Print("Position X:%1.2f Y:%1.2f\n", x, y); + INFO_LOG(CONSOLE, "GetCursorPos: %i %i\n", point.x, point.y); + INFO_LOG(CONSOLE, "GetClientRect: %i %i %i %i\n", Rect.left, Rect.right, Rect.top, Rect.bottom); + INFO_LOG(CONSOLE, "Position X:%1.2f Y:%1.2f\n", x, y); */ // --------------------------- @@ -220,7 +220,7 @@ void GetCalibrationChecksum() sum += nunchuck_calibration[i]; u8 Check1 = sum + 0x55; u8 Check2 = sum + 0xaa; - Console::Print("0x%02x 0x%02x", Check1, Check2); + INFO_LOG(CONSOLE, "0x%02x 0x%02x", Check1, Check2); } // ================ @@ -230,7 +230,7 @@ void GetCalibrationChecksum() // ---------------- void LoadRecordedMovements() { - Console::Print("LoadRecordedMovements()\n"); + INFO_LOG(CONSOLE, "LoadRecordedMovements()\n"); IniFile file; file.Load(FULL_CONFIG_DIR "WiimoteMovement.ini"); @@ -238,7 +238,7 @@ void LoadRecordedMovements() for(int i = 0; i < RECORDING_ROWS; i++) { // Logging - //Console::Print("Recording%i ", i + 1); + //INFO_LOG(CONSOLE, "Recording%i ", i + 1); // Temporary storage int iTmp; @@ -310,10 +310,10 @@ void LoadRecordedMovements() // --------------------------------- // Log results // --------- - /*Console::Print("Time:%f\n", Tmp.Time); + /*INFO_LOG(CONSOLE, "Time:%f\n", Tmp.Time); std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30); - Console::Print("IR: %s\n", TmpIRLog.c_str()); - Console::Print("\n");*/ + INFO_LOG(CONSOLE, "IR: %s\n", TmpIRLog.c_str()); + INFO_LOG(CONSOLE, "\n");*/ } // Get HotKey @@ -335,7 +335,7 @@ void LoadRecordedMovements() else TmpIRLog = ""; - Console::Print("Size:%i HotKey:%i PlSpeed:%i IR:%s X:%i Y:%i Z:%i\n", + INFO_LOG(CONSOLE, "Size:%i HotKey:%i PlSpeed:%i IR:%s X:%i Y:%i Z:%i\n", VRecording.at(i).Recording.size(), VRecording.at(i).HotKeyWiimote, VRecording.at(i).PlaybackSpeed, TmpIRLog.c_str(), VRecording.at(i).Recording.at(0).x, VRecording.at(i).Recording.at(0).y, VRecording.at(i).Recording.at(0).z @@ -355,7 +355,7 @@ void UpdateEeprom() g_wm.cal_g.y = g_Eeprom[27] - g_Eeprom[24]; g_wm.cal_g.z = g_Eeprom[28] - g_Eeprom[24]; - Console::Print("\nUpdateEeprom: %i %i %i\n", + INFO_LOG(CONSOLE, "\nUpdateEeprom: %i %i %i\n", WiiMoteEmu::g_Eeprom[22], WiiMoteEmu::g_Eeprom[23], WiiMoteEmu::g_Eeprom[28]); if(g_Config.bNunchuckConnected) @@ -373,7 +373,7 @@ void UpdateEeprom() g_nu.jy.min = g_RegExt[0x2c]; g_nu.jy.center = g_RegExt[0x2d]; - Console::Print("UpdateNunchuck: %i %i %i %i %i\n\n", + INFO_LOG(CONSOLE, "UpdateNunchuck: %i %i %i %i %i\n\n", WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d], WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]); } @@ -396,7 +396,7 @@ void UpdateEeprom() g_cc.Tl.neutral = g_RegExt[0x2c]; g_cc.Tr.neutral = g_RegExt[0x2d]; - Console::Print("UpdateCC: %i %i %i %i %i\n\n", + INFO_LOG(CONSOLE, "UpdateCC: %i %i %i %i %i\n\n", WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d], WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]); } @@ -460,7 +460,7 @@ void SetDefaultExtensionRegistry() memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id)); } - Console::Print("\nSetDefaultExtensionRegistry()\n\n"); + INFO_LOG(CONSOLE, "\nSetDefaultExtensionRegistry()\n\n"); UpdateEeprom(); } @@ -518,7 +518,7 @@ void DoState(void* ptr, int mode) these variables. */ void Shutdown(void) { - Console::Print("ShutDown\n"); + INFO_LOG(CONSOLE, "ShutDown\n"); ResetVariables(); @@ -529,7 +529,7 @@ void Shutdown(void) if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID) if (joyinfo.at(PadMapping[i].ID).Good) { - Console::Print("ShutDown: %i\n", PadState[i].joy); + INFO_LOG(CONSOLE, "ShutDown: %i\n", PadState[i].joy); /* SDL_JoystickClose() crashes for some reason so I avoid this for now, SDL_Quit() should close the pads to I think */ //if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy); @@ -582,7 +582,7 @@ void CheckAckDelay() } AckDelay.at(i).Delay--; - //Console::Print("%i 0x%04x 0x%02x", i, AckDelay.at(i).ChannelID, AckDelay.at(i).ReportID); + //INFO_LOG(CONSOLE, "%i 0x%04x 0x%02x", i, AckDelay.at(i).ChannelID, AckDelay.at(i).ReportID); } } } @@ -595,7 +595,7 @@ void CheckAckDelay() // ---------------- void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) { - //Console::Print("Emu InterruptChannel\n"); + //INFO_LOG(CONSOLE, "Emu InterruptChannel\n"); DEBUG_LOG(WII_IPC_WIIMOTE, "============================================================="); DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote_Input"); @@ -657,7 +657,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) { - //Console::Print("Emu ControlChannel\n"); + //INFO_LOG(CONSOLE, "Emu ControlChannel\n"); const u8* data = (const u8*)_pData; // Dump raw data @@ -665,7 +665,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) INFO_LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel"); std::string Temp = ArrayToString(data, 0, _Size); #if defined(HAVE_WX) && HAVE_WX - Console::Print("\n%s: ControlChannel: %s\n", Tm().c_str(), Temp.c_str()); + INFO_LOG(CONSOLE, "\n%s: ControlChannel: %s\n", Tm().c_str(), Temp.c_str()); #endif DEBUG_LOG(WII_IPC_WIIMOTE, " Data: %s", Temp.c_str()); } @@ -724,7 +724,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) void Update() { //LOG(WII_IPC_WIIMOTE, "Wiimote_Update"); - //Console::Print("Emu Update: %i\n", g_ReportingMode); + //INFO_LOG(CONSOLE, "Emu Update: %i\n", g_ReportingMode); // Check if the pad state should be updated if ((g_Config.Trigger.Type == g_Config.Trigger.TRIGGER || g_Config.Trigger.Type == g_Config.Trigger.ANALOG1 || g_Config.Trigger.Type == g_Config.Trigger.ANALOG2 diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp index d862aa5f4b..4db783bfdf 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp @@ -171,8 +171,8 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT #endif /* Debugging - Console::ClearScreen(); - Console::Print( +// Console::ClearScreen(); + DEBUG_LOG(CONSOLE, "Controller and handle: %i %i\n" "Triggers:%i %i %i %i %i\n" diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index c6f06d07cf..b06d834760 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -96,7 +96,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr) { case WM_REQUEST_STATUS: // 0x15 if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmRequestStatus(_channelID, (wm_request_status*)sr->data); //Temp = ArrayToString(sr->data, sizeof(wm_request_status), 0); - //Console::Print("\n%s: InterruptChannel: %s\n", Tm().c_str(), Temp.c_str()); + //INFO_LOG(CONSOLE, "\n%s: InterruptChannel: %s\n", Tm().c_str(), Temp.c_str()); break; case WM_READ_DATA: // 0x17 if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data); @@ -107,7 +107,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr) { case WM_IR_PIXEL_CLOCK: // 0x13 case WM_IR_LOGIC: // 0x1a WARN_LOG(WII_IPC_WIIMOTE, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); - Console::Print("IR Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); + INFO_LOG(CONSOLE, "IR Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); if(sr->data[0] == 0x02) g_IR = 0; else if(sr->data[0] == 0x06) g_IR = 1; break; @@ -118,13 +118,13 @@ void HidOutputReport(u16 _channelID, wm_report* sr) { case WM_SPEAKER_ENABLE: // 0x14 INFO_LOG(WII_IPC_WIIMOTE, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); - //Console::Print("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); + //INFO_LOG(CONSOLE, "Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); if(sr->data[0] == 0x02) g_Speaker = 0; else if(sr->data[0] == 0x06) g_Speaker = 1; break; case WM_SPEAKER_MUTE: // 0x19 INFO_LOG(WII_IPC_WIIMOTE, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); - //Console::Print("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); + //INFO_LOG(CONSOLE, "Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); if(sr->data[0] == 0x02) g_SpeakerVoice = 0; // g_SpeakerVoice else if(sr->data[0] == 0x06) g_SpeakerVoice = 1; break; @@ -204,13 +204,13 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address) INFO_LOG(WII_IPC_WIIMOTE, " Report ID: %02x", _reportID); //std::string Temp = ArrayToString(DataFrame, Offset, 0); //LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str()); - //Console::Print("%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str()); + //INFO_LOG(CONSOLE, "%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str()); /* Debug. Write the report for extension registry writes. if((_reportID == 0x16 || _reportID == 0x17) && ((address >> 16) & 0xfe) == 0xa4) { - Console::Print("\nWMSendAck Report ID: %02x Encryption: %02x\n", _reportID, g_RegExt[0xf0]); - Console::Print("Data: %s\n", Temp.c_str()); + INFO_LOG(CONSOLE, "\nWMSendAck Report ID: %02x Encryption: %02x\n", _reportID, g_RegExt[0xf0]); + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str()); }*/ g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); @@ -248,7 +248,7 @@ void WmReadData(u16 _channelID, wm_read_data* rd) return; } SendReadDataReply(_channelID, g_Eeprom + address, address, (u8)size); - /*Console::Print("Read RegEeprom: Size: %i, Address: %08x, Offset: %08x\n", + /*INFO_LOG(CONSOLE, "Read RegEeprom: Size: %i, Address: %08x, Offset: %08x\n", size, address, (address & 0xffff));*/ } else if(rd->space == WM_SPACE_REGS1 || rd->space == WM_SPACE_REGS2) @@ -263,7 +263,7 @@ void WmReadData(u16 _channelID, wm_read_data* rd) INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa2: g_RegSpeaker"); /*Tmp = ArrayToString(g_RegSpeaker, size, (address & 0xffff)); //LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str()); - Console::Print("Read RegSpkr: Size %i Address %08x Offset %08x\nData %s\n", + INFO_LOG(CONSOLE, "Read RegSpkr: Size %i Address %08x Offset %08x\nData %s\n", size, address, (address & 0xffff), Tmp.c_str());*/ break; case 0xA4: @@ -272,7 +272,7 @@ void WmReadData(u16 _channelID, wm_read_data* rd) INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa4: Read ExtReg"); /*Tmp = ArrayToString(g_RegExt, size, (address & 0xffff), 40); //LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str()); - Console::Print("Read RegExt: Size %i Address %08x Offset %08x\nData %s\n", + INFO_LOG(CONSOLE, "Read RegExt: Size %i Address %08x Offset %08x\nData %s\n", size, address, (address & 0xffff), Tmp.c_str());*/ break; case 0xB0: @@ -281,7 +281,7 @@ void WmReadData(u16 _channelID, wm_read_data* rd) INFO_LOG(WII_IPC_WIIMOTE, " Case: 0xb0 g_RegIr"); /*Tmp = ArrayToString(g_RegIr, size, (address & 0xffff)); //LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str()); - Console::Print("Read RegIR: Size %i Address %08x Offset %08x\nData %s\n", + INFO_LOG(CONSOLE, "Read RegIR: Size %i Address %08x Offset %08x\nData %s\n", size, address, (address & 0xffff), Tmp.c_str());*/ break; default: @@ -297,12 +297,12 @@ void WmReadData(u16 _channelID, wm_read_data* rd) if(((address >> 16) & 0xfe) == 0xa4) { /* Debugging - Console::Print("\n\nWmReadData Address: %08x Offset: %08x Size: %i byte\n", + INFO_LOG(CONSOLE, "\n\nWmReadData Address: %08x Offset: %08x Size: %i byte\n", address, address & 0xffff, (u8)size); // Debugging u32 offset = address & 0xffff; std::string Temp = ArrayToString(g_RegExt, size, offset); - Console::Print("Unencrypted data:\n%s\n", Temp.c_str());*/ + INFO_LOG(CONSOLE, "Unencrypted data:\n%s\n", Temp.c_str());*/ // Check if encrypted reads is on if(g_RegExt[0xf0] == 0xaa) @@ -319,7 +319,7 @@ void WmReadData(u16 _channelID, wm_read_data* rd) /* Debugging: Show the encrypted data std::string Temp = ArrayToString(g_RegExtTmp, size, offset); - Console::Print("Encrypted data:\n%s\n", Temp.c_str());*/ + INFO_LOG(CONSOLE, "Encrypted data:\n%s\n", Temp.c_str());*/ } } //------------- @@ -405,14 +405,14 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size) DEBUG_LOG(WII_IPC_WIIMOTE, " Error: 0x%x", pReply->error); DEBUG_LOG(WII_IPC_WIIMOTE, " Size: 0x%x", pReply->size); DEBUG_LOG(WII_IPC_WIIMOTE, " Address: 0x%04x", pReply->address); - /*Console::Print(" SendReadDataReply()\n"); - Console::Print(" Offset: 0x%x\n", Offset); - Console::Print(" dataOffset: 0x%x\n", dataOffset); - Console::Print(" copySize: 0x%x\n", copySize); - Console::Print(" Size: 0x%x\n", pReply->size); - Console::Print(" Address: 0x%04x\n", Common::swap16(pReply->address));*/ + /*INFO_LOG(CONSOLE, " SendReadDataReply()\n"); + INFO_LOG(CONSOLE, " Offset: 0x%x\n", Offset); + INFO_LOG(CONSOLE, " dataOffset: 0x%x\n", dataOffset); + INFO_LOG(CONSOLE, " copySize: 0x%x\n", copySize); + INFO_LOG(CONSOLE, " Size: 0x%x\n", pReply->size); + INFO_LOG(CONSOLE, " Address: 0x%04x\n", Common::swap16(pReply->address));*/ //std::string Temp = ArrayToString(data, 0x40); - //Console::Print("Data:\n%s\n", Temp.c_str()); + //INFO_LOG(CONSOLE, "Data:\n%s\n", Temp.c_str()); // Send a piece g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); @@ -456,7 +456,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd) return; } memcpy(g_Eeprom + address, wd->data, wd->size); - /*Console::Print("Write RegEeprom: Size: %i, Address: %08x, Offset: %08x\n", + /*INFO_LOG(CONSOLE, "Write RegEeprom: Size: %i, Address: %08x, Offset: %08x\n", wd->size, address, (address & 0xffff));*/ } // Write to registers @@ -470,9 +470,9 @@ void WmWriteData(u16 _channelID, wm_write_data* wd) block = g_RegSpeaker; blockSize = WIIMOTE_REG_SPEAKER_SIZE; INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa2: RegSpeaker"); - /*Console::Print("Write RegSpeaker: Size: %i, Address: %08x, Offset: %08x\n", + /*INFO_LOG(CONSOLE, "Write RegSpeaker: Size: %i, Address: %08x, Offset: %08x\n", wd->size, address, (address & 0xffff)); - Console::Print("Data: %s\n", Temp.c_str());*/ + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/ break; case 0xA4: block = g_RegExt; // Extension Controller register @@ -480,17 +480,17 @@ void WmWriteData(u16 _channelID, wm_write_data* wd) //LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************"); INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa4: ExtReg"); //LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************"); - /*Console::Print("Write RegExt Size: %i Address: %08x Offset: %08x \n", + /*INFO_LOG(CONSOLE, "Write RegExt Size: %i Address: %08x Offset: %08x \n", wd->size, address, (address & 0xffff)); - Console::Print("Data: %s\n", Temp.c_str());*/ + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/ break; case 0xB0: block = g_RegIr; blockSize = WIIMOTE_REG_IR_SIZE; INFO_LOG(WII_IPC_WIIMOTE, " Case 0xb0: RegIr"); - /*Console::Print("Write RegIR Size: %i Address: %08x Offset: %08x \n", + /*INFO_LOG(CONSOLE, "Write RegIR Size: %i Address: %08x Offset: %08x \n", wd->size, address, (address & 0xffff)); - Console::Print("Data: %s\n", Temp.c_str());*/ + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/ break; default: ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: bad register block!"); @@ -518,8 +518,8 @@ void WmWriteData(u16 _channelID, wm_write_data* wd) if(blockSize == WIIMOTE_REG_EXT_SIZE) { /* Debugging. Write the data. - Console::Print("Data: %s\n", Temp.c_str()); - Console::Print("Current address: %08x\n", address); */ + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str()); + INFO_LOG(CONSOLE, "Current address: %08x\n", address); */ /* Run the key generation on all writes in the key area, it doesn't matter that we send it parts of a key, only the last full key will have an diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h index ac8e7110a1..fc583fd165 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.h @@ -40,9 +40,6 @@ // Declarations and definitions // ŻŻŻŻŻŻŻŻŻ extern SWiimoteInitialize g_WiimoteInitialize; -//extern void __Log(int log, const char *format, ...); -//extern void __Log(int log, int v, const char *format, ...); -/////////////////////////////// namespace WiiMoteEmu diff --git a/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp b/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp index 80f90be5cb..b3475406a9 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Encryption.cpp @@ -262,8 +262,8 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata) for(int i=0;i<6;i++) skey[5-i] = keydata[i+10]; - Console::Print("rand: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", rand[0], rand[1], rand[2], rand[3], rand[4], rand[5], rand[6], rand[7], rand[8], rand[9]); - Console::Print("key: %02x %02x %02x %02x %02x %02x\n", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]); + INFO_LOG(CONSOLE, "rand: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", rand[0], rand[1], rand[2], rand[3], rand[4], rand[5], rand[6], rand[7], rand[8], rand[9]); + INFO_LOG(CONSOLE, "key: %02x %02x %02x %02x %02x %02x\n", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]); for(idx = 0; idx < 7; idx++) { @@ -272,12 +272,12 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata) break; } // default case is idx = 7 which is valid (homebrew uses it for the 0x17 case) - Console::Print("idx: %d\n", idx); + INFO_LOG(CONSOLE, "idx: %d\n", idx); gentabs(rand, skey, idx, key->ft, key->sb); - Console::Print("ft: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->ft[0], key->ft[1], key->ft[2], key->ft[3], key->ft[4], key->ft[5], key->ft[6], key->ft[7]); - Console::Print("sb: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->sb[0], key->sb[1], key->sb[2], key->sb[3], key->sb[4], key->sb[5], key->sb[6], key->sb[7]); + INFO_LOG(CONSOLE, "ft: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->ft[0], key->ft[1], key->ft[2], key->ft[3], key->ft[4], key->ft[5], key->ft[6], key->ft[7]); + INFO_LOG(CONSOLE, "sb: %02x %02x %02x %02x %02x %02x %02x %02x\n", key->sb[0], key->sb[1], key->sb[2], key->sb[3], key->sb[4], key->sb[5], key->sb[6], key->sb[7]); // for homebrew, ft and sb are all 0x97 which is equivalent to 0x17 } diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index e94b05ef64..e874bfc991 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -111,7 +111,7 @@ int G2Accelerometer(int _G, int XYZ, int Wm) int Return = (int)Accelerometer; // Logging - //Console::Print("G2Accelerometer():%f %f %f %f\n", Neutral, OneG, G, Accelerometer); + //INFO_LOG(CONSOLE, "G2Accelerometer():%f %f %f %f\n", Neutral, OneG, G, Accelerometer); // Boundaries if (Return > 255) Return = 255; @@ -130,14 +130,14 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) if(VRecording.at(g_RecordingPlaying[Wm]).Recording.size() == 0) { g_RecordingPlaying[Wm] = -1; - Console::Print("Empty\n\n"); + INFO_LOG(CONSOLE, "Empty\n\n"); return false; } // Return if the playback speed is unset if(VRecording.at(g_RecordingPlaying[Wm]).PlaybackSpeed < 0) { - Console::Print("PlaybackSpeed empty: %i\n\n", g_RecordingPlaying[Wm]); + INFO_LOG(CONSOLE, "PlaybackSpeed empty: %i\n\n", g_RecordingPlaying[Wm]); g_RecordingPlaying[Wm] = -1; return false; } @@ -152,7 +152,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) ) ) { - Console::Print("Wrong IR mode: %i\n\n", g_RecordingPlaying[Wm]); + INFO_LOG(CONSOLE, "Wrong IR mode: %i\n\n", g_RecordingPlaying[Wm]); g_RecordingPlaying[Wm] = -1; return false; } @@ -160,7 +160,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) // Get starting time if(g_RecordingCounter[Wm] == 0) { - Console::Print("\n\nBegin: %i\n", Wm); + INFO_LOG(CONSOLE, "\n\nBegin: %i\n", Wm); g_RecordingStart[Wm] = GetDoubleTime(); } @@ -190,7 +190,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) g_RecordingPlaying[Wm] = -1; g_RecordingStart[Wm] = 0; g_RecordingCurrentTime[Wm] = 0; - Console::Print("End: %i\n\n", Wm); + INFO_LOG(CONSOLE, "End: %i\n\n", Wm); return false; } @@ -204,13 +204,13 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) if (g_DebugAccelerometer) { //Console::ClearScreen(); - Console::Print("Current time: [%i / %i] %f %f\n", + INFO_LOG(CONSOLE, "Current time: [%i / %i] %f %f\n", g_RecordingPoint[Wm], VRecording.at(g_RecordingPlaying[Wm]).Recording.size(), VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).Time, g_RecordingCurrentTime[Wm] ); - Console::Print("Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); + INFO_LOG(CONSOLE, "Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); } - //Console::Print("Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); + //INFO_LOG(CONSOLE, "Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); g_RecordingCounter[Wm]++; @@ -272,7 +272,7 @@ bool IsSwitchPressed(int _Key) int RecordingCheckKeys(int WmNuIr) { #ifdef _WIN32 - //Console::Print("RecordingCheckKeys: %i\n", Wiimote); + //INFO_LOG(CONSOLE, "RecordingCheckKeys: %i\n", Wiimote); // Check if we have a HotKey match bool Match = false; @@ -287,7 +287,7 @@ int RecordingCheckKeys(int WmNuIr) || VRecording.at(i).HotKeyIR == j && WmNuIr == 2 && IsNumericalKeyPressed(j)) && (IsSwitchPressed(VRecording.at(i).HotKeySwitch) || VRecording.at(i).HotKeySwitch == 3)) { - //Console::Print("Match: %i %i\n", i, Key); + //INFO_LOG(CONSOLE, "Match: %i %i\n", i, Key); Match = true; Recording = i; break; @@ -485,7 +485,7 @@ void SingleShake(u8 &_y, u8 &_z, int i) Shake[i] = -1; } #endif - //if (Shake[i] > -1) Console::Print("Shake: %i\n", Shake[i]); + //if (Shake[i] > -1) INFO_LOG(CONSOLE, "Shake: %i\n", Shake[i]); } @@ -609,7 +609,7 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch) else { Pitch = KbDegree; - //Console::Print("Degree: %2.1f\n", KbDegree); + //INFO_LOG(CONSOLE, "Degree: %2.1f\n", KbDegree); } // -------------------- #endif @@ -642,9 +642,9 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z) if (g_DebugData) { //Console::ClearScreen(); - /*Console::Print("L:%2.1f R:%2.1f Lx:%2.1f Range:%2.1f Degree:%2.1f L:%i R:%i\n", + /*INFO_LOG(CONSOLE, "L:%2.1f R:%2.1f Lx:%2.1f Range:%2.1f Degree:%2.1f L:%i R:%i\n", Tl, Tr, Lx, Range, Degree, PadState[Page].Axis.Tl, PadState[Page].Axis.Tr);*/ - /*Console::Print("Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch);*/ + /*INFO_LOG(CONSOLE, "Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch);*/ } } @@ -662,7 +662,7 @@ void FillReportAcc(wm_accel& _acc) { // If the recording reached the end or failed somehow we will not return if (RecordingPlay(_acc.x, _acc.y, _acc.z, 0)) return; - //Console::Print("X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); + //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); } // --------------------- @@ -767,13 +767,13 @@ void FillReportAcc(wm_accel& _acc) //if(consoleDisplay == 0) - Console::Print("x: %03i | y: %03i | z: %03i | A:%i B:%i C:%i a:%i b:%i c:%i d:%i X:%i Y:%i Z:%i\n", + INFO_LOG(CONSOLE, "x: %03i | y: %03i | z: %03i | A:%i B:%i C:%i a:%i b:%i c:%i d:%i X:%i Y:%i Z:%i\n", _acc.x, _acc.y, _acc.z, A, B, C, a, b, c, d, X, Y, Z ); - Console::Print("x: %03i | y: %03i | z: %03i | X:%i Y:%i Z:%i | AX:%i AY:%i AZ:%i \n", + INFO_LOG(CONSOLE, "x: %03i | y: %03i | z: %03i | X:%i Y:%i Z:%i | AX:%i AY:%i AZ:%i \n", _acc.x, _acc.y, _acc.z, X, Y, Z, AX, AY, AZ @@ -804,7 +804,7 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1) } else { - //Console::Print("X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); + //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); if (RecordingPlayIR(_ir0)) return; } // --------------------- @@ -857,7 +857,7 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1) //Console::ClearScreen(); //if(consoleDisplay == 1) - Console::Print("x0:%03i x1:%03i y0:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i\n", + INFO_LOG(CONSOLE, "x0:%03i x1:%03i y0:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i\n", x0, x1, y0, y1, Top, Left, Right, Bottom, SensorBarRadius );*/ // ------------------ @@ -898,7 +898,7 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1) // We are playing back a recording, we don't accept any manual input this time else { - //Console::Print("X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); + //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); if (RecordingPlayIR(_ir0)) return; } // --------------------- @@ -958,11 +958,11 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1) //ClearScreen(); //if(consoleDisplay == 1) - Console::Print("x1:%03i x2:%03i y1:%03i y2:%03i irx1:%02x y1:%02x x2:%02x y2:%02x | T:%i L:%i R:%i B:%i S:%i\n", + INFO_LOG(CONSOLE, "x1:%03i x2:%03i y1:%03i y2:%03i irx1:%02x y1:%02x x2:%02x y2:%02x | T:%i L:%i R:%i B:%i S:%i\n", x1, x2, y1, y2, _ir0.x1, _ir0.y1, _ir1.x2, _ir1.y2, Top, Left, Right, Bottom, SensorBarRadius ); - Console::Print("\n"); - Console::Print("ir0.x1:%02x x1h:%02x x2:%02x x2h:%02x | ir0.y1:%02x y1h:%02x y2:%02x y2h:%02x | ir1.x1:%02x x1h:%02x x2:%02x x2h:%02x | ir1.y1:%02x y1h:%02x y2:%02x y2h:%02x\n", + INFO_LOG(CONSOLE, "\n"); + INFO_LOG(CONSOLE, "ir0.x1:%02x x1h:%02x x2:%02x x2h:%02x | ir0.y1:%02x y1h:%02x y2:%02x y2h:%02x | ir1.x1:%02x x1h:%02x x2:%02x x2h:%02x | ir1.y1:%02x y1h:%02x y2:%02x y2h:%02x\n", _ir0.x1, _ir0.x1Hi, _ir0.x2, _ir0.x2Hi, _ir0.y1, _ir0.y1Hi, _ir0.y2, _ir0.y2Hi, _ir1.x1, _ir1.x1Hi, _ir1.x2, _ir1.x2Hi, diff --git a/Source/Plugins/Plugin_Wiimote/Src/Logging.h b/Source/Plugins/Plugin_Wiimote/Src/Logging.h index 5c0e964419..965aa9def1 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Logging.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Logging.h @@ -22,7 +22,6 @@ // Includes // ŻŻŻŻŻŻŻŻŻŻŻŻŻ #include -#include "ConsoleWindow.h" ////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp index f02f48616b..f43aeaadca 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp @@ -23,7 +23,6 @@ #include "wiiuse.h" // Externals -#include "ConsoleWindow.h" // Common #include "StringUtil.h" #include "Timer.h" #include "pluginspecs_wiimote.h" @@ -49,26 +48,26 @@ int GetReportSize(struct wiimote_t* wm) void handle_ctrl_status(struct wiimote_t* wm) { - Console::Print("\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", wm->unid); + INFO_LOG(CONSOLE, "\n\n--- CONTROLLER STATUS [wiimote id %i] ---\n", wm->unid); - Console::Print("attachment: %i\n", wm->exp.type); - Console::Print("speaker: %i\n", WIIUSE_USING_SPEAKER(wm)); - Console::Print("ir: %i\n", WIIUSE_USING_IR(wm)); - Console::Print("leds: %i %i %i %i\n", WIIUSE_IS_LED_SET(wm, 1), WIIUSE_IS_LED_SET(wm, 2), WIIUSE_IS_LED_SET(wm, 3), WIIUSE_IS_LED_SET(wm, 4)); - Console::Print("battery: %f %%\n", wm->battery_level); + INFO_LOG(CONSOLE, "attachment: %i\n", wm->exp.type); + INFO_LOG(CONSOLE, "speaker: %i\n", WIIUSE_USING_SPEAKER(wm)); + INFO_LOG(CONSOLE, "ir: %i\n", WIIUSE_USING_IR(wm)); + INFO_LOG(CONSOLE, "leds: %i %i %i %i\n", WIIUSE_IS_LED_SET(wm, 1), WIIUSE_IS_LED_SET(wm, 2), WIIUSE_IS_LED_SET(wm, 3), WIIUSE_IS_LED_SET(wm, 4)); + INFO_LOG(CONSOLE, "battery: %f %%\n", wm->battery_level); } bool IRDataOK(struct wiimote_t* wm) { - //Console::Print("IRDataOK: "); + //INFO_LOG(CONSOLE, "IRDataOK: "); // The report size is 0x33 = 18, 0x37 = 22 withouth the leading (a1) byte int ReportSize = GetReportSize(wm); for(int i = 0; i < ReportSize; i++) { - //Console::Print("%02x ", wm->event_buf[i]); + //INFO_LOG(CONSOLE, "%02x ", wm->event_buf[i]); if (wm->event_buf[i] > 0) { - //Console::Print("\n"); + //INFO_LOG(CONSOLE, "\n"); return true; } } @@ -77,21 +76,21 @@ bool IRDataOK(struct wiimote_t* wm) void handle_event(struct wiimote_t* wm) { - //Console::Print("\n\n--- EVENT [id %i] ---\n", wm->unid); + //INFO_LOG(CONSOLE, "\n\n--- EVENT [id %i] ---\n", wm->unid); // if a button is pressed, report it - if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) Console::Print("A pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) Console::Print("B pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) Console::Print("UP pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) Console::Print("DOWN pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) Console::Print("LEFT pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) Console::Print("RIGHT pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) Console::Print("MINUS pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) Console::Print("PLUS pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) Console::Print("ONE pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) INFO_LOG(CONSOLE, "A pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) INFO_LOG(CONSOLE, "B pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) INFO_LOG(CONSOLE, "UP pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) INFO_LOG(CONSOLE, "DOWN pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) INFO_LOG(CONSOLE, "LEFT pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) INFO_LOG(CONSOLE, "RIGHT pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) INFO_LOG(CONSOLE, "MINUS pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) INFO_LOG(CONSOLE, "PLUS pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) INFO_LOG(CONSOLE, "ONE pressed\n"); //if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) g_Run = false; - if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) Console::Print("TWO pressed\n"); - if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) Console::Print("HOME pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) INFO_LOG(CONSOLE, "TWO pressed\n"); + if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) INFO_LOG(CONSOLE, "HOME pressed\n"); // Pressing minus will tell the wiimote we are no longer interested in movement. @@ -168,7 +167,7 @@ void handle_event(struct wiimote_t* wm) //Tmp += "Data: " + TmpData; //Console::ClearScreen(); - //Console::Print("%s\n\n", Tmp.c_str()); + //INFO_LOG(CONSOLE, "%s\n\n", Tmp.c_str()); #if defined(HAVE_WX) && HAVE_WX if(frame) @@ -214,8 +213,8 @@ void handle_event(struct wiimote_t* wm) // wxT("Current: %03u %03u %03u"), Gx, Gy, Gz)); if(frame->m_bRecording) - Console::Print("Wiiuse Recorded accel x, y, z: %03i %03i %03i\n", Gx, Gy, Gz); - //Console::Print("Wiiuse Recorded accel x, y, z: %02x %02x %02x\n", Gx, Gy, Gz); + INFO_LOG(CONSOLE, "Wiiuse Recorded accel x, y, z: %03i %03i %03i\n", Gx, Gy, Gz); + //INFO_LOG(CONSOLE, "Wiiuse Recorded accel x, y, z: %02x %02x %02x\n", Gx, Gy, Gz); } // Send the data to be saved @@ -233,8 +232,8 @@ void handle_event(struct wiimote_t* wm) /* if(!g_DebugData) { - Console::ClearScreen(); - Console::Print("Roll:%03i Pitch:%03i\n", (int)wm->orient.roll, (int)wm->orient.pitch); +// Console::ClearScreen(); + INFO_LOG(CONSOLE, "Roll:%03i Pitch:%03i\n", (int)wm->orient.roll, (int)wm->orient.pitch); } // Convert Roll and Pitch from 180 to 0x8000 int Roll = (int)wm->orient.roll * (0x8000 / 180); @@ -337,7 +336,7 @@ void ReadWiimote() { Temp = ArrayToString(g_WiiMotesFromWiiUse[0]->read_req->buf, sizeof(WiiMoteEmu::EepromData_0), 0, 30); memcpy(WiiMoteEmu::g_Eeprom, g_WiiMotesFromWiiUse[0]->read_req->buf, sizeof(WiiMoteEmu::EepromData_0)); - Console::Print("EEPROM: %s\n", Temp.c_str()); + INFO_LOG(CONSOLE, "EEPROM: %s\n", Temp.c_str()); WiiMoteEmu::UpdateEeprom(); g_RunTemporary = false; } @@ -352,17 +351,17 @@ void ReadWiimote() */ //wiiuse_set_nunchuk_orient_threshold((struct nunchuk_t*)&wiimotes[i]->exp.nunchuk, 90.0f); //wiiuse_set_nunchuk_accel_threshold((struct nunchuk_t*)&wiimotes[i]->exp.nunchuk, 100); - Console::Print("Nunchuk inserted.\n"); + INFO_LOG(CONSOLE, "Nunchuk inserted.\n"); break; case WIIUSE_CLASSIC_CTRL_INSERTED: - Console::Print("Classic controller inserted.\n"); + INFO_LOG(CONSOLE, "Classic controller inserted.\n"); break; case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED: // some expansion was inserted //handle_ctrl_status(wiimotes[i]); - Console::Print("Guitar Hero 3 controller inserted.\n"); + INFO_LOG(CONSOLE, "Guitar Hero 3 controller inserted.\n"); break; case WIIUSE_NUNCHUK_REMOVED: @@ -370,7 +369,7 @@ void ReadWiimote() case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED: // some expansion was removed //handle_ctrl_status(wiimotes[i]); - Console::Print("An expansion was removed.\n"); + INFO_LOG(CONSOLE, "An expansion was removed.\n"); break; default: diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index dd38ea6a28..dfd6724d0c 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -37,7 +37,6 @@ worked. // ŻŻŻŻŻŻŻŻŻŻŻŻŻ #include "Common.h" // Common #include "StringUtil.h" -#include "ConsoleWindow.h" // For Start, Print, GetHwnd #include "Timer.h" #define EXCLUDEMAIN_H // Avoid certain declarations in main.h @@ -61,6 +60,7 @@ worked. // Declarations and definitions // ŻŻŻŻŻŻŻŻŻŻŻŻŻ SWiimoteInitialize g_WiimoteInitialize; +PLUGIN_GLOBALS* globals = NULL; // General bool g_EmulatorRunning = false; @@ -170,7 +170,11 @@ extern "C" void GetDllInfo (PLUGIN_INFO* _PluginInfo) #endif } -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {} +void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +{ + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); +} void DllDebugger(HWND _hParent, bool Show) {} @@ -229,7 +233,7 @@ extern "C" void Initialize(void *init) DoInitialize(); - Console::Print("ISOId: %08x %s\n", g_WiimoteInitialize.ISOId, Hex2Ascii(g_WiimoteInitialize.ISOId).c_str()); + INFO_LOG(CONSOLE, "ISOId: %08x %s\n", g_WiimoteInitialize.ISOId, Hex2Ascii(g_WiimoteInitialize.ISOId).c_str()); } // If a game is not running this is called by the Configuration window when it's closed @@ -261,7 +265,7 @@ extern "C" void Shutdown(void) #endif WiiMoteEmu::Shutdown(); - Console::Close(); + // Console::Close(); } @@ -319,7 +323,7 @@ extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _ // Check for custom communication if(_channelID == 99 && data[0] == WIIMOTE_RECONNECT) { - Console::Print("\n\nWiimote Disconnected\n\n"); + INFO_LOG(CONSOLE, "\n\nWiimote Disconnected\n\n"); g_EmulatorRunning = false; g_WiimoteUnexpectedDisconnect = true; #if defined(HAVE_WX) && HAVE_WX @@ -380,10 +384,6 @@ extern "C" void Wiimote_Update() // Debugging #ifdef _WIN32 - // Open console - if( GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_INSERT) ) - OpenConsole(); - if( GetAsyncKeyState(VK_HOME) && g_DebugComm ) g_DebugComm = false; // Page Down else if (GetAsyncKeyState(VK_HOME) && !g_DebugComm ) g_DebugComm = true; @@ -393,8 +393,8 @@ extern "C" void Wiimote_Update() if( GetAsyncKeyState(VK_NEXT) && g_DebugAccelerometer ) g_DebugAccelerometer = false; // Home else if (GetAsyncKeyState(VK_NEXT) && !g_DebugAccelerometer ) g_DebugAccelerometer = true; - if( GetAsyncKeyState(VK_END) && g_DebugCustom ) { g_DebugCustom = false; Console::Print("Custom Debug: Off\n");} // End - else if (GetAsyncKeyState(VK_END) && !g_DebugCustom ) {g_DebugCustom = true; Console::Print("Custom Debug: Off\n");} + if( GetAsyncKeyState(VK_END) && g_DebugCustom ) { g_DebugCustom = false; INFO_LOG(CONSOLE, "Custom Debug: Off\n");} // End + else if (GetAsyncKeyState(VK_END) && !g_DebugCustom ) {g_DebugCustom = true; INFO_LOG(CONSOLE, "Custom Debug: Off\n");} #endif } @@ -417,16 +417,17 @@ extern "C" unsigned int Wiimote_GetAttachedControllers() // ---------------------------------------- // Debugging window // ---------- +/* void OpenConsole(bool Open) { // Close the console window #ifdef _WIN32 - if (Console::GetHwnd() != NULL && !Open) +// if (Console::GetHwnd() != NULL && !Open) #else if (false) #endif { - Console::Close(); +// Console::Close(); // Wait here until we have let go of the button again #ifdef _WIN32 while(GetAsyncKeyState(VK_INSERT)) {Sleep(10);} @@ -435,16 +436,16 @@ void OpenConsole(bool Open) } // Open the console window - Console::Open(140, 1000, "Wiimote"); // give room for 20 rows - Console::Print("\n\nWiimote console opened\n"); +// Console::Open(140, 1000, "Wiimote"); // give room for 20 rows + INFO_LOG(CONSOLE, "\n\nWiimote console opened\n"); // Move window #ifdef _WIN32 //MoveWindow(Console::GetHwnd(), 0,400, 100*8,10*14, true); // small window //MoveWindow(Console::GetHwnd(), 400,0, 100*8,70*14, true); // big window - MoveWindow(Console::GetHwnd(), 200,0, 140*8,70*14, true); // big wide window +// MoveWindow(Console::GetHwnd(), 200,0, 140*8,70*14, true); // big wide window #endif -} + }*/ // --------------- // ---------------------------------------- @@ -500,7 +501,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) Name = "WM_STATUS_REPORT"; { wm_status_report* pStatus = (wm_status_report*)(data + 2); - Console::Print("\n" + INFO_LOG(CONSOLE, "\n" "Extension Controller: %i\n" //"Speaker enabled: %i\n" //"IR camera enabled: %i\n" @@ -566,8 +567,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) #if defined(HAVE_WX) && HAVE_WX if (frame) frame->UpdateGUI(); #endif - Console::Print("%s", TmpData.c_str()); - Console::Print("Game got the decrypted extension ID: %02x%02x\n\n", data[7], data[8]); + INFO_LOG(CONSOLE, "%s", TmpData.c_str()); + INFO_LOG(CONSOLE, "Game got the decrypted extension ID: %02x%02x\n\n", data[7], data[8]); } else if(data[4] == 0x50) { @@ -579,8 +580,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) #if defined(HAVE_WX) && HAVE_WX if (frame) frame->UpdateGUI(); #endif - Console::Print("%s", TmpData.c_str()); - Console::Print("Game got the decrypted extension ID: %02x%02x%02x%02x%02x%02x\n\n", data[7], data[8], data[9], data[10], data[11], data[12]); + INFO_LOG(CONSOLE, "%s", TmpData.c_str()); + INFO_LOG(CONSOLE, "Game got the decrypted extension ID: %02x%02x%02x%02x%02x%02x\n\n", data[7], data[8], data[9], data[10], data[11], data[12]); } } // --------------------------------------------- @@ -594,13 +595,13 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) { if(data[6] == 0x10) { - Console::Print("\nGame got the Wiimote calibration:\n"); - Console::Print("Cal_zero.x: %i\n", data[7 + 6]); - Console::Print("Cal_zero.y: %i\n", data[7 + 7]); - Console::Print("Cal_zero.z: %i\n", data[7 + 8]); - Console::Print("Cal_g.x: %i\n", data[7 + 10]); - Console::Print("Cal_g.y: %i\n", data[7 + 11]); - Console::Print("Cal_g.z: %i\n", data[7 +12]); + INFO_LOG(CONSOLE, "\nGame got the Wiimote calibration:\n"); + INFO_LOG(CONSOLE, "Cal_zero.x: %i\n", data[7 + 6]); + INFO_LOG(CONSOLE, "Cal_zero.y: %i\n", data[7 + 7]); + INFO_LOG(CONSOLE, "Cal_zero.z: %i\n", data[7 + 8]); + INFO_LOG(CONSOLE, "Cal_g.x: %i\n", data[7 + 10]); + INFO_LOG(CONSOLE, "Cal_g.y: %i\n", data[7 + 11]); + INFO_LOG(CONSOLE, "Cal_g.z: %i\n", data[7 +12]); } } // --------------------------------------------- @@ -619,37 +620,37 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) if (g_Config.bNunchuckConnected) { - Console::Print("\nGame got the Nunchuck calibration:\n"); - Console::Print("Cal_zero.x: %i\n", data[7 + 0]); - Console::Print("Cal_zero.y: %i\n", data[7 + 1]); - Console::Print("Cal_zero.z: %i\n", data[7 + 2]); - Console::Print("Cal_g.x: %i\n", data[7 + 4]); - Console::Print("Cal_g.y: %i\n", data[7 + 5]); - Console::Print("Cal_g.z: %i\n", data[7 + 6]); - Console::Print("Js.Max.x: %i\n", data[7 + 8]); - Console::Print("Js.Min.x: %i\n", data[7 + 9]); - Console::Print("Js.Center.x: %i\n", data[7 + 10]); - Console::Print("Js.Max.y: %i\n", data[7 + 11]); - Console::Print("Js.Min.y: %i\n", data[7 + 12]); - Console::Print("JS.Center.y: %i\n\n", data[7 + 13]); + INFO_LOG(CONSOLE, "\nGame got the Nunchuck calibration:\n"); + INFO_LOG(CONSOLE, "Cal_zero.x: %i\n", data[7 + 0]); + INFO_LOG(CONSOLE, "Cal_zero.y: %i\n", data[7 + 1]); + INFO_LOG(CONSOLE, "Cal_zero.z: %i\n", data[7 + 2]); + INFO_LOG(CONSOLE, "Cal_g.x: %i\n", data[7 + 4]); + INFO_LOG(CONSOLE, "Cal_g.y: %i\n", data[7 + 5]); + INFO_LOG(CONSOLE, "Cal_g.z: %i\n", data[7 + 6]); + INFO_LOG(CONSOLE, "Js.Max.x: %i\n", data[7 + 8]); + INFO_LOG(CONSOLE, "Js.Min.x: %i\n", data[7 + 9]); + INFO_LOG(CONSOLE, "Js.Center.x: %i\n", data[7 + 10]); + INFO_LOG(CONSOLE, "Js.Max.y: %i\n", data[7 + 11]); + INFO_LOG(CONSOLE, "Js.Min.y: %i\n", data[7 + 12]); + INFO_LOG(CONSOLE, "JS.Center.y: %i\n\n", data[7 + 13]); } else // g_Config.bClassicControllerConnected { - Console::Print("\nGame got the Classic Controller calibration:\n"); - Console::Print("Lx.Max: %i\n", data[7 + 0]); - Console::Print("Lx.Min: %i\n", data[7 + 1]); - Console::Print("Lx.Center: %i\n", data[7 + 2]); - Console::Print("Ly.Max: %i\n", data[7 + 3]); - Console::Print("Ly.Min: %i\n", data[7 + 4]); - Console::Print("Ly.Center: %i\n", data[7 + 5]); - Console::Print("Rx.Max.x: %i\n", data[7 + 6]); - Console::Print("Rx.Min.x: %i\n", data[7 + 7]); - Console::Print("Rx.Center.x: %i\n", data[7 + 8]); - Console::Print("Ry.Max.y: %i\n", data[7 + 9]); - Console::Print("Ry.Min: %i\n", data[7 + 10]); - Console::Print("Ry.Center: %i\n\n", data[7 + 11]); - Console::Print("Lt.Neutral: %i\n", data[7 + 12]); - Console::Print("Rt.Neutral %i\n\n", data[7 + 13]); + INFO_LOG(CONSOLE, "\nGame got the Classic Controller calibration:\n"); + INFO_LOG(CONSOLE, "Lx.Max: %i\n", data[7 + 0]); + INFO_LOG(CONSOLE, "Lx.Min: %i\n", data[7 + 1]); + INFO_LOG(CONSOLE, "Lx.Center: %i\n", data[7 + 2]); + INFO_LOG(CONSOLE, "Ly.Max: %i\n", data[7 + 3]); + INFO_LOG(CONSOLE, "Ly.Min: %i\n", data[7 + 4]); + INFO_LOG(CONSOLE, "Ly.Center: %i\n", data[7 + 5]); + INFO_LOG(CONSOLE, "Rx.Max.x: %i\n", data[7 + 6]); + INFO_LOG(CONSOLE, "Rx.Min.x: %i\n", data[7 + 7]); + INFO_LOG(CONSOLE, "Rx.Center.x: %i\n", data[7 + 8]); + INFO_LOG(CONSOLE, "Ry.Max.y: %i\n", data[7 + 9]); + INFO_LOG(CONSOLE, "Ry.Min: %i\n", data[7 + 10]); + INFO_LOG(CONSOLE, "Ry.Center: %i\n\n", data[7 + 11]); + INFO_LOG(CONSOLE, "Lt.Neutral: %i\n", data[7 + 12]); + INFO_LOG(CONSOLE, "Rt.Neutral %i\n\n", data[7 + 13]); } // Save the values if they come from the real Wiimote @@ -677,7 +678,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) } // Show the encrypted data - Console::Print("%s", TmpData.c_str()); + INFO_LOG(CONSOLE, "%s", TmpData.c_str()); } // --------------------------------------------- @@ -720,7 +721,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) break; default: //PanicAlert("%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]); - Console::Print("%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]); + INFO_LOG(CONSOLE, "%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]); return; } @@ -728,8 +729,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) { std::string TmpData = ArrayToString(data, size + 2, 0, 30); //LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str()); - Console::Print("Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), TmpData.c_str()); // No timestamp - //Console::Print(" (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp + INFO_LOG(CONSOLE, "Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), TmpData.c_str()); // No timestamp + //INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp } if (DataReport && g_DebugData) @@ -801,7 +802,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) // --------------------------------------------- // Test the angles to x, y, z values formula by calculating the values back and forth // ----------- - /*Console::ClearScreen(); + /* //Console::ClearScreen(); // Show a test of our calculations WiiMoteEmu::TiltTest(data[4], data[5], data[6]); u8 x, y, z; @@ -840,24 +841,24 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) // ------------------------- // Classic Controller data - Console::Print("Read[%s]: %s | %s | %s | %s | %s\n", (Emu ? "Emu" : "Real"), + INFO_LOG(CONSOLE, "Read[%s]: %s | %s | %s | %s | %s\n", (Emu ? "Emu" : "Real"), TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), CCData.c_str()); // Formatted data only - //Console::Print("Read[%s]: 0x%02x | %s | %s | %s\n", (Emu ? "Emu" : "Real"), data[1], RollPitch.c_str(), GForce.c_str(), IRData.c_str()); + //INFO_LOG(CONSOLE, "Read[%s]: 0x%02x | %s | %s | %s\n", (Emu ? "Emu" : "Real"), data[1], RollPitch.c_str(), GForce.c_str(), IRData.c_str()); // IR data - //Console::Print("Read[%s]: %s | %s\n", (Emu ? "Emu" : "Real"), TmpData.c_str(), IRData.c_str()); + //INFO_LOG(CONSOLE, "Read[%s]: %s | %s\n", (Emu ? "Emu" : "Real"), TmpData.c_str(), IRData.c_str()); // Accelerometer data - //Console::Print("Read[%s]: %s | %s | %s | %s | %s | %s | %s\n", (Emu ? "Emu" : "Real"), + //INFO_LOG(CONSOLE, "Read[%s]: %s | %s | %s | %s | %s | %s | %s\n", (Emu ? "Emu" : "Real"), // TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), RollPitch.c_str(), GForce.c_str(), CCData.c_str()); // Timestamp - //Console::Print(" (%s): %s\n", Tm(true).c_str(), Temp.c_str()); + //INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); } if(g_DebugAccelerometer) { // Accelerometer only - Console::ClearScreen(); - Console::Print("Accel x, y, z: %03u %03u %03u\n", data[4], data[5], data[6]); + // Console::ClearScreen(); + INFO_LOG(CONSOLE, "Accel x, y, z: %03u %03u %03u\n", data[4], data[5], data[6]); } } @@ -916,18 +917,18 @@ void InterruptDebugging(bool Emu, const void* _pData) Name.append(" REG_SPEAKER"); if(data[6] == 7) { - Console::Print("\nSound configuration:\n"); + INFO_LOG(CONSOLE, "\nSound configuration:\n"); if(data[8] == 0x00) { memcpy(&SampleValue, &data[9], 2); - Console::Print(" Data format: 4-bit ADPCM (%i Hz)\n", 6000000 / SampleValue); - Console::Print(" Volume: %02i%%\n\n", (data[11] / 0x40) * 100); + INFO_LOG(CONSOLE, " Data format: 4-bit ADPCM (%i Hz)\n", 6000000 / SampleValue); + INFO_LOG(CONSOLE, " Volume: %02i%%\n\n", (data[11] / 0x40) * 100); } else if (data[8] == 0x40) { memcpy(&SampleValue, &data[9], 2); - Console::Print(" Data format: 8-bit PCM (%i Hz)\n", 12000000 / SampleValue); - Console::Print(" Volume: %02i%%\n\n", (data[11] / 0xff) * 100); + INFO_LOG(CONSOLE, " Data format: 8-bit PCM (%i Hz)\n", 12000000 / SampleValue); + INFO_LOG(CONSOLE, " Volume: %02i%%\n\n", (data[11] / 0xff) * 100); } } } @@ -941,7 +942,7 @@ void InterruptDebugging(bool Emu, const void* _pData) WiiMoteEmu::g_Encryption = true; else if (data[7] == 0x55) WiiMoteEmu::g_Encryption = false; - Console::Print("\nExtension enryption turned %s\n\n", WiiMoteEmu::g_Encryption ? "On" : "Off"); + INFO_LOG(CONSOLE, "\nExtension enryption turned %s\n\n", WiiMoteEmu::g_Encryption ? "On" : "Off"); } break; case 0xb0: @@ -985,10 +986,11 @@ void InterruptDebugging(bool Emu, const void* _pData) case WM_SPEAKER_MUTE: // 0x19 if (g_DebugComm) Name.append("WM_SPEAKER"); size = 1; - if(data[1] == 0x14) - Console::Print("\nSpeaker %s\n\n", (data[2] == 0x06) ? "On" : "Off"); - else if(data[1] == 0x19) - Console::Print("\nSpeaker %s\n\n", (data[2] == 0x06) ? "Muted" : "Unmuted"); + if(data[1] == 0x14) { + INFO_LOG(CONSOLE, "\nSpeaker %s\n\n", (data[2] == 0x06) ? "On" : "Off"); + } else if(data[1] == 0x19) { + INFO_LOG(CONSOLE, "\nSpeaker %s\n\n", (data[2] == 0x06) ? "Muted" : "Unmuted"); + } break; case WM_WRITE_SPEAKER_DATA: // 0x18 if (g_DebugComm) Name.append("WM_SPEAKER_DATA"); @@ -997,22 +999,22 @@ void InterruptDebugging(bool Emu, const void* _pData) default: size = 15; - Console::Print("%s InterruptDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]); + INFO_LOG(CONSOLE, "%s InterruptDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]); break; } if (g_DebugComm && !SoundData) { std::string Temp = ArrayToString(data, size + 2, 0, 30); //LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str()); - Console::Print("%s: %s\n", Name.c_str(), Temp.c_str()); // No timestamp - //Console::Print(" (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp + INFO_LOG(CONSOLE, "%s: %s\n", Name.c_str(), Temp.c_str()); // No timestamp + //INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp } if (g_DebugSoundData && SoundData) { std::string Temp = ArrayToString(data, size + 2, 0, 30); //LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str()); - Console::Print("%s: %s\n", Name.c_str(), Temp.c_str()); // No timestamp - //Console::Print(" (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp + INFO_LOG(CONSOLE, "%s: %s\n", Name.c_str(), Temp.c_str()); // No timestamp + //INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp } } @@ -1058,7 +1060,7 @@ int GetUpdateRate() // Calculate the time and save it int Time = (int)(10 / (GetDoubleTime() - g_UpdateTime)); g_UpdateTimeList.push_back(Time); - //Console::Print("Time: %i %f\n", Time, GetDoubleTime()); + //INFO_LOG(CONSOLE, "Time: %i %f\n", Time, GetDoubleTime()); int TotalTime = 0; for (int i = 0; i < (int)g_UpdateTimeList.size(); i++) @@ -1099,31 +1101,3 @@ void DoInitialize() } -//****************************************************************************** -// Logging functions -//****************************************************************************** - -void __Log(int log, const char *_fmt, ...) -{ - char Msg[512]; - va_list ap; - - va_start( ap, _fmt ); - vsprintf( Msg, _fmt, ap ); - va_end( ap ); - - g_WiimoteInitialize.pLog(Msg, 0); -} - - -void __Logv(int log, int v, const char *_fmt, ...) -{ - char Msg[512]; - va_list ap; - - va_start( ap, _fmt ); - vsprintf( Msg, _fmt, ap ); - va_end( ap ); - - g_WiimoteInitialize.pLog(Msg, v); -} diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index 4633549ca9..8d4481e8a2 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -41,7 +41,6 @@ int GetUpdateRate(); void InterruptDebugging(bool Emu, const void* _pData); void ReadDebugging(bool Emu, const void* _pData, int Size); bool IsFocus(); -void OpenConsole(bool Open = false); // Movement recording diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 01a5be326b..224a9db245 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -27,7 +27,6 @@ #include "Common.h" #include "Thread.h" #include "StringUtil.h" -#include "ConsoleWindow.h" #include "Timer.h" #include "pluginspecs_wiimote.h" @@ -129,7 +128,7 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size) // Debugging //std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30); - //Console::Print("Wiimote Write:\n%s\n", Temp.c_str()); + //INFO_LOG(CONSOLE, "Wiimote Write:\n%s\n", Temp.c_str()); } m_pCriticalSection->Leave(); } @@ -146,7 +145,7 @@ void ReadData() // Send data to the Wiimote if (!m_EventWriteQueue.empty()) { - //Console::Print("Writing data to the Wiimote\n"); + //INFO_LOG(CONSOLE, "Writing data to the Wiimote\n"); SEvent& rEvent = m_EventWriteQueue.front(); wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, MAX_PAYLOAD); m_EventWriteQueue.pop(); @@ -194,7 +193,7 @@ void ReadData() //if(GetAsyncKeyState('V')) { std::string Temp = ArrayToString(pBuffer, 20, 0, 30); - Console::Print("Data: %s\n", Temp.c_str()); + INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str()); } */ #endif } @@ -309,7 +308,7 @@ void SendAcc(u8 _ReportID) wiiuse_io_write(WiiMoteReal::g_WiiMotesFromWiiUse[0], (byte*)DataAcc, MAX_PAYLOAD); std::string Temp = ArrayToString(DataAcc, 28, 0, 30); - Console::Print("SendAcc: %s\n", Temp.c_str()); + INFO_LOG(CONSOLE, "SendAcc: %s\n", Temp.c_str()); //22 00 00 _reportID 00 } @@ -348,7 +347,7 @@ int Initialize() g_WiiMotesFromWiiUse = wiiuse_init(MAX_WIIMOTES); g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5); if (g_NumberOfWiiMotes > 0) g_RealWiiMotePresent = true; - Console::Print("Found No of Wiimotes: %i\n", g_NumberOfWiiMotes); + INFO_LOG(CONSOLE, "Found No of Wiimotes: %i\n", g_NumberOfWiiMotes); // Remove the wiiuse_poll() threshold wiiuse_set_accel_threshold(g_WiiMotesFromWiiUse[0], 0); @@ -362,7 +361,7 @@ int Initialize() // I don't seem to need wiiuse_connect() in Windows. But Linux needs it. #ifndef _WIN32 int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); - Console::Print("Connected: %i\n", Connect); + INFO_LOG(CONSOLE, "Connected: %i\n", Connect); #endif // If we are connecting from the config window without a game running we flash the lights @@ -431,13 +430,13 @@ void Shutdown(void) void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) { - //Console::Print("Real InterruptChannel\n"); + //INFO_LOG(CONSOLE, "Real InterruptChannel\n"); g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size); } void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) { - //Console::Print("Real ControlChannel\n"); + //INFO_LOG(CONSOLE, "Real ControlChannel\n"); g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size); } @@ -447,7 +446,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) // --------------- void Update() { - //Console::Print("Real Update\n"); + //INFO_LOG(CONSOLE, "Real Update\n"); for (int i = 0; i < g_NumberOfWiiMotes; i++) { g_WiiMotes[i]->Update(); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj index c60bd2b195..65adfc3788 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj +++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj @@ -1,7 +1,7 @@ LogMsg("Saved: %s %i\n", SectionName.c_str(), PadMapping[i].triggertype); } - Console::Print("%i: Save: %i\n", 0, PadMapping[0].halfpress); + INFO_LOG(CONSOLE, "%i: Save: %i\n", 0, PadMapping[0].halfpress); file.Save(FULL_CONFIG_DIR "nJoy.ini"); } @@ -272,6 +272,6 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID) //if(m_frame) m_frame->LogMsg("%i: Enabled: %i\n", i, PadMapping[i].buttons[CTL_X_BUTTON]); } - Console::Print("%i: Load: %i\n", 0, PadMapping[0].halfpress); + INFO_LOG(CONSOLE, "%i: Load: %i\n", 0, PadMapping[0].halfpress); } diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index fd8911a799..903ed5bc3c 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -605,7 +605,7 @@ void ConfigBox::OnPaint( wxPaintEvent &event ) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void ConfigBox::CreateGUIControls() { - Console::Print("CreateGUIControls()\n"); + INFO_LOG(CONSOLE, "CreateGUIControls()\n"); #ifndef _DEBUG SetTitle(wxT("Configure: nJoy v"INPUT_VERSION" Input Plugin")); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp index 93fcbe08ca..7f9bb14f8d 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp @@ -279,7 +279,7 @@ void ConfigBox::DoGetButtons(int GetId) int Axes = SDL_JoystickNumAxes(joy); int Hats = SDL_JoystickNumHats(joy); - Console::Print("PadID: %i Axes: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy); + INFO_LOG(CONSOLE, "PadID: %i Axes: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy); // Get the controller and trigger type int ControllerType = PadMapping[Controller].controllertype; @@ -316,7 +316,7 @@ void ConfigBox::DoGetButtons(int GetId) bool Stop = false; // Stop the timer // ======================= - //Console::Print("Before (%i) Id:%i %i IsRunning:%i\n", + //INFO_LOG(CONSOLE, "Before (%i) Id:%i %i IsRunning:%i\n", // GetButtonWaitingTimer, GetButtonWaitingID, GetId, m_ButtonMappingTimer->IsRunning()); // If the Id has changed or the timer is not running we should start one @@ -426,7 +426,7 @@ void ConfigBox::DoGetButtons(int GetId) // Debugging /* - Console::Print("Change: %i %i %i %i '%s' '%s' '%s' '%s'\n", + INFO_LOG(CONSOLE, "Change: %i %i %i %i '%s' '%s' '%s' '%s'\n", PadMapping[0].halfpress, PadMapping[1].halfpress, PadMapping[2].halfpress, PadMapping[3].halfpress, m_JoyButtonHalfpress[0]->GetValue().c_str(), m_JoyButtonHalfpress[1]->GetValue().c_str(), m_JoyButtonHalfpress[2]->GetValue().c_str(), m_JoyButtonHalfpress[3]->GetValue().c_str() );*/ diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 208bf8a329..cd0f900cc6 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -93,10 +93,7 @@ int NumPads = 0, NumGoodPads = 0, LastPad = 0; HWND m_hWnd = NULL, m_hConsole = NULL; // Handle to window #endif SPADInitialize *g_PADInitialize = NULL; - -// TODO: fix this dirty hack to stop missing symbols -void __Log(int log, const char *format, ...) {} -void __Logv(int log, int v, const char *format, ...) {} +PLUGIN_GLOBALS* globals = NULL; // Rumble #ifdef _WIN32 @@ -182,17 +179,22 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo) #endif } -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {} +void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +{ + globals = _pPluginGlobals; + LogManager::SetInstance((LogManager *)globals->logManager); +} + // Call config dialog // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void DllConfig(HWND _hParent) { // Debugging - #ifdef SHOW_PAD_STATUS - Console::Open(100); - m_hConsole = Console::GetHwnd(); - #endif + // #ifdef SHOW_PAD_STATUS + // Console::Open(100); + // m_hConsole = Console::GetHwnd(); + // #endif #ifdef _WIN32 // Start the pads so we can use them in the configuration and advanced controls @@ -240,11 +242,11 @@ void DllDebugger(HWND _hParent, bool Show) {} void Initialize(void *init) { // Debugging - #ifdef SHOW_PAD_STATUS - Console::Open(110); - m_hConsole = Console::GetHwnd(); - #endif - Console::Print("Initialize: %i\n", SDL_WasInit(0)); + // #ifdef SHOW_PAD_STATUS + // Console::Open(110); + // m_hConsole = Console::GetHwnd(); + // #endif + INFO_LOG(CONSOLE, "Initialize: %i\n", SDL_WasInit(0)); g_PADInitialize = (SPADInitialize*)init; g_EmulatorRunning = true; @@ -277,7 +279,7 @@ void Initialize(void *init) Called from: The Dolphin Core, ConfigBox::OnClose() */ void Shutdown() { - Console::Print("Shutdown: %i\n", SDL_WasInit(0)); + INFO_LOG(CONSOLE, "Shutdown: %i\n", SDL_WasInit(0)); // ------------------------------------------- // Play back input instead of accepting any user input @@ -358,7 +360,7 @@ void PAD_Input(u16 _Key, u8 _UpDown) } // Debugging - //Console::Print("%i", _Key); + //INFO_LOG(CONSOLE, "%i", _Key); } @@ -385,7 +387,7 @@ unsigned int PAD_GetAttachedPads() if (PadMapping[2].enabled) connected |= 4; if (PadMapping[3].enabled) connected |= 8; - //Console::Print("PAD_GetAttachedPads: %i %i %i %i\n", PadMapping[0].enabled, PadMapping[1].enabled, PadMapping[2].enabled, PadMapping[3].enabled); + //INFO_LOG(CONSOLE, "PAD_GetAttachedPads: %i %i %i %i\n", PadMapping[0].enabled, PadMapping[1].enabled, PadMapping[2].enabled, PadMapping[3].enabled); return connected; } @@ -397,7 +399,7 @@ unsigned int PAD_GetAttachedPads() // Function: Gives the current pad status to the Core void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) { - //Console::Print("PAD_GetStatus(): %i %i %i\n", _numPAD, PadMapping[_numPAD].enabled, PadState[_numPAD].joy); + //INFO_LOG(CONSOLE, "PAD_GetStatus(): %i %i %i\n", _numPAD, PadMapping[_numPAD].enabled, PadState[_numPAD].joy); /* Check if the pad is enabled and avaliable, currently we don't disable pads just because they are disconnected */ @@ -561,10 +563,10 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) // Debugging /* // Show the status of all connected pads - if ((LastPad == 0 && _numPAD == 0) || _numPAD < LastPad) Console::ClearScreen(); +// if ((LastPad == 0 && _numPAD == 0) || _numPAD < LastPad) Console::ClearScreen(); LastPad = _numPAD; - Console::ClearScreen(); - Console::Print( +// Console::ClearScreen(); + INFO_LOG(CONSOLE, "Pad | Number:%i Enabled:%i Handle:%i\n" "Trigger | StatusL:%04x StatusR:%04x TriggerL:%04x TriggerR:%04x TriggerValue:%i\n" "Buttons | Overall:%i A:%i X:%i\n" @@ -641,7 +643,7 @@ bool ReloadDLL() // Close SDL if (SDL_WasInit(0)) SDL_Quit(); // Log message - Console::Print("Error: %s\n", StrError.c_str()); + INFO_LOG(CONSOLE, "Error: %s\n", StrError.c_str()); return true; } } diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h index 0ac834989b..1b1241adce 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h @@ -57,8 +57,6 @@ #include "Setup.h" #include "pluginspecs_pad.h" #include "IniFile.h" -#include "ConsoleWindow.h" -//#include "Timer.h" #include "Config.h" // Local diff --git a/Source/Plugins/Plugin_nJoy_Testing/Plugin_nJoy_SDL_Test.vcproj b/Source/Plugins/Plugin_nJoy_Testing/Plugin_nJoy_SDL_Test.vcproj index efd42c4a45..5394f8d92b 100644 --- a/Source/Plugins/Plugin_nJoy_Testing/Plugin_nJoy_SDL_Test.vcproj +++ b/Source/Plugins/Plugin_nJoy_Testing/Plugin_nJoy_SDL_Test.vcproj @@ -66,7 +66,7 @@ /> logManager); } + // Call config dialog // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void DllConfig(HWND _hParent)