diff --git a/src/main.cpp b/src/main.cpp index 0b8ff1e..e5eb5ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,11 +5,17 @@ int main(int argc, char *argv[]) { + qSetMessagePattern( + "[%{time h:mm:ss.zzz} %{if-category}%{category}: %{endif}%{type}] %{message}"); + + qInfo() << "App launched."; + QApplication a(argc, argv); QApplication::setStyle(QStyleFactory::create("Fusion")); QApplication::setOrganizationName("Kitswas"); QApplication::setOrganizationDomain("io.github.kitswas"); QApplication::setApplicationName("VirtualGamePad"); + MainWindow w; w.show(); return a.exec(); diff --git a/src/networking/executor.cpp b/src/networking/executor.cpp index 1c65cb5..4b74480 100644 --- a/src/networking/executor.cpp +++ b/src/networking/executor.cpp @@ -21,10 +21,20 @@ vgp_data_exchange_gamepad_reading parse_gamepad_state(const char *data, size_t l size_t decoded_octects = vgp_data_exchange_gamepad_reading_unmarshal(&reading, data, len); if (decoded_octects == 0) { - qDebug() << "Failed to deserialize data"; + qWarning() << "Failed to deserialize data"; return reading; } + // Log the gamepad state + qDebug() << "Gamepad state:" + << "\nButtons up: " << reading.buttons_up << "\nButtons down: " << reading.buttons_down + << "\nLeft trigger: " << reading.left_trigger + << "\nRight trigger: " << reading.right_trigger + << "\nLeft thumbstick x: " << reading.left_thumbstick_x + << "\nLeft thumbstick y: " << reading.left_thumbstick_y + << "\nRight thumbstick x: " << reading.right_thumbstick_x + << "\nRight thumbstick y: " << reading.right_thumbstick_y; + return reading; } diff --git a/src/networking/server.cpp b/src/networking/server.cpp index 7f24649..761df50 100644 --- a/src/networking/server.cpp +++ b/src/networking/server.cpp @@ -68,6 +68,7 @@ Server::~Server() isGamepadConnected = false; } tcpServer->close(); // And then close the server + qInfo() << "Server stopped."; tcpServer->deleteLater(); delete ui; } @@ -114,6 +115,7 @@ void Server::initServer() } }); connect(tcpServer, &QTcpServer::newConnection, this, &Server::handleConnection); + qInfo() << "Server started."; } void Server::handleConnection() @@ -127,13 +129,14 @@ void Server::handleConnection() : clientConnection->peerName(), clientConnection->peerAddress().toString(), QString::number(clientConnection->peerPort())); - qDebug() << connectionMessage; + qInfo().noquote() << connectionMessage; ui->clientLabel->setText(connectionMessage); tcpServer->pauseAccepting(); connect(clientConnection, &QAbstractSocket::disconnected, clientConnection, &QObject::deleteLater); connect(clientConnection, &QAbstractSocket::disconnected, this, [this]() { ui->clientLabel->setText(tr("No device connected")); + qInfo() << "Device disconnected."; isGamepadConnected = false; tcpServer->resumeAccepting(); }); @@ -142,23 +145,12 @@ void Server::handleConnection() void Server::serveClient() { - qDebug() << "Received: " << clientConnection->bytesAvailable() << "bytes"; + qInfo() << "Received: " << clientConnection->bytesAvailable() << "bytes"; QByteArray request = clientConnection->readAll(); qDebug() << "Request: " << request; - // vgp_data_exchange_message message; - // vgp_data_exchange_message_unmarshal(&message, request.constData(), request.size()); - // qDebug() << "Message: " << message.contents.utf8; vgp_data_exchange_gamepad_reading gamepad_reading = parse_gamepad_state(request.constData(), request.size()); - qDebug() << "Reading (Btn down): " << gamepad_reading.buttons_down; - qDebug() << "Reading (Btn up): " << gamepad_reading.buttons_up; - qDebug() << "Reading (Left trigger): " << gamepad_reading.left_trigger; - qDebug() << "Reading (Right trigger): " << gamepad_reading.right_trigger; - qDebug() << "Reading (Left thumbstick X): " << gamepad_reading.left_thumbstick_x; - qDebug() << "Reading (Left thumbstick Y): " << gamepad_reading.left_thumbstick_y; - qDebug() << "Reading (Right thumbstick X): " << gamepad_reading.right_thumbstick_x; - qDebug() << "Reading (Right thumbstick Y): " << gamepad_reading.right_thumbstick_y; inject_gamepad_state(gamepad_reading); } diff --git a/src/ui/preferences.cpp b/src/ui/preferences.cpp index dcfaa30..c44929f 100644 --- a/src/ui/preferences.cpp +++ b/src/ui/preferences.cpp @@ -255,7 +255,7 @@ bool Preferences::eventFilter(QObject *sender, QEvent *event) valid = true; break; default: - qDebug() << "[!] Error Occurred. No Legal Mouse Button Found"; + qWarning() << "No legal mouse button found."; } if (valid) ptr->setText(QString(buffer));