From 47cf34d090c694334b5d07bbd664df5d3be8b091 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 19 Sep 2021 21:16:03 +0200 Subject: [PATCH] Fix compiling on latest devkitPPC/wut --- .gitignore | 3 ++- Dockerfile | 2 +- Makefile | 31 +++++++++---------------- source/ControllerPatcher.cpp | 4 ++-- source/ControllerPatcherIncludes.hpp | 2 +- source/network/CPTCPServer.cpp | 3 ++- source/network/CPTCPServer.hpp | 3 +++ source/network/UDPClient.cpp | 5 ++-- source/network/UDPClient.hpp | 2 ++ source/network/UDPServer.cpp | 6 ++--- source/network/net.c | 5 +--- source/patcher/ControllerPatcherHID.cpp | 4 ++-- source/utils/TCPServer.cpp | 6 ++--- source/utils/TCPServer.hpp | 4 ++-- 14 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index d6b7354..f09a56a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /release /libcontrollerpatcher-1.0.0.tar.bz2 libcontrollerpatcher.cbp -libcontrollerpatcher.depend \ No newline at end of file +libcontrollerpatcher.depend +.idea/ diff --git a/Dockerfile b/Dockerfile index 77c9e8a..fd38b9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wiiuenv/devkitppc:20200810 +FROM wiiuenv/devkitppc:20210917 WORKDIR tmp_build COPY . . diff --git a/Makefile b/Makefile index 1332e88..c4de735 100644 --- a/Makefile +++ b/Makefile @@ -34,26 +34,26 @@ SOURCES := source \ source/utils DATA := data INCLUDES := source \ - include + include \ #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS := -Wall -save-temps \ +CFLAGS := -Wall -Werror -save-temps \ -ffunction-sections -fdata-sections \ $(MACHDEP) \ $(BUILD_CFLAGS) -CFLAGS += $(INCLUDE) -D__WIIU__ -D__LOGGING__ +CFLAGS += $(INCLUDE) -D__WIIU__ -CXXFLAGS := $(CFLAGS) -std=gnu++17 +CXXFLAGS := $(CFLAGS) -std=gnu++20 ASFLAGS := $(MACHDEP) LDFLAGS = $(ARCH) -Wl,--gc-sections -LIBS := +LIBS := #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -76,7 +76,6 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- @@ -94,12 +93,13 @@ endif #--------------------------------------------------------------------------------- export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) +export OFILES_SRC := $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) export OFILES := $(OFILES_BIN) $(OFILES_SRC) export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I. .PHONY: all dist-bin dist-src dist install clean @@ -119,13 +119,10 @@ install: dist-bin bzip2 -cd libcontrollerpatcher-$(VERSION).tar.bz2 | tar -xf - -C $(WUT_ROOT)/usr lib: - @[ -d $@ ] || mkdir -p $@ - -share: - @[ -d $@ ] || mkdir -p $@ + @$(shell [ ! -d 'lib' ] && mkdir -p 'lib') release: - @[ -d $@ ] || mkdir -p $@ + @$(shell [ ! -d 'release' ] && mkdir -p 'release') lib/libcontrollerpatcher.a :$(SOURCES) $(INCLUDES) | lib release @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ @@ -151,12 +148,6 @@ $(OUTPUT) : $(OFILES) $(OFILES_SRC) : $(HFILES) -#--------------------------------------------------------------------------------- -%.o: %.def - $(SILENTMSG) $(notdir $<) - $(SILENTCMD)rplimportgen $< $*.s $*.ld $(ERROR_FILTER) - $(SILENTCMD)$(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER) - #--------------------------------------------------------------------------------- %_bin.h %.bin.o : %.bin #--------------------------------------------------------------------------------- @@ -168,4 +159,4 @@ $(OFILES_SRC) : $(HFILES) #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- \ No newline at end of file +#--------------------------------------------------------------------------------------- diff --git a/source/ControllerPatcher.cpp b/source/ControllerPatcher.cpp index 7c0d1b4..85a4b53 100644 --- a/source/ControllerPatcher.cpp +++ b/source/ControllerPatcher.cpp @@ -489,7 +489,7 @@ BOOL ControllerPatcher::Init(const char * pathToConfig) { OSDynLoad_Module handle; void* kpad_ptr; OSDynLoad_Acquire("padscore",&handle); - OSDynLoad_FindExport(handle, 0 ,"KPADRead",&kpad_ptr); + OSDynLoad_FindExport(handle, OS_DYNLOAD_EXPORT_FUNC ,"KPADRead",&kpad_ptr); gSamplingCallback = (WPADSamplingCallback)((uint32_t)kpad_ptr + 0x1F0); if(*(uint32_t*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { @@ -798,7 +798,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp if((hid & (1 << i)) != 0) { memset(buffer,0,sizeof(*buffer)); - int32_t newhid = (1 << i); + uint32_t newhid = (1 << i); int32_t deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid); if(deviceslot < 0) continue; diff --git a/source/ControllerPatcherIncludes.hpp b/source/ControllerPatcherIncludes.hpp index 3c98edb..af34710 100644 --- a/source/ControllerPatcherIncludes.hpp +++ b/source/ControllerPatcherIncludes.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "./ConfigReader.hpp" #include diff --git a/source/network/CPTCPServer.cpp b/source/network/CPTCPServer.cpp index 66facbc..80ffffc 100644 --- a/source/network/CPTCPServer.cpp +++ b/source/network/CPTCPServer.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . ****************************************************************************/ #include "CPTCPServer.hpp" +#include #include #include #include @@ -81,7 +82,7 @@ BOOL CPTCPServer::whileLoop() { } ret = checkbyte(clientfd); if (ret < 0) { - if(socketlasterr() != 6) { + if(errno != EWOULDBLOCK) { return false; } OSSleepTicks(OSMicrosecondsToTicks(1000)); diff --git a/source/network/CPTCPServer.hpp b/source/network/CPTCPServer.hpp index 07e9326..0046c64 100644 --- a/source/network/CPTCPServer.hpp +++ b/source/network/CPTCPServer.hpp @@ -19,6 +19,9 @@ #include "../ControllerPatcherIncludes.hpp" +#include +#include +#include #include #include #include diff --git a/source/network/UDPClient.cpp b/source/network/UDPClient.cpp index 9ee4293..976db9f 100644 --- a/source/network/UDPClient.cpp +++ b/source/network/UDPClient.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . ****************************************************************************/ #include "UDPClient.hpp" +#include #include #include @@ -36,14 +37,14 @@ UDPClient::UDPClient(uint32_t ip, int32_t port) { connect_addr.sin_addr.s_addr = ip; if(connect(sockfd, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) { - socketclose(sockfd); + close(sockfd); sockfd = -1; } } UDPClient::~UDPClient() { if (this->sockfd != -1) { - socketclose(sockfd); + close(sockfd); } if(HID_DEBUG) { log_printf("UDPClient::~UDPClient(line %d): Thread has been closed",__LINE__); diff --git a/source/network/UDPClient.hpp b/source/network/UDPClient.hpp index 8abecf4..586248d 100644 --- a/source/network/UDPClient.hpp +++ b/source/network/UDPClient.hpp @@ -18,6 +18,8 @@ #define _UDPCLIENT_WINDOW_H_ #include "../ControllerPatcherIncludes.hpp" +#include +#include #define DEFAULT_UDP_CLIENT_PORT 8114 diff --git a/source/network/UDPServer.cpp b/source/network/UDPServer.cpp index 0d2c7a5..48ade89 100644 --- a/source/network/UDPServer.cpp +++ b/source/network/UDPServer.cpp @@ -52,7 +52,7 @@ UDPServer::~UDPServer() { delete pThreadPointer; UDPServer::pThread = NULL; if (this->sockfd != -1) { - socketclose(sockfd); + close(sockfd); } this->sockfd = -1; } @@ -104,9 +104,9 @@ void UDPServer::DoUDPThreadInternal() { memset(buffer,0,MAX_UDP_SIZE); n = recv(sockfd,buffer,MAX_UDP_SIZE,0); if (n < 0) { - int32_t errno_ = socketlasterr(); + int32_t errno_ = errno; OSSleepTicks(OSMicrosecondsToTicks(2000)); - if(errno_ != 11 && errno_ != 9) { + if(errno_ != EINVAL && errno_ != ENOTCONN) { break; } continue; diff --git a/source/network/net.c b/source/network/net.c index 398a7df..c17cbb2 100644 --- a/source/network/net.c +++ b/source/network/net.c @@ -1,10 +1,7 @@ -#include -#include #include #include -#include +#include -static uint32_t hostIpAddress __attribute__((section(".data"))) = 0; static volatile int socket_lock __attribute__((section(".data"))) = 0; void initNetwork(){ diff --git a/source/patcher/ControllerPatcherHID.cpp b/source/patcher/ControllerPatcherHID.cpp index ccff9cd..c22d20b 100644 --- a/source/patcher/ControllerPatcherHID.cpp +++ b/source/patcher/ControllerPatcherHID.cpp @@ -239,7 +239,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic } else if (slotdata->hidmask == gHID_LIST_MOUSE) { HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 0, 0, 0); //HIDGetDescriptor(p_device->handle,0x22,0x00,0,my_buf,512,my_foo_cb,NULL); - HIDSetIdle(p_device->handle,p_device->interfaceIndex,1,NULL,NULL); + HIDSetIdle(p_device->handle,p_device->interfaceIndex,1,NULL,NULL,NULL); gHID_Mouse_Mode = HID_MOUSE_MODE_AIM; HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDMouseReadCallback, usr); } else if (slotdata->hidmask == gHID_LIST_SWITCH_PRO) { @@ -272,7 +272,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic } } else if (slotdata->hidmask == gHID_LIST_KEYBOARD) { HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0); - HIDSetIdle(p_device->handle, p_device->interfaceIndex, 0, 0, 0); + HIDSetIdle(p_device->handle, p_device->interfaceIndex, 0, 0, nullptr, nullptr); HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDReadCallback, usr); } else if (slotdata->hidmask == gHID_LIST_DS3) { HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0); diff --git a/source/utils/TCPServer.cpp b/source/utils/TCPServer.cpp index 253c744..540f73d 100644 --- a/source/utils/TCPServer.cpp +++ b/source/utils/TCPServer.cpp @@ -36,10 +36,10 @@ TCPServer::~TCPServer() { void TCPServer::CloseSockets() { if (this->sockfd != -1) { - socketclose(this->sockfd); + close(this->sockfd); } if (this->clientfd != -1) { - socketclose(this->clientfd); + close(this->clientfd); } this->sockfd = -1; this->clientfd = -1; @@ -110,7 +110,7 @@ void TCPServer::DoTCPThreadInternal() { DEBUG_FUNCTION_LINE("Client disconnected"); if(clientfd != -1) { - socketclose(clientfd); + close(clientfd); } clientfd = -1; } while(0); diff --git a/source/utils/TCPServer.hpp b/source/utils/TCPServer.hpp index 7dcfbfb..94db849 100644 --- a/source/utils/TCPServer.hpp +++ b/source/utils/TCPServer.hpp @@ -2,8 +2,8 @@ #define _TCPSERVER_H_ #include - -#include +#include +#include #include #include