aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r--src/frontend/qt_sdl/ArchiveUtil.cpp5
-rw-r--r--src/frontend/qt_sdl/CLI.cpp8
-rw-r--r--src/frontend/qt_sdl/CheatsDialog.cpp4
-rw-r--r--src/frontend/qt_sdl/InputConfig/MapButton.h3
-rw-r--r--src/frontend/qt_sdl/LAN_PCap.cpp27
-rw-r--r--src/frontend/qt_sdl/LocalMP.cpp13
-rw-r--r--src/frontend/qt_sdl/Platform.cpp17
-rw-r--r--src/frontend/qt_sdl/SaveManager.cpp6
-rw-r--r--src/frontend/qt_sdl/TitleManagerDialog.cpp10
9 files changed, 62 insertions, 31 deletions
diff --git a/src/frontend/qt_sdl/ArchiveUtil.cpp b/src/frontend/qt_sdl/ArchiveUtil.cpp
index fff1a94..b025aa8 100644
--- a/src/frontend/qt_sdl/ArchiveUtil.cpp
+++ b/src/frontend/qt_sdl/ArchiveUtil.cpp
@@ -19,6 +19,9 @@
#include "ArchiveUtil.h"
#include "Platform.h"
+using Platform::Log;
+using Platform::LogLevel;
+
namespace Archive
{
@@ -106,7 +109,7 @@ QVector<QString> ExtractFileFromArchive(QString path, QString wantedFile, QByteA
if (bytesRead < 0)
{
- printf("Error whilst reading archive: %s", archive_error_string(a));
+ Log(LogLevel::Error, "Error whilst reading archive: %s", archive_error_string(a));
return QVector<QString> {"Err", archive_error_string(a)};
}
diff --git a/src/frontend/qt_sdl/CLI.cpp b/src/frontend/qt_sdl/CLI.cpp
index 58e386e..9c19d79 100644
--- a/src/frontend/qt_sdl/CLI.cpp
+++ b/src/frontend/qt_sdl/CLI.cpp
@@ -25,6 +25,10 @@
#include <QStringList>
#include "CLI.h"
+#include "Platform.h"
+
+using Platform::Log;
+using Platform::LogLevel;
namespace CLI
{
@@ -55,7 +59,7 @@ CommandLineOptions* ManageArgs(QApplication& melon)
switch (posargs.size())
{
default:
- printf("Too many positional arguments; ignoring 3 onwards\n");
+ Log(LogLevel::Warn, "Too many positional arguments; ignoring 3 onwards\n");
case 2:
options->gbaRomPath = posargs[1];
case 1:
@@ -79,7 +83,7 @@ CommandLineOptions* ManageArgs(QApplication& melon)
}
else
{
- printf("ERROR: -b/--boot only accepts auto/always/never as arguments\n");
+ Log(LogLevel::Error, "ERROR: -b/--boot only accepts auto/always/never as arguments\n");
exit(1);
}
diff --git a/src/frontend/qt_sdl/CheatsDialog.cpp b/src/frontend/qt_sdl/CheatsDialog.cpp
index 4537df3..b15fab7 100644
--- a/src/frontend/qt_sdl/CheatsDialog.cpp
+++ b/src/frontend/qt_sdl/CheatsDialog.cpp
@@ -29,6 +29,8 @@
#include "CheatsDialog.h"
#include "ui_CheatsDialog.h"
+using Platform::Log;
+using Platform::LogLevel;
CheatsDialog* CheatsDialog::currentDlg = nullptr;
@@ -150,7 +152,7 @@ void CheatsDialog::on_btnNewARCode_clicked()
}
else
{
- printf("what?? :(\n");
+ Log(LogLevel::Warn, "what?? :(\n");
return;
}
diff --git a/src/frontend/qt_sdl/InputConfig/MapButton.h b/src/frontend/qt_sdl/InputConfig/MapButton.h
index afefed7..f90fa3f 100644
--- a/src/frontend/qt_sdl/InputConfig/MapButton.h
+++ b/src/frontend/qt_sdl/InputConfig/MapButton.h
@@ -24,6 +24,7 @@
#include <SDL2/SDL.h>
#include "Input.h"
+#include "Platform.h"
class KeyMapButton : public QPushButton
{
@@ -51,7 +52,7 @@ protected:
{
if (!isChecked()) return QPushButton::keyPressEvent(event);
- printf("KEY PRESSED = %08X %08X | %08X %08X %08X\n", event->key(), (int)event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode());
+ Platform::Log(Platform::Debug, "KEY PRESSED = %08X %08X | %08X %08X %08X\n", event->key(), (int)event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode());
int key = event->key();
int mod = event->modifiers();
diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp
index 86c218f..2a04e70 100644
--- a/src/frontend/qt_sdl/LAN_PCap.cpp
+++ b/src/frontend/qt_sdl/LAN_PCap.cpp
@@ -26,6 +26,7 @@
#include "../Wifi.h"
#include "LAN_PCap.h"
#include "Config.h"
+#include "Platform.h"
#ifdef __WIN32__
#include <iphlpapi.h>
@@ -41,6 +42,8 @@
#endif
#endif
+using Platform::Log;
+using Platform::LogLevel;
// welp
#ifndef PCAP_OPENFLAG_PROMISCUOUS
@@ -136,14 +139,14 @@ bool Init(bool open_adapter)
continue;
}
- printf("PCap: lib %s, init successful\n", PCapLibNames[i]);
+ Log(LogLevel::Info, "PCap: lib %s, init successful\n", PCapLibNames[i]);
PCapLib = lib;
break;
}
if (PCapLib == NULL)
{
- printf("PCap: init failed\n");
+ Log(LogLevel::Error, "PCap: init failed\n");
return false;
}
}
@@ -155,7 +158,7 @@ bool Init(bool open_adapter)
ret = pcap_findalldevs(&alldevs, errbuf);
if (ret < 0 || alldevs == NULL)
{
- printf("PCap: no devices available\n");
+ Log(LogLevel::Warn, "PCap: no devices available\n");
return false;
}
@@ -202,7 +205,7 @@ bool Init(bool open_adapter)
}
if (uret != ERROR_SUCCESS)
{
- printf("GetAdaptersAddresses() shat itself: %08X\n", uret);
+ Log(LogLevel::Error, "GetAdaptersAddresses() shat itself: %08X\n", uret);
return false;
}
@@ -226,7 +229,7 @@ bool Init(bool open_adapter)
if (addr->PhysicalAddressLength != 6)
{
- printf("weird MAC addr length %d for %s\n", addr->PhysicalAddressLength, addr->AdapterName);
+ Log(LogLevel::Warn, "weird MAC addr length %d for %s\n", addr->PhysicalAddressLength, addr->AdapterName);
}
else
memcpy(adata->MAC, addr->PhysicalAddress, 6);
@@ -255,7 +258,7 @@ bool Init(bool open_adapter)
struct ifaddrs* addrs;
if (getifaddrs(&addrs) != 0)
{
- printf("getifaddrs() shat itself :(\n");
+ Log(LogLevel::Error, "getifaddrs() shat itself :(\n");
return false;
}
@@ -273,7 +276,7 @@ bool Init(bool open_adapter)
if (!curaddr->ifa_addr)
{
- printf("Device (%s) does not have an address :/\n", curaddr->ifa_name);
+ Log(LogLevel::Error, "Device (%s) does not have an address :/\n", curaddr->ifa_name);
curaddr = curaddr->ifa_next;
continue;
}
@@ -289,7 +292,7 @@ bool Init(bool open_adapter)
{
struct sockaddr_ll* sa = (sockaddr_ll*)curaddr->ifa_addr;
if (sa->sll_halen != 6)
- printf("weird MAC length %d for %s\n", sa->sll_halen, curaddr->ifa_name);
+ Log(LogLevel::Warn, "weird MAC length %d for %s\n", sa->sll_halen, curaddr->ifa_name);
else
memcpy(adata->MAC, sa->sll_addr, 6);
}
@@ -298,7 +301,7 @@ bool Init(bool open_adapter)
{
struct sockaddr_dl* sa = (sockaddr_dl*)curaddr->ifa_addr;
if (sa->sdl_alen != 6)
- printf("weird MAC length %d for %s\n", sa->sdl_alen, curaddr->ifa_name);
+ Log(LogLevel::Warn, "weird MAC length %d for %s\n", sa->sdl_alen, curaddr->ifa_name);
else
memcpy(adata->MAC, LLADDR(sa), 6);
}
@@ -326,7 +329,7 @@ bool Init(bool open_adapter)
PCapAdapter = pcap_open_live(dev->name, 2048, PCAP_OPENFLAG_PROMISCUOUS, 1, errbuf);
if (!PCapAdapter)
{
- printf("PCap: failed to open adapter %s\n", errbuf);
+ Log(LogLevel::Error, "PCap: failed to open adapter %s\n", errbuf);
return false;
}
@@ -334,7 +337,7 @@ bool Init(bool open_adapter)
if (pcap_setnonblock(PCapAdapter, 1, errbuf) < 0)
{
- printf("PCap: failed to set nonblocking mode\n");
+ Log(LogLevel::Error, "PCap: failed to set nonblocking mode\n");
pcap_close(PCapAdapter); PCapAdapter = NULL;
return false;
}
@@ -376,7 +379,7 @@ int SendPacket(u8* data, int len)
if (len > 2048)
{
- printf("LAN_SendPacket: error: packet too long (%d)\n", len);
+ Log(LogLevel::Error, "LAN_SendPacket: error: packet too long (%d)\n", len);
return 0;
}
diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp
index fb7ef7a..31801b7 100644
--- a/src/frontend/qt_sdl/LocalMP.cpp
+++ b/src/frontend/qt_sdl/LocalMP.cpp
@@ -36,7 +36,10 @@
#include "Config.h"
#include "LocalMP.h"
+#include "Platform.h"
+using Platform::Log;
+using Platform::LogLevel;
namespace LocalMP
{
@@ -239,10 +242,10 @@ bool Init()
if (!MPQueue->attach())
{
- printf("MP sharedmem doesn't exist. creating\n");
+ Log(LogLevel::Info, "MP sharedmem doesn't exist. creating\n");
if (!MPQueue->create(kQueueSize))
{
- printf("MP sharedmem create failed :(\n");
+ Log(LogLevel::Error, "MP sharedmem create failed :(\n");
return false;
}
@@ -285,7 +288,7 @@ bool Init()
LastHostID = -1;
- printf("MP comm init OK, instance ID %d\n", InstanceID);
+ Log(LogLevel::Info, "MP comm init OK, instance ID %d\n", InstanceID);
RecvTimeout = 25;
@@ -478,7 +481,7 @@ int RecvPacketGeneric(u8* packet, bool block, u64* timestamp)
if (pktheader.Magic != 0x4946494E)
{
- printf("PACKET FIFO OVERFLOW\n");
+ Log(LogLevel::Warn, "PACKET FIFO OVERFLOW\n");
PacketReadOffset = header->PacketWriteOffset;
SemReset(InstanceID);
MPQueue->unlock();
@@ -590,7 +593,7 @@ u16 RecvReplies(u8* packets, u64 timestamp, u16 aidmask)
if (pktheader.Magic != 0x4946494E)
{
- printf("REPLY FIFO OVERFLOW\n");
+ Log(LogLevel::Warn, "REPLY FIFO OVERFLOW\n");
ReplyReadOffset = header->ReplyWriteOffset;
SemReset(16+InstanceID);
MPQueue->unlock();
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp
index f9eaf42..6b48335 100644
--- a/src/frontend/qt_sdl/Platform.cpp
+++ b/src/frontend/qt_sdl/Platform.cpp
@@ -60,10 +60,10 @@ void IPCInit()
if (!IPCBuffer->attach())
{
- printf("IPC sharedmem doesn't exist. creating\n");
+ Log(LogLevel::Info, "IPC sharedmem doesn't exist. creating\n");
if (!IPCBuffer->create(1024))
{
- printf("IPC sharedmem create failed :(\n");
+ Log(LogLevel::Error, "IPC sharedmem create failed :(\n");
delete IPCBuffer;
IPCBuffer = nullptr;
return;
@@ -88,7 +88,7 @@ void IPCInit()
}
IPCBuffer->unlock();
- printf("IPC: instance ID %d\n", IPCInstanceID);
+ Log(LogLevel::Info, "IPC: instance ID %d\n", IPCInstanceID);
}
void IPCDeInit()
@@ -349,6 +349,17 @@ FILE* OpenLocalFile(std::string path, std::string mode)
return OpenFile(fullpath.toStdString(), mode, mode[0] != 'w');
}
+void Log(LogLevel level, const char* fmt, ...)
+{
+ if (fmt == nullptr)
+ return;
+
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
Thread* Thread_Create(std::function<void()> func)
{
QThread* t = QThread::create(func);
diff --git a/src/frontend/qt_sdl/SaveManager.cpp b/src/frontend/qt_sdl/SaveManager.cpp
index d9e2138..31d2a68 100644
--- a/src/frontend/qt_sdl/SaveManager.cpp
+++ b/src/frontend/qt_sdl/SaveManager.cpp
@@ -22,6 +22,8 @@
#include "SaveManager.h"
#include "Platform.h"
+using Platform::Log;
+using Platform::LogLevel;
SaveManager::SaveManager(std::string path) : QThread()
{
@@ -122,7 +124,7 @@ void SaveManager::CheckFlush()
SecondaryBufferLock->lock();
- printf("SaveManager: Flush requested\n");
+ Log(LogLevel::Info, "SaveManager: Flush requested\n");
if (SecondaryBufferLength != Length)
{
@@ -178,7 +180,7 @@ void SaveManager::FlushSecondaryBuffer(u8* dst, u32 dstLength)
FILE* f = Platform::OpenFile(Path, "wb");
if (f)
{
- printf("SaveManager: Written\n");
+ Log(LogLevel::Info, "SaveManager: Written\n");
fwrite(SecondaryBuffer, SecondaryBufferLength, 1, f);
fclose(f);
}
diff --git a/src/frontend/qt_sdl/TitleManagerDialog.cpp b/src/frontend/qt_sdl/TitleManagerDialog.cpp
index 7b54313..72d19ec 100644
--- a/src/frontend/qt_sdl/TitleManagerDialog.cpp
+++ b/src/frontend/qt_sdl/TitleManagerDialog.cpp
@@ -30,6 +30,8 @@
#include "ui_TitleManagerDialog.h"
#include "ui_TitleImportDialog.h"
+using Platform::Log;
+using Platform::LogLevel;
bool TitleManagerDialog::NANDInited = false;
TitleManagerDialog* TitleManagerDialog::currentDlg = nullptr;
@@ -262,7 +264,7 @@ void TitleManagerDialog::onImportTitleData()
QListWidgetItem* cur = ui->lstTitleList->currentItem();
if (!cur)
{
- printf("what??\n");
+ Log(LogLevel::Error, "what??\n");
return;
}
@@ -283,7 +285,7 @@ void TitleManagerDialog::onImportTitleData()
wantedsize = cur->data(Qt::UserRole+3).toUInt();
break;
default:
- printf("what??\n");
+ Log(LogLevel::Warn, "what??\n");
return;
}
@@ -332,7 +334,7 @@ void TitleManagerDialog::onExportTitleData()
QListWidgetItem* cur = ui->lstTitleList->currentItem();
if (!cur)
{
- printf("what??\n");
+ Log(LogLevel::Error, "what??\n");
return;
}
@@ -357,7 +359,7 @@ void TitleManagerDialog::onExportTitleData()
wantedsize = cur->data(Qt::UserRole+3).toUInt();
break;
default:
- printf("what??\n");
+ Log(LogLevel::Warn, "what??\n");
return;
}