Convert win32 to use new logging facility

This commit is contained in:
Azamat H. Hackimov
2024-08-25 00:01:37 +03:00
parent 83ff0eef99
commit cc61f5de31
4 changed files with 27 additions and 30 deletions

View File

@@ -10,6 +10,8 @@ add_dependencies(win32 get_git_hash)
target_include_directories(win32 PRIVATE ${PROJECT_BINARY_DIR}/lib) target_include_directories(win32 PRIVATE ${PROJECT_BINARY_DIR}/lib)
target_compile_definitions(win32 PRIVATE DX_APP) target_compile_definitions(win32 PRIVATE DX_APP)
target_link_libraries(win32 PRIVATE target_link_libraries(win32 PRIVATE
ddebug
ddio ddio
misc misc
plog::plog
) )

View File

@@ -320,6 +320,7 @@
#include "joystick.h" #include "joystick.h"
#include "Macros.h" #include "Macros.h"
#include "inffile.h" #include "inffile.h"
#include "log.h"
// Sorry! This is needed for the semi-hacky mouselook support // Sorry! This is needed for the semi-hacky mouselook support
#include "descent.h" #include "descent.h"
@@ -536,7 +537,6 @@ ct_config_data gameWinController::get_controller_value(ct_type type_req) {
case ctMouseButton: case ctMouseButton:
for (j = 0; j < CT_MAX_BUTTONS; j++) { for (j = 0; j < CT_MAX_BUTTONS; j++) {
if (ddio_MouseBtnUpCount(j)) { if (ddio_MouseBtnUpCount(j)) {
// mprintf(0, "MseBtn %d down\n", j);
val = MAKE_CONFIG_DATA(CONTROLLER_CTL_INFO(1, NULL_CONTROLLER), CONTROLLER_CTL_VALUE(j + 1, NULL_BINDING)); val = MAKE_CONFIG_DATA(CONTROLLER_CTL_INFO(1, NULL_CONTROLLER), CONTROLLER_CTL_VALUE(j + 1, NULL_BINDING));
return val; return val;
} }
@@ -554,7 +554,7 @@ ct_config_data gameWinController::get_controller_value(ct_type type_req) {
: (m_ControlList[i].sens[CT_V_AXIS - 1] > 1.0f) ? 0.80f : (m_ControlList[i].sens[CT_V_AXIS - 1] > 1.0f) ? 0.80f
: (m_ControlList[i].sens[CT_V_AXIS - 1] / 2); : (m_ControlList[i].sens[CT_V_AXIS - 1] / 2);
pos = get_axis_value(i, CT_V_AXIS, ctAnalog); pos = get_axis_value(i, CT_V_AXIS, ctAnalog);
mprintf(0, "pos=%.2f\n", pos); LOG_DEBUG.printf("pos=%.2f", pos);
if (fabs(pos) > limit) if (fabs(pos) > limit)
val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_V_AXIS, NULL_BINDING)); val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_V_AXIS, NULL_BINDING));
} }
@@ -629,13 +629,11 @@ ct_config_data gameWinController::get_controller_value(ct_type type_req) {
} }
if (m_ControlList[i].flags & CTF_Y_AXIS) { if (m_ControlList[i].flags & CTF_Y_AXIS) {
pos = get_axis_value(i, CT_Y_AXIS, ctAnalog); pos = get_axis_value(i, CT_Y_AXIS, ctAnalog);
// mprintf(0, "y=%.2f ", pos);
if (fabs(pos) >= 0.90f) if (fabs(pos) >= 0.90f)
val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_Y_AXIS, NULL_BINDING)); val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_Y_AXIS, NULL_BINDING));
} }
if (m_ControlList[i].flags & CTF_X_AXIS) { if (m_ControlList[i].flags & CTF_X_AXIS) {
pos = get_axis_value(i, CT_X_AXIS, ctAnalog); pos = get_axis_value(i, CT_X_AXIS, ctAnalog);
// mprintf(0, "x=%.2f\n", pos);
if (fabs(pos) >= 0.90f) if (fabs(pos) >= 0.90f)
val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_X_AXIS, NULL_BINDING)); val = MAKE_CONFIG_DATA(ctl, CONTROLLER_CTL_VALUE(CT_X_AXIS, NULL_BINDING));
} }
@@ -903,7 +901,7 @@ float gameWinController::get_axis_value(int8_t controller, uint8_t axis, ct_form
val -= 1.0f; val -= 1.0f;
} else { } else {
val = 0.0f; val = 0.0f;
mprintf(1, "gameController::axis unsupported format for function.\n"); LOG_DEBUG << "gameController::axis unsupported format for function.";
} }
ct_packet key_slide1, key_bank; ct_packet key_slide1, key_bank;
@@ -1046,7 +1044,7 @@ float gameWinController::get_button_value(int8_t controller, ct_format format, u
break; break;
default: default:
mprintf(1, "gameController::button unsupported format for function\n"); LOG_WARNING << "gameController::button unsupported format for function";
} }
return val; return val;
@@ -1113,7 +1111,7 @@ float gameWinController::get_pov_value(int8_t controller, ct_format format, uint
break; break;
default: default:
mprintf(1, "gameController::pov unsupported format for function\n"); LOG_WARNING << "gameController::pov unsupported format for function";
} }
return val; return val;
@@ -1141,7 +1139,7 @@ float gameWinController::get_key_value(int key, ct_format format) {
break; break;
default: default:
mprintf(1, "gameController::key unsupported format for function\n"); LOG_WARNING << "gameController::key unsupported format for function";
} }
return val; return val;
@@ -1381,7 +1379,7 @@ bool gameWinController::enum_controllers(char *remote_adr) {
} }
m_ControlList[num_devs].deadzone = JOY_DEADZONE; m_ControlList[num_devs].deadzone = JOY_DEADZONE;
mprintf(0, "Controller %s found.\n", jc.name); LOG_INFO.printf("Controller %s found.", jc.name);
// okay, now search for a '****.ctl' file in the current directory. // okay, now search for a '****.ctl' file in the current directory.
parse_ctl_file(num_devs, jc.name); parse_ctl_file(num_devs, jc.name);
@@ -1454,7 +1452,6 @@ void gameWinController::extctl_getpos(int id) {
if ((ji.buttons & (1 << i)) && !(m_ExtCtlStates[id].buttons & (1 << i))) { if ((ji.buttons & (1 << i)) && !(m_ExtCtlStates[id].buttons & (1 << i))) {
m_ExtCtlStates[id].btnpresses[i]++; m_ExtCtlStates[id].btnpresses[i]++;
m_ExtCtlStates[id].btnstarts[i] = timer_val; m_ExtCtlStates[id].btnstarts[i] = timer_val;
// mprintf(0, "Start time for %d = %f\n", i, timer_val);
} }
if (ji.buttons & (1 << i)) // if button is down if (ji.buttons & (1 << i)) // if button is down
@@ -1484,8 +1481,6 @@ void gameWinController::mouse_geteval() {
m_MseState.m_absX = x; m_MseState.m_absX = x;
m_MseState.m_absY = y; m_MseState.m_absY = y;
m_MseState.m_buttonMask = btnmask; m_MseState.m_buttonMask = btnmask;
mprintf_at(1, 5, 30, "btnmask=%08d\n", btnmask);
} }
// gets sensitivity of axis item // gets sensitivity of axis item

