Fixes and tuneup
* Reduce duplicate methods perform same task into one simple function. * Use EmuShared to obtain updated log settings instead of WM_COPYDATA message. * FIXED: Set log config for second GUI process * FIXED: Proper update logging config to EmuShared instead of repeatly send when it is indeed in use. * Without this fix, it will affect other GUI process emulating a title.
This commit is contained in:
parent
54f95fc33b
commit
8c31d5e24e
|
@ -36,7 +36,9 @@
|
||||||
|
|
||||||
#include <windows.h> // for PULONG
|
#include <windows.h> // for PULONG
|
||||||
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
#include "Common/Settings.hpp"
|
||||||
|
#include "CxbxKrnl/EmuShared.h"
|
||||||
|
|
||||||
// For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration
|
// For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration
|
||||||
// TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html
|
// TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html
|
||||||
|
@ -102,7 +104,35 @@ const char* g_EnumModules2String[to_underlying(CXBXR_MODULE::MAX)] = {
|
||||||
"XC ",
|
"XC ",
|
||||||
"XE ",
|
"XE ",
|
||||||
};
|
};
|
||||||
std::atomic_int g_CurrentLogLevel = to_underlying(LOG_LEVEL::INFO);
|
std::atomic_int g_CurrentLogLevel = to_underlying(LOG_LEVEL::INFO);
|
||||||
|
|
||||||
|
// Set up the logging variables for the GUI process
|
||||||
|
inline void get_log_settings()
|
||||||
|
{
|
||||||
|
set_log_config(g_Settings->m_core.LogLevel, g_Settings->m_core.LoggedModules);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void sync_log_config()
|
||||||
|
{
|
||||||
|
int LogLevel;
|
||||||
|
uint LoggedModules[NUM_INTEGERS_LOG];
|
||||||
|
g_EmuShared->GetLogLv(&LogLevel);
|
||||||
|
g_EmuShared->GetLogModules(LoggedModules);
|
||||||
|
set_log_config(LogLevel, LoggedModules);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_log_config(int LogLevel, uint* LoggedModules)
|
||||||
|
{
|
||||||
|
g_CurrentLogLevel = LogLevel;
|
||||||
|
for (int index = to_underlying(CXBXR_MODULE::CXBXR); index < to_underlying(CXBXR_MODULE::MAX); index++) {
|
||||||
|
if (LoggedModules[index / 32] & (1 << (index % 32))) {
|
||||||
|
g_EnabledModules[index] = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_EnabledModules[index] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const bool needs_escape(const wint_t _char)
|
const bool needs_escape(const wint_t _char)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,6 +118,12 @@ typedef enum class _CXBXR_MODULE {
|
||||||
extern std::atomic_bool g_EnabledModules[to_underlying(CXBXR_MODULE::MAX)];
|
extern std::atomic_bool g_EnabledModules[to_underlying(CXBXR_MODULE::MAX)];
|
||||||
extern const char* g_EnumModules2String[to_underlying(CXBXR_MODULE::MAX)];
|
extern const char* g_EnumModules2String[to_underlying(CXBXR_MODULE::MAX)];
|
||||||
extern std::atomic_int g_CurrentLogLevel;
|
extern std::atomic_int g_CurrentLogLevel;
|
||||||
|
|
||||||
|
extern inline void get_log_settings();
|
||||||
|
|
||||||
|
extern inline void sync_log_config();
|
||||||
|
|
||||||
|
void set_log_config(int LogLevel, uint* LoggedModules);
|
||||||
|
|
||||||
//
|
//
|
||||||
// __FILENAME__
|
// __FILENAME__
|
||||||
|
|
|
@ -239,33 +239,15 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
g_Settings->m_core.LoggedModules[1] = LoggedModules[1];
|
g_Settings->m_core.LoggedModules[1] = LoggedModules[1];
|
||||||
g_Settings->m_core.LogLevel = LogLevel;
|
g_Settings->m_core.LogLevel = LogLevel;
|
||||||
|
|
||||||
// This is necessary because otherwise relaunched xbe's in multi-xbe titles will still use the old settings
|
|
||||||
g_EmuShared->SetLogLv(&LogLevel);
|
|
||||||
g_EmuShared->SetLogModules(LoggedModules);
|
|
||||||
|
|
||||||
// Update the logging variables for the GUI process
|
// Update the logging variables for the GUI process
|
||||||
g_CurrentLogLevel = LogLevel;
|
set_log_config(LogLevel, LoggedModules);
|
||||||
for (int index = to_underlying(CXBXR_MODULE::CXBXR); index < to_underlying(CXBXR_MODULE::MAX); index++) {
|
|
||||||
if (LoggedModules[index / 32] & (1 << (index % 32))) {
|
|
||||||
g_EnabledModules[index] = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g_EnabledModules[index] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Also inform the kernel process if it exists
|
// Also inform the kernel process if it exists
|
||||||
if (g_ChildWnd) {
|
if (g_ChildWnd) {
|
||||||
COPYDATASTRUCT CopyData;
|
// Sync updated log to kernel process to use run-time settings.
|
||||||
LogData Data;
|
g_EmuShared->SetLogLv(&LogLevel);
|
||||||
Data.Level = LogLevel;
|
g_EmuShared->SetLogModules(LoggedModules);
|
||||||
for (int i = 0; i < NUM_INTEGERS_LOG; i++) {
|
SendMessage(g_ChildWnd, WM_COMMAND, MAKEWPARAM(ID_SYNC_CONFIG_LOGGING, 0), 0);
|
||||||
Data.LoggedModules[i] = LoggedModules[i];
|
|
||||||
}
|
|
||||||
CopyData.dwData = LOG_ID;
|
|
||||||
CopyData.cbData = sizeof(LogData);
|
|
||||||
CopyData.lpData = &Data;
|
|
||||||
SendMessage(g_ChildWnd, WM_COPYDATA, reinterpret_cast<WPARAM>(hWndDlg), reinterpret_cast<LPARAM>(&CopyData));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PostMessage(hWndDlg, WM_COMMAND, IDC_LOG_CANCEL, 0);
|
PostMessage(hWndDlg, WM_COMMAND, IDC_LOG_CANCEL, 0);
|
||||||
|
|
|
@ -351,6 +351,7 @@
|
||||||
#define ID_SETTINGS_CONFIG_DLOCCURDIR 40106
|
#define ID_SETTINGS_CONFIG_DLOCCURDIR 40106
|
||||||
#define ID_SETTINGS_ALLOWADMINPRIVILEGE 40107
|
#define ID_SETTINGS_ALLOWADMINPRIVILEGE 40107
|
||||||
#define ID_SETTINGS_CONFIG_LOGGING 40108
|
#define ID_SETTINGS_CONFIG_LOGGING 40108
|
||||||
|
#define ID_SYNC_CONFIG_LOGGING 40109
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
|
@ -358,7 +359,7 @@
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 135
|
#define _APS_NEXT_RESOURCE_VALUE 135
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40108
|
#define _APS_NEXT_COMMAND_VALUE 40110
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1256
|
#define _APS_NEXT_CONTROL_VALUE 1256
|
||||||
#define _APS_NEXT_SYMED_VALUE 104
|
#define _APS_NEXT_SYMED_VALUE 104
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -122,18 +122,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bKernel) {
|
get_log_settings();
|
||||||
// Set up the logging variables for the GUI process
|
|
||||||
g_CurrentLogLevel = g_Settings->m_core.LogLevel;
|
|
||||||
for (int index = to_underlying(CXBXR_MODULE::CXBXR); index < to_underlying(CXBXR_MODULE::MAX); index++) {
|
|
||||||
if (g_Settings->m_core.LoggedModules[index / 32] & (1 << (index % 32))) {
|
|
||||||
g_EnabledModules[index] = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g_EnabledModules[index] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bElevated = CxbxIsElevated();
|
bool bElevated = CxbxIsElevated();
|
||||||
|
|
||||||
|
@ -194,6 +183,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
EmuShared::Cleanup();
|
EmuShared::Cleanup();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_log_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
INITCOMMONCONTROLSEX icc;
|
INITCOMMONCONTROLSEX icc;
|
||||||
|
|
|
@ -927,17 +927,8 @@ void CxbxKrnlMain(int argc, char* argv[])
|
||||||
g_EmuShared->GetLogLv(&LogLevel);
|
g_EmuShared->GetLogLv(&LogLevel);
|
||||||
g_EmuShared->GetLogModules(LoggedModules);
|
g_EmuShared->GetLogModules(LoggedModules);
|
||||||
|
|
||||||
// Set up the logging variables for the kernel process during initialization. Note that we cannot use WM_COPYDATA here
|
// Set up the logging variables for the kernel process during initialization.
|
||||||
// because the child window doesn't exist yet at this point
|
set_log_config(LogLevel, LoggedModules);
|
||||||
g_CurrentLogLevel = LogLevel;
|
|
||||||
for (int index = to_underlying(CXBXR_MODULE::CXBXR); index < to_underlying(CXBXR_MODULE::MAX); index++) {
|
|
||||||
if (LoggedModules[index / 32] & (1 << (index % 32))) {
|
|
||||||
g_EnabledModules[index] = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g_EnabledModules[index] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CxbxKrnl_hEmuParent != NULL) {
|
if (CxbxKrnl_hEmuParent != NULL) {
|
||||||
|
|
|
@ -1587,28 +1587,14 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COPYDATA:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
COPYDATASTRUCT* pCopyData = reinterpret_cast<COPYDATASTRUCT*>(lParam);
|
switch (LOWORD(wParam))
|
||||||
switch (pCopyData->dwData)
|
|
||||||
{
|
{
|
||||||
case LOG_ID:
|
case ID_SYNC_CONFIG_LOGGING:
|
||||||
{
|
{
|
||||||
if (pCopyData->cbData == sizeof(LogData)) {
|
// Sync run-time config log settings from GUI process.
|
||||||
LogData Data = *reinterpret_cast<LogData*>(pCopyData->lpData);
|
sync_log_config();
|
||||||
g_CurrentLogLevel = Data.Level;
|
|
||||||
for (int index = to_underlying(CXBXR_MODULE::CXBXR); index < to_underlying(CXBXR_MODULE::MAX); index++) {
|
|
||||||
if (Data.LoggedModules[index / 32] & (1 << (index % 32))) {
|
|
||||||
g_EnabledModules[index] = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
g_EnabledModules[index] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
EmuLog(CXBXR_MODULE::GUI, LOG_LEVEL::WARNING, "COPYDATASTRUCT with id LOG_ID with abnormal size %zu", pCopyData->cbData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -55,13 +55,6 @@ enum {
|
||||||
BOOT_SKIP_ANIMATION = 1 << 2,
|
BOOT_SKIP_ANIMATION = 1 << 2,
|
||||||
BOOT_RUN_DASHBOARD = 1 << 3,
|
BOOT_RUN_DASHBOARD = 1 << 3,
|
||||||
BOOT_QUICK_REBOOT = 1 << 4,
|
BOOT_QUICK_REBOOT = 1 << 4,
|
||||||
};
|
|
||||||
|
|
||||||
// Log variables used by WM_COPYDATA
|
|
||||||
#define LOG_ID 1
|
|
||||||
struct LogData {
|
|
||||||
int Level;
|
|
||||||
uint LoggedModules[NUM_INTEGERS_LOG];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
Loading…
Reference in New Issue