From 1de7f602bb4140a7f1f09de7bcb919c58a928a1e Mon Sep 17 00:00:00 2001 From: smdstudios <113876887+smdstudios@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:37:39 +1000 Subject: [PATCH 1/2] Update BT.c Provides ability to load Wiimote/CC mappings from .ini file on USB/SD card --- kernel/BT.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/kernel/BT.c b/kernel/BT.c index 0f4e80ff..58b28f7e 100644 --- a/kernel/BT.c +++ b/kernel/BT.c @@ -738,10 +738,41 @@ void BTUpdateRegisters(void) if(inited == 0) return; - if(intr == 1) - { - intr = 0; - __readintrdataCB(); + // Try to load Wiimote/Classic Controller bindings from ircc.ini + const char *filenames[2] = { + file_sd, file_usb, + "sd:/ircc.ini", + "usb:/ircc.ini" + }; + + int i; + FIL f; + FRESULT res = FR_DISK_ERR; + for (i = 0; i < 2; i++) { + res = f_open_char(&f, filenames[i], FA_READ | FA_OPEN_EXISTING); + if (res == FR_OK) + break; + } + + if (res == FR_OK) { + // File found, read the configuration + size_t fsize = f.obj.objsize; + UINT read; + f_read(&f, (void*)IR_CFG_FILE, fsize, &read); + DCFlushRange((void*)IR_CFG_FILE, fsize); + f_close(&f); + // Apply custom config (size is fsize) + *(vu32*)IR_CFG_SIZE = fsize; + } else { + // No config file found; fall back to defaults + *(vu32*)IR_CFG_SIZE = 0; + } + + // Continue with the rest of the BTUpdateRegisters function + if(intr == 1) + { + intr = 0; + __readintrdataCB(); __issue_intrread(); } if(bulk == 1) @@ -751,6 +782,7 @@ void BTUpdateRegisters(void) __issue_bulkread(); } + // Handle connected controllers u32 i = 0, j = 0; sync_before_read((void*)0x13003020,0x40); for( ; i < BTChannelsUsed; ++i) From 9c4dbb50e35b9b8ab82c7da5bfdda6705a096b78 Mon Sep 17 00:00:00 2001 From: smdstudios <113876887+smdstudios@users.noreply.github.com> Date: Wed, 16 Oct 2024 01:19:48 +1000 Subject: [PATCH 2/2] Update BT.c define IR_CFG_FILE and IR_CFG_SIZE --- kernel/BT.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/BT.c b/kernel/BT.c index 58b28f7e..58479e25 100644 --- a/kernel/BT.c +++ b/kernel/BT.c @@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. /* WiiU Pro Controller Documentation from TeHaxor69 */ /* lwBT ported from LibOGC */ +#define IR_CFG_FILE 0x93005180 +#define IR_CFG_SIZE 0x93005184 + #include "global.h" #include "string.h" #include "BT.h"