Skip to content

Commit

Permalink
Remove unused header files
Browse files Browse the repository at this point in the history
  • Loading branch information
Crayon2000 committed Dec 25, 2024
1 parent 30e6b48 commit ae0a381
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
32 changes: 14 additions & 18 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <coreinit/screen.h>
#include <padscore/kpad.h>
#include <vpad/input.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <nn/ac.h>
#include <whb/sdcard.h>
Expand All @@ -14,19 +13,16 @@
#include <sysapp/launch.h>
#include <wut_types.h>
#include <ini.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <cstring>
#include <sys/unistd.h>
#include <thread>

/**
* Application configuration.
*/
typedef struct {
std::string ipaddress;
int port{4242};
uint16_t port{4242};
} configuration;

/**
Expand All @@ -45,11 +41,11 @@ static std::atomic<bool> thread_running{true};
static int handler(void* user, const char* section, const char* name, const char* value)
{
configuration* pconfig = static_cast<configuration*>(user);
if(strcmp(section, "server") == 0) {
if(strcmp(name, "ipaddress") == 0) {
if(std::strcmp(section, "server") == 0) {
if(std::strcmp(name, "ipaddress") == 0) {
pconfig->ipaddress = value;
}
else if(strcmp(name, "port") == 0) {
else if(std::strcmp(name, "port") == 0) {
pconfig->port = std::atoi(value);
}
else {
Expand Down Expand Up @@ -128,7 +124,7 @@ static int sendPadData() {

// Transform to JSON
PADData pad_data;
memset(&pad_data, 0, sizeof(PADData));
std::memset(&pad_data, 0, sizeof(PADData));
pad_data.vpad = &vpad_data;
if(kpad_error1 == KPADError::KPAD_ERROR_OK) {
pad_data.kpad[0] = &kpad_data1;
Expand Down Expand Up @@ -204,7 +200,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
WHBMountSdCard();
char path[256];
char *sdRootPath = WHBGetSdCardMountPath();
snprintf(path, sizeof(path), "%s/wiiu/apps/MiisendU-Wii-U/settings.ini", sdRootPath);
std::snprintf(path, sizeof(path), "%s/wiiu/apps/MiisendU-Wii-U/settings.ini", sdRootPath);

// Init screen and screen buffers
ConsoleInit();
Expand Down Expand Up @@ -277,7 +273,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
OSScreenPutFontEx(SCREEN_DRC, 0, 5, "Please insert your computer's IP address below");
OSScreenPutFontEx(SCREEN_DRC, 0, 6, "(use the DPAD to edit the IP address)");
OSScreenPutFontEx(SCREEN_DRC, 4 * selected_digit, 8, "vvv");
snprintf(IP_str, 32, "%3d.%3d.%3d.%3d", IP[0], IP[1], IP[2], IP[3]);
std::snprintf(IP_str, 32, "%3d.%3d.%3d.%3d", IP[0], IP[1], IP[2], IP[3]);
OSScreenPutFontEx(SCREEN_DRC, 0, 9, IP_str);
OSScreenPutFontEx(SCREEN_DRC, 0, 15, "Press 'A' to confirm");
OSScreenPutFontEx(SCREEN_DRC, 0, 16, "Press the HOME button to exit");
Expand Down Expand Up @@ -317,21 +313,21 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)

// Get IP Address (without spaces)
char IP_ADDRESS[32];
snprintf(IP_ADDRESS, 32, "%d.%d.%d.%d", IP[0], IP[1], IP[2], IP[3]);
std::snprintf(IP_ADDRESS, 32, "%d.%d.%d.%d", IP[0], IP[1], IP[2], IP[3]);

// Initialize the UDP connection
udp_init(IP_ADDRESS, Port);

// Save settings to file
FILE * IP_file = fopen(path, "w");
FILE * IP_file = std::fopen(path, "w");
if (IP_file != nullptr) {
fprintf(IP_file,
std::fprintf(IP_file,
"[server]\n"
"ipaddress=%s\n"
"port=%d\n"
"\n",
IP_ADDRESS, Port);
fclose(IP_file);
std::fclose(IP_file);
}

uint16_t holdTime = 0;
Expand All @@ -343,7 +339,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
if(ConsoleDrawStart() == true) {
// Output the IP address
char msg_connected[255];
snprintf(msg_connected, 255, "Connected to %s:%d", IP_ADDRESS, Port);
std::snprintf(msg_connected, 255, "Connected to %s:%d", IP_ADDRESS, Port);

// Print to TV
PrintHeader(SCREEN_TV);
Expand Down
13 changes: 4 additions & 9 deletions source/udp.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#include "udp.h"
#include <coreinit/memdefaultheap.h>
#include <coreinit/thread.h>
#include <sys/socket.h>
#include <sys/unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <cstring>

static int udp_socket = -1;
static volatile bool udp_lock = false;
Expand All @@ -27,12 +22,12 @@ void udp_init(std::string_view ipString, uint16_t ipport)
}

struct sockaddr_in connect_addr;
memset(&connect_addr, 0, sizeof(connect_addr));
std::memset(&connect_addr, 0, sizeof(connect_addr));
connect_addr.sin_family = AF_INET;
connect_addr.sin_port = ipport;
inet_aton(ipString.data(), &connect_addr.sin_addr);

if(connect(udp_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) {
if(connect(udp_socket, reinterpret_cast<struct sockaddr*>(&connect_addr), sizeof(connect_addr)) < 0) {
close(udp_socket);
udp_socket = -1;
}
Expand Down
1 change: 0 additions & 1 deletion source/vpad_to_json.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <string.h>
#include "rapidjson/writer.h"
#include <map>
#include <unordered_map>
Expand Down

0 comments on commit ae0a381

Please sign in to comment.