View File

@@ -149,7 +149,8 @@
#include "Application.h" #include "Application.h"
#include "AppConsole.h" #include "AppConsole.h"
#include "mono.h" #include "debugbreak.h"
#include "log.h"
#include "networking.h" #include "networking.h"
#include <shellapi.h> #include <shellapi.h>
@@ -234,7 +235,7 @@ oeWin32Application::oeWin32Application(const char *name, unsigned flags, HInstan
#endif #endif
if (!RegisterClass(&wc)) { if (!RegisterClass(&wc)) {
mprintf(0, "Failure to register window class (err:%x).\n", GetLastError()); LOG_ERROR.printf("Failure to register window class (err:%x).", GetLastError());
return; return;
} }
@@ -353,7 +354,7 @@ void oeWin32Application::init() {
if (m_hWnd == NULL) { if (m_hWnd == NULL) {
DWORD err = GetLastError(); DWORD err = GetLastError();
mprintf(0, "Failed to create game window (err: %x)\n", err); LOG_ERROR.printf("Failed to create game window (err: %x)", err);
return; return;
} }
@@ -401,7 +402,7 @@ int oeWin32Application::defer_block() {
// QUIT APP. // QUIT APP.
exit(1); exit(1);
} else if (msg.message == WM_MOVE) { } else if (msg.message == WM_MOVE) {
mprintf(0, "move msg\n"); LOG_DEBUG << "move msg";
} }
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
@@ -416,7 +417,7 @@ int oeWin32Application::defer_block() {
if (this->active()) { if (this->active()) {
#ifndef _DEBUG #ifndef _DEBUG
if (GetForegroundWindow() != (HWND)this->m_hWnd && !(m_Flags & OEAPP_CONSOLE)) { if (GetForegroundWindow() != (HWND)this->m_hWnd && !(m_Flags & OEAPP_CONSOLE)) {
mprintf(0, "forcing this window into the foreground.\n"); LOG_DEBUG << "forcing this window into the foreground.";
SetForegroundWindow((HWND)this->m_hWnd); SetForegroundWindow((HWND)this->m_hWnd);
} }
#endif #endif
@@ -466,11 +467,11 @@ void oeWin32Application::os_init() {
#ifdef _DEBUG #ifdef _DEBUG
if (os == Win9x) { if (os == Win9x) {
mprintf(0, "Win9x system\n"); LOG_DEBUG << "Win9x system";
} else if (os == WinNT) { } else if (os == WinNT) {
mprintf(0, "WinNT %d.%d.%d system\n", major, minor, build); LOG_DEBUG.printf( "WinNT %d.%d.%d system", major, minor, build);
} else { } else {
mprintf(0, "Win32 non-standard operating system\n"); LOG_DEBUG << "Win32 non-standard operating system";
} }
#endif #endif
@@ -541,7 +542,6 @@ LResult oeWin32Application::WndProc(HWnd hwnd, unsigned msg, WParam wParam, LPar
switch (msg) { switch (msg) {
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
m_AppActive = wParam ? true : false; m_AppActive = wParam ? true : false;
// mprintf(0, "WM_ACTIVATEAPP (%u,%l)\n", wParam, lParam);
break; break;
} }
@@ -679,7 +679,7 @@ LRESULT WINAPI MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
break; break;
case WM_POWERBROADCAST: // Won't allow OS to suspend operation for now. case WM_POWERBROADCAST: // Won't allow OS to suspend operation for now.
mprintf(0, "WM_POWERBROADCAST=%u,%d\n", wParam, lParam); LOG_DEBUG.printf("WM_POWERBROADCAST=%u,%d", wParam, lParam);
if (wParam == PBT_APMQUERYSUSPEND) { if (wParam == PBT_APMQUERYSUSPEND) {
return BROADCAST_QUERY_DENY; return BROADCAST_QUERY_DENY;
} }

View File

@@ -73,7 +73,7 @@
#include <windows.h> #include <windows.h>
#include <assert.h> #include <assert.h>
#include "mono.h" #include "log.h"
#include "pserror.h" #include "pserror.h"
// Construction and destruction. // Construction and destruction.
@@ -91,7 +91,7 @@ oeWin32AppDatabase::oeWin32AppDatabase() {
if (!res) { if (!res) {
res = create_record(m_Basepath); res = create_record(m_Basepath);
if (!res) { if (!res) {
mprintf(1, "Unable to create registry directory.\n"); LOG_WARNING << "Unable to create registry directory.";
} }
} }
} }
@@ -120,7 +120,7 @@ bool oeWin32AppDatabase::create_record(const char *pathname) {
lres = RegCreateKeyEx((HKEY)hBaseKey, pathname, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &disp); lres = RegCreateKeyEx((HKEY)hBaseKey, pathname, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &disp);
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to create key %s (%x)\n", pathname, lres); LOG_WARNING.printf("Unable to create key %s (%x)", pathname, lres);
return 0; return 0;
} }
@@ -142,7 +142,7 @@ bool oeWin32AppDatabase::lookup_record(const char *pathname) {
lres = RegOpenKeyEx((HKEY)hBaseKey, pathname, 0, KEY_READ | KEY_WRITE | KEY_EXECUTE, &hkey); lres = RegOpenKeyEx((HKEY)hBaseKey, pathname, 0, KEY_READ | KEY_WRITE | KEY_EXECUTE, &hkey);
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to open key %s (%x)\n", pathname, lres); LOG_WARNING.printf("Unable to open key %s (%x)", pathname, lres);
return 0; return 0;
} }
@@ -166,7 +166,7 @@ bool oeWin32AppDatabase::read(const char *label, char *entry, int *entrylen) {
assert(type != REG_DWORD); assert(type != REG_DWORD);
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to query str key %s (%x)\n", label, lres); LOG_WARNING.printf("Unable to query str key %s (%x)", label, lres);
return 0; return 0;
} }
return 1; return 1;
@@ -188,7 +188,7 @@ bool oeWin32AppDatabase::read(const char *label, void *entry, int wordsize) {
assert(len == 4); assert(len == 4);
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to query int key %s (%x)\n", label, lres); LOG_WARNING.printf("Unable to query int key %s (%x)", label, lres);
return 0; return 0;
} }
@@ -234,7 +234,7 @@ bool oeWin32AppDatabase::write(const char *label, const char *entry, int entryle
lres = RegSetValueEx((HKEY)hCurKey, label, 0, REG_SZ, (LPBYTE)entry, entrylen); lres = RegSetValueEx((HKEY)hCurKey, label, 0, REG_SZ, (LPBYTE)entry, entrylen);
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to write str key %s (%x)\n", label, lres); LOG_WARNING.printf("Unable to write str key %s (%x)", label, lres);
return 0; return 0;
} }
return 1; return 1;
@@ -249,7 +249,7 @@ bool oeWin32AppDatabase::write(const char *label, int entry) {
lres = RegSetValueEx((HKEY)hCurKey, label, 0, REG_DWORD, (LPBYTE)&entry, sizeof(int)); lres = RegSetValueEx((HKEY)hCurKey, label, 0, REG_DWORD, (LPBYTE)&entry, sizeof(int));
if (lres != ERROR_SUCCESS) { if (lres != ERROR_SUCCESS) {
mprintf(1, "Unable to write int key %s (%x)\n", label, lres); LOG_WARNING.printf("Unable to write int key %s (%x)", label, lres);
return 0; return 0;
} }