From 91871505fa66d0e430886688ce3ca801ba3b74ae Mon Sep 17 00:00:00 2001 From: InvoxiPlayGames Date: Thu, 10 Dec 2020 11:20:00 +0000 Subject: [PATCH] Initial commit --- .gitignore | 3 + LICENCE | 21 +++++++ Makefile | 138 +++++++++++++++++++++++++++++++++++++++++ README.md | 33 ++++++++++ hbc/icon.png | Bin 0 -> 10192 bytes hbc/meta.xml | 12 ++++ source/main.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 375 insertions(+) create mode 100644 .gitignore create mode 100644 LICENCE create mode 100644 Makefile create mode 100644 README.md create mode 100644 hbc/icon.png create mode 100644 hbc/meta.xml create mode 100644 source/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c3b3a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.dol +*.elf +build \ No newline at end of file diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..de5f769 --- /dev/null +++ b/LICENCE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 InvoxiPlayGames + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ad42dc9 --- /dev/null +++ b/Makefile @@ -0,0 +1,138 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif + +include $(DEVKITPPC)/wii_rules + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# INCLUDES is a list of directories containing extra header files +#--------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) +CXXFLAGS = $(CFLAGS) + +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lwiiuse -lbte -logc -lm + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +#--------------------------------------------------------------------------------- +# automatically build a list of object files for our project +#--------------------------------------------------------------------------------- +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) + export LD := $(CC) +else + export LD := $(CXX) +endif + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +#--------------------------------------------------------------------------------- +# build a list of include paths +#--------------------------------------------------------------------------------- +export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) \ + -I$(LIBOGC_INC) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := -L$(LIBOGC_LIB) $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +export OUTPUT := $(CURDIR)/$(TARGET) +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol + +#--------------------------------------------------------------------------------- +run: + wiiload $(TARGET).dol + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).dol: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) + +$(OFILES_SOURCES) : $(HFILES) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .jpg extension +#--------------------------------------------------------------------------------- +%.jpg.o %_jpg.h : %.jpg +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + $(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/README.md b/README.md new file mode 100644 index 0000000..2229cd6 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# GCPadder + +GCPadder is a utility that allows you to send your GameCube controller's inputs to your computer from your modded Wii, either wirelessly or using a USB Gecko. _(Performance is best on a stable ethernet connection or a USB Gecko.)_ + +## [Download the Windows PC Client](https://github.com/InvoxiPlayGames/GCPadder/releases/latest) - requires [ViGEmBus](https://github.com/ViGEm/ViGEmBus/releases/latest). + +## How to use: + +- Please make sure you have the [ViGEmBus driver](https://github.com/ViGEm/ViGEmBus/releases/latest) installed. +- If you are using Windows 7, please make sure you have the [.NET Framework 4.5.2 Runtime](https://dotnet.microsoft.com/download/dotnet-framework/net452) installed. + - If you intend on using a USB Gecko, make sure you have [.NET Framework 4.0 Runtime](https://dotnet.microsoft.com/download/dotnet-framework/net40) installed as well as 4.5.2. + - Windows 8.1 and Windows 10 should come with these runtimes pre-installed, or should offer a download if they are not. + +1. Download the latest version of the [Wii Homebrew application and Windows PC client](https://github.com/InvoxiPlayGames/GCPadder/releases/latest). +2. Launch the homebrew application and press the button corresponding with the connection method you want to use. Wait until it says 'Listening on...'. +3. In the PC client, type in the IP address you see on your Wii's screen. The IP may already be filled in for you. The port is filled in automatically, in most cases there is no reason to touch this. + - If using a USB Gecko, select the USB Gecko option in the PC client. +4. Click 'Connect' on the PC client, and if all goes well, an Xbox 360 Controller will appear to applications and games running on your PC with the inputs of your GameCube controller. + +## For developers: + +The "protocol" used is very simple, send 0x09AD09AD to the UDP server/USB Gecko from your application, and the Wii will start reporting inputs at ~200Hz. The controller input format is shown below as a C structure: +```c +struct NETPADData { + uint16_t buttons; + int8_t stickX; + int8_t stickY; + int8_t substickX; + int8_t substickY; + uint8_t triggerL; + uint8_t triggerR; +} paddata; +``` \ No newline at end of file diff --git a/hbc/icon.png b/hbc/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d330c1082506f2d82922a7a6eebe0b3035dc3fc5 GIT binary patch literal 10192 zcmV;>CokBEP)J$d`1zsX4+I*Wt}%P^o$^uoPrHB#`9Y!M=*Xpoq_-Y1)zLN2WKsi;w9NzLe1DxqUE zu1mccQ#wZHpOqDilICP3iTeDb@P98K#u30EL4NnU-$5dgM5lTsROTbAw921ByKRzc z>atGyX~3Qxfl}M1>Lyww+uqgeH*Z^8&34uJSlt{hu)MKDw{2r^);e=`276{EaY#0; z^QqWuBAo2AU3T^lc%*(i=gy795?vOzmte^%5~j{(ER9Xsn#-1TFBHiONw$Ry7QIJS z^hFkD*#=I{?1e4qxaXdG5eNhv1xTe*sBf%8Jet6J<>yf)cfeRg7`AT1)9S`WPq#q| zaSeheJ89ln>9y|M)-K&pQC-c@-majz#Q~l}zer*C zr)QBJOe2%Z(!<#Qt-@o)gH-g*irdX^JFh)sIj6-~?p(X{7%T0IE&F?3Kl$Uiek8(G z*+r65jhOAyhD{}TJY&Uwl}VU;SUh|tU^c?7dSOagabK+X{G#8IBqL)c@ab1Cqn#Sg zpFfY**48-}5DJAz0aEaV-SA2(%teGD>uwmXG$K>|QlKwzN8+&j{^qsH71!M6S5%LL zgRf-Jeb|6Wyr8C*p`wxtpPYZv#`$w5jvg^lRhh-kovMKSY>K#qrqYe5g@^vFTI*th z#@ry66>?#py+9e}3z{t@^!e?|v?+TIvkT`E$5NQds+h*ABw5-V@>qX{nnXI?I`aH% z=HP>=nb4Cp=0?lw4iX+@76@M`5-EUesR$}zXvz%zExj=gAaQPIC>VAf1Zw+k@_hD^ zPfkv?U)J$98Q0%M7dCA?^+XC|BQ`GFp z+WZ3lHJDvY30OJH=Yz|N1e&wxywa~g&KdH)1P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(9X0MIRJGMZk84E4k`7eoU4U#ac;nTw3mKMtpH6w9 z6)Ram;3!&QyF`^tSwXTzUMcqnBy=8exm{i{#eH`CRXn!)YsX(cxaVIg0=18R;-0V1 zIGT*ltOTS|WC!e(Lt zjYzgp=*I!{n596@a4zuyS}cX;i^q-m#^=t+fh>= z?36>UT2c3>@Fli|_3lfTEid&_#pPbexDtzAspT)Q^m2l?e|N&SMVP7+CyOJRn847~ zX|t#QmC3^=UpjGa;Ori{xnEqq`KF@;_xjegSBOQoob7vDr8R}3yxuN;;YA)Kb8iY= zvvv(eM@F%(cBk+uys^vU!C(K!<1b5%_{MvTa!zEtQTXXJ?}E z$dGN~6zx7n+ezBStAh3DYQ0DZSj(p7UVB&Oad;X2(bIcHrE}leJ~THsI|`6ar?Gwe zb_@*-iA99@R3Q)XuD|ns_=CYRlMYPO1n?zQ=|l|YPj#ceryI$5RH2*pTbAjgzFlJO z_K%7OdofQ_=?;(Wu`TTh8wb#(t*ytz#-$q78 zL~einX{kh9%;hij;pO3~ix*X>3n1o?pFcpAA{lYva|8bW0t^5$;#<`#ZQkPm0000< KMNUMnLSTXvv%<>& literal 0 HcmV?d00001 diff --git a/hbc/meta.xml b/hbc/meta.xml new file mode 100644 index 0000000..1f2197a --- /dev/null +++ b/hbc/meta.xml @@ -0,0 +1,12 @@ + + + GCPadder + InvoxiPlayGames + 1.0 + 20201210000000 + Use GameCube controllers on PC + GCPadder is a utility that allows you to send your GameCube controller's inputs to your computer, either wirelessly or using a USB Gecko. (Performance is best on a stable ethernet connection or a USB Gecko.) +Read more information and download the corresponding PC application from https://github.com/InvoxiPlayGames/GCPadder + +THIS IS INCOMPATIBLE WITH WIIS WITHOUT GAMECUBE PORTS. (Obviously!) + \ No newline at end of file diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..9fd488f --- /dev/null +++ b/source/main.c @@ -0,0 +1,168 @@ +#include +#include +#include +#include +#include +#include + +static void *xfb = NULL; +static GXRModeObj *rmode = NULL; + +u32 storedmagic = 0x0; +s8 selectedoutput = -1; + +u16 netport = 0x9AD; +s32 sock; +u32 size; +struct sockaddr_in connected; + +char localip[16] = {0}; +char gateway[16] = {0}; +char netmask[16] = {0}; +int recv_buffer(void *buffer, int size) { + if (selectedoutput == 2) { + size = sizeof(connected); + return net_recvfrom(sock, buffer, size, 0, (struct sockaddr *)&connected, (u32*)&size); + } else { + return usb_recvbuffer(selectedoutput, buffer, size); + } +} +int send_buffer(void *buffer, int size) { + if (selectedoutput == 2) { + return net_sendto(sock, buffer, size, 0, (struct sockaddr *)&connected, size); + } else { + return usb_sendbuffer(selectedoutput, buffer, size); + } +} + +typedef struct NETPADData NETPADData; +struct NETPADData { + u16 buttons; + s8 stickX; + s8 stickY; + s8 substickX; + s8 substickY; + u8 triggerL; + u8 triggerR; +} paddata; + +struct NETPADData old; + +int main(int argc, char **argv) { + VIDEO_Init(); + WPAD_Init(); + PAD_Init(); + rmode = VIDEO_GetPreferredMode(NULL); + xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); + VIDEO_Configure(rmode); + VIDEO_SetNextFramebuffer(xfb); + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); + if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); + + bool geckoA; + bool geckoB; + + printf("\x1b[2;0H"); + printf("GCPadder v1.0\n"); + printf("-------------\n\n"); + printf("Press A on GameCube Pad 1 to use the network.\n"); + if ((geckoB = usb_isgeckoalive(1))) printf("Press B on GameCube Pad 1 to use USB Gecko Slot B.\n"); + if ((geckoA = usb_isgeckoalive(0))) printf("Press X on GameCube Pad 1 to use USB Gecko Slot A.\n"); + printf("Press START, RESET or HOME to exit\n"); + + while(selectedoutput == -1) { + PAD_ScanPads(); + WPAD_ScanPads(); + u16 pressedGC = PAD_ButtonsDown(0); + if (pressedGC & PAD_BUTTON_A) selectedoutput = 2; + if (geckoB && pressedGC & PAD_BUTTON_B) selectedoutput = 1; + if (geckoA && pressedGC & PAD_BUTTON_X) selectedoutput = 0; + if (pressedGC & PAD_BUTTON_START) exit(0); + u32 pressedRVL = WPAD_ButtonsDown(0); + if (pressedRVL & WPAD_BUTTON_HOME) exit(0); + if (pressedRVL & WPAD_CLASSIC_BUTTON_HOME) exit(0); + if (SYS_ResetButtonDown()) exit(0); + } + + if (selectedoutput == 2) { + printf("Connecting to the network...\n"); + s32 ret; + char localip[16] = {0}; + char gateway[16] = {0}; + char netmask[16] = {0}; + ret = if_config(localip, netmask, gateway, TRUE, 20); + if (ret < 0) { + printf("Failed to connect to the network. Press any button to exit.\n"); + while (1) { + PAD_ScanPads(); + if (PAD_ButtonsDown(0) > 0) exit(0); + } + } + printf("Initialising socket...\n"); + sock = net_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (sock == INVALID_SOCKET) { + printf("Failed to create a socket. Press any button to exit.\n"); + while (1) { + PAD_ScanPads(); + if (PAD_ButtonsDown(0) > 0) exit(0); + } + } + struct sockaddr_in bind; + memset(&bind, 0, sizeof(bind)); + bind.sin_family = AF_INET; + bind.sin_port = htons(netport); + bind.sin_addr.s_addr = INADDR_ANY; + ret = net_bind(sock, (struct sockaddr *)&bind, sizeof(bind)); + if (ret) { + printf("Failed to bind socket. Press any button to exit.\n"); + while (1) { + PAD_ScanPads(); + if (PAD_ButtonsDown(0) > 0) exit(0); + } + } + printf("Listening on %s:%i...\n", localip, netport); + } else { + printf("Listening on USB Gecko Slot %c...\n", 65 + selectedoutput); + } + printf("Use the GCPadder application on your PC to connect."); + while (storedmagic != 0x09ad09ad) { + recv_buffer(&storedmagic, 4); + } + if (selectedoutput == 2) { + uint32_t ip = connected.sin_addr.s_addr; + unsigned char bytes[4]; + bytes[0] = ip & 0xFF; + bytes[1] = (ip >> 8) & 0xFF; + bytes[2] = (ip >> 16) & 0xFF; + bytes[3] = (ip >> 24) & 0xFF; + printf("\rConnected to %u.%u.%u.%u:%i! \n", bytes[3], bytes[2], bytes[1], bytes[0], connected.sin_port); + } else { + printf("\rConnected! \n"); + } + printf("Press RESET or HOME to exit.\n"); + uint8_t loopis = 0; + while(true) { + if (SYS_ResetButtonDown()) exit(0); + WPAD_ScanPads(); + u32 pressedRVL = WPAD_ButtonsDown(0); + if (pressedRVL & WPAD_BUTTON_HOME) exit(0); + if (pressedRVL & WPAD_CLASSIC_BUTTON_HOME) exit(0); + PAD_ScanPads(); + paddata.buttons = PAD_ButtonsHeld(0); + paddata.stickX = PAD_StickX(0); + paddata.stickY = PAD_StickY(0); + paddata.substickX = PAD_SubStickX(0); + paddata.substickY = PAD_SubStickY(0); + paddata.triggerL = PAD_TriggerL(0); + paddata.triggerR = PAD_TriggerR(0); + if (selectedoutput < 2 || loopis == 255 || memcmp(&paddata, &old, 8) != 0) send_buffer(&paddata, sizeof(paddata)); + old = paddata; + loopis++; + usleep(5000); + }; + + return 0; +}