Fix compiling on latest devkitPPC/wut

This commit is contained in:
Maschell 2021-09-19 21:16:03 +02:00
parent 1482f8a437
commit 47cf34d090
14 changed files with 38 additions and 42 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/libcontrollerpatcher-1.0.0.tar.bz2 /libcontrollerpatcher-1.0.0.tar.bz2
libcontrollerpatcher.cbp libcontrollerpatcher.cbp
libcontrollerpatcher.depend libcontrollerpatcher.depend
.idea/

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20200810 FROM wiiuenv/devkitppc:20210917
WORKDIR tmp_build WORKDIR tmp_build
COPY . . COPY . .

View File

@ -34,19 +34,19 @@ SOURCES := source \
source/utils source/utils
DATA := data DATA := data
INCLUDES := source \ INCLUDES := source \
include include \
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
CFLAGS := -Wall -save-temps \ CFLAGS := -Wall -Werror -save-temps \
-ffunction-sections -fdata-sections \ -ffunction-sections -fdata-sections \
$(MACHDEP) \ $(MACHDEP) \
$(BUILD_CFLAGS) $(BUILD_CFLAGS)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__LOGGING__ CFLAGS += $(INCLUDE) -D__WIIU__
CXXFLAGS := $(CFLAGS) -std=gnu++17 CXXFLAGS := $(CFLAGS) -std=gnu++20
ASFLAGS := $(MACHDEP) ASFLAGS := $(MACHDEP)
@ -76,7 +76,6 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -94,12 +93,13 @@ endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 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 OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 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 .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 bzip2 -cd libcontrollerpatcher-$(VERSION).tar.bz2 | tar -xf - -C $(WUT_ROOT)/usr
lib: lib:
@[ -d $@ ] || mkdir -p $@ @$(shell [ ! -d 'lib' ] && mkdir -p 'lib')
share:
@[ -d $@ ] || mkdir -p $@
release: release:
@[ -d $@ ] || mkdir -p $@ @$(shell [ ! -d 'release' ] && mkdir -p 'release')
lib/libcontrollerpatcher.a :$(SOURCES) $(INCLUDES) | lib release lib/libcontrollerpatcher.a :$(SOURCES) $(INCLUDES) | lib release
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
@ -151,12 +148,6 @@ $(OUTPUT) : $(OFILES)
$(OFILES_SRC) : $(HFILES) $(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 %_bin.h %.bin.o : %.bin
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -489,7 +489,7 @@ BOOL ControllerPatcher::Init(const char * pathToConfig) {
OSDynLoad_Module handle; OSDynLoad_Module handle;
void* kpad_ptr; void* kpad_ptr;
OSDynLoad_Acquire("padscore",&handle); 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); gSamplingCallback = (WPADSamplingCallback)((uint32_t)kpad_ptr + 0x1F0);
if(*(uint32_t*)gSamplingCallback != FIRST_INSTRUCTION_IN_SAMPLING_CALLBACK) { 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) { if((hid & (1 << i)) != 0) {
memset(buffer,0,sizeof(*buffer)); memset(buffer,0,sizeof(*buffer));
int32_t newhid = (1 << i); uint32_t newhid = (1 << i);
int32_t deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid); int32_t deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid);
if(deviceslot < 0) continue; if(deviceslot < 0) continue;

View File

@ -26,7 +26,7 @@
#include <padscore/wpad.h> #include <padscore/wpad.h>
#include <vpad/input.h> #include <vpad/input.h>
#include <coreinit/systeminfo.h> #include <coreinit/systeminfo.h>
#include <nsysnet/socket.h> #include <sys/socket.h>
#include "./ConfigReader.hpp" #include "./ConfigReader.hpp"
#include <controller_patcher/ControllerPatcher.hpp> #include <controller_patcher/ControllerPatcher.hpp>

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include "CPTCPServer.hpp" #include "CPTCPServer.hpp"
#include <netinet/in.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -81,7 +82,7 @@ BOOL CPTCPServer::whileLoop() {
} }
ret = checkbyte(clientfd); ret = checkbyte(clientfd);
if (ret < 0) { if (ret < 0) {
if(socketlasterr() != 6) { if(errno != EWOULDBLOCK) {
return false; return false;
} }
OSSleepTicks(OSMicrosecondsToTicks(1000)); OSSleepTicks(OSMicrosecondsToTicks(1000));

View File

@ -19,6 +19,9 @@
#include "../ControllerPatcherIncludes.hpp" #include "../ControllerPatcherIncludes.hpp"
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <utils/TCPServer.hpp> #include <utils/TCPServer.hpp>
#include <network/net.h> #include <network/net.h>
#include <coreinit/title.h> #include <coreinit/title.h>

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include "UDPClient.hpp" #include "UDPClient.hpp"
#include <netinet/in.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -36,14 +37,14 @@ UDPClient::UDPClient(uint32_t ip, int32_t port) {
connect_addr.sin_addr.s_addr = ip; connect_addr.sin_addr.s_addr = ip;
if(connect(sockfd, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) { if(connect(sockfd, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) {
socketclose(sockfd); close(sockfd);
sockfd = -1; sockfd = -1;
} }
} }
UDPClient::~UDPClient() { UDPClient::~UDPClient() {
if (this->sockfd != -1) { if (this->sockfd != -1) {
socketclose(sockfd); close(sockfd);
} }
if(HID_DEBUG) { if(HID_DEBUG) {
log_printf("UDPClient::~UDPClient(line %d): Thread has been closed",__LINE__); log_printf("UDPClient::~UDPClient(line %d): Thread has been closed",__LINE__);

View File

@ -18,6 +18,8 @@
#define _UDPCLIENT_WINDOW_H_ #define _UDPCLIENT_WINDOW_H_
#include "../ControllerPatcherIncludes.hpp" #include "../ControllerPatcherIncludes.hpp"
#include <sys/socket.h>
#include <netinet/in.h>
#define DEFAULT_UDP_CLIENT_PORT 8114 #define DEFAULT_UDP_CLIENT_PORT 8114

View File

@ -52,7 +52,7 @@ UDPServer::~UDPServer() {
delete pThreadPointer; delete pThreadPointer;
UDPServer::pThread = NULL; UDPServer::pThread = NULL;
if (this->sockfd != -1) { if (this->sockfd != -1) {
socketclose(sockfd); close(sockfd);
} }
this->sockfd = -1; this->sockfd = -1;
} }
@ -104,9 +104,9 @@ void UDPServer::DoUDPThreadInternal() {
memset(buffer,0,MAX_UDP_SIZE); memset(buffer,0,MAX_UDP_SIZE);
n = recv(sockfd,buffer,MAX_UDP_SIZE,0); n = recv(sockfd,buffer,MAX_UDP_SIZE,0);
if (n < 0) { if (n < 0) {
int32_t errno_ = socketlasterr(); int32_t errno_ = errno;
OSSleepTicks(OSMicrosecondsToTicks(2000)); OSSleepTicks(OSMicrosecondsToTicks(2000));
if(errno_ != 11 && errno_ != 9) { if(errno_ != EINVAL && errno_ != ENOTCONN) {
break; break;
} }
continue; continue;

View File

@ -1,10 +1,7 @@
#include <network/net.h>
#include <nsysnet/socket.h>
#include <coreinit/systeminfo.h> #include <coreinit/systeminfo.h>
#include <coreinit/thread.h> #include <coreinit/thread.h>
#include <nn/ac/ac_c.h> #include <sys/socket.h>
static uint32_t hostIpAddress __attribute__((section(".data"))) = 0;
static volatile int socket_lock __attribute__((section(".data"))) = 0; static volatile int socket_lock __attribute__((section(".data"))) = 0;
void initNetwork(){ void initNetwork(){

View File

@ -239,7 +239,7 @@ int32_t ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevic
} else if (slotdata->hidmask == gHID_LIST_MOUSE) { } else if (slotdata->hidmask == gHID_LIST_MOUSE) {
HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 0, 0, 0); HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 0, 0, 0);
//HIDGetDescriptor(p_device->handle,0x22,0x00,0,my_buf,512,my_foo_cb,NULL); //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; gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDMouseReadCallback, usr); HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDMouseReadCallback, usr);
} else if (slotdata->hidmask == gHID_LIST_SWITCH_PRO) { } 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) { } else if (slotdata->hidmask == gHID_LIST_KEYBOARD) {
HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0); 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); HIDRead(p_device->handle, buf, p_device->maxPacketSizeRx, myHIDReadCallback, usr);
} else if (slotdata->hidmask == gHID_LIST_DS3) { } else if (slotdata->hidmask == gHID_LIST_DS3) {
HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0); HIDSetProtocol(p_device->handle, p_device->interfaceIndex, 1, 0, 0);

View File

@ -36,10 +36,10 @@ TCPServer::~TCPServer() {
void TCPServer::CloseSockets() { void TCPServer::CloseSockets() {
if (this->sockfd != -1) { if (this->sockfd != -1) {
socketclose(this->sockfd); close(this->sockfd);
} }
if (this->clientfd != -1) { if (this->clientfd != -1) {
socketclose(this->clientfd); close(this->clientfd);
} }
this->sockfd = -1; this->sockfd = -1;
this->clientfd = -1; this->clientfd = -1;
@ -110,7 +110,7 @@ void TCPServer::DoTCPThreadInternal() {
DEBUG_FUNCTION_LINE("Client disconnected"); DEBUG_FUNCTION_LINE("Client disconnected");
if(clientfd != -1) { if(clientfd != -1) {
socketclose(clientfd); close(clientfd);
} }
clientfd = -1; clientfd = -1;
} while(0); } while(0);

View File

@ -2,8 +2,8 @@
#define _TCPSERVER_H_ #define _TCPSERVER_H_
#include <sys/select.h> #include <sys/select.h>
#include <sys/socket.h>
#include <nsysnet/socket.h> #include <netinet/in.h>
#include <system/CThread.h> #include <system/CThread.h>
#include <wut_types.h> #include <wut_types.h>