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.cbp
libcontrollerpatcher.depend
.idea/

View File

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

View File

@ -34,19 +34,19 @@ 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)
@ -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
#---------------------------------------------------------------------------------

View File

@ -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;

View File

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

View File

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

View File

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

View File

@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "UDPClient.hpp"
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
@ -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__);

View File

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

View File

@ -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;

View File

@ -1,10 +1,7 @@
#include <network/net.h>
#include <nsysnet/socket.h>
#include <coreinit/systeminfo.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;
void initNetwork(){

View File

@ -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);

View File

@ -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);

View File

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