[WiiU] Input: Make controller_patcher a compile-time option

As discussed in libretro#5357; controller_patcher is now optional. It's
off by default; though this could be changed with a simple makefile
tweak (ENABLE_CONTROLLER_PATCHER ?= 1, perhaps?)

To re-enable controller_patcher; append ENABLE_CONTROLLER_PATCHER=1 to
your usual make command.

controller_patcher was the only user of c++ constructors in the Wii U
port, so you'll need 26a006c in your tree otherwise you will have a
blackscreen on startup.
This commit is contained in:
Ash 2017-12-01 18:29:21 +11:00
parent 26a006cfac
commit bf3e256a43
No known key found for this signature in database
GPG Key ID: F8C85A8C836C0A7E
4 changed files with 88 additions and 59 deletions

View File

@ -18,24 +18,27 @@ OBJ += wiiu/system/exception_handler.o
OBJ += wiiu/system/missing_libc_functions.o
OBJ += wiiu/fs/sd_fat_devoptab.o
OBJ += wiiu/fs/fs_utils.o
OBJ += wiiu/controller_patcher/ControllerPatcher.o
OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o
OBJ += wiiu/controller_patcher/ConfigReader.o
OBJ += wiiu/controller_patcher/config/ConfigParser.o
OBJ += wiiu/controller_patcher/config/ConfigValues.o
OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o
OBJ += wiiu/controller_patcher/network/TCPServer.o
OBJ += wiiu/controller_patcher/network/UDPClient.o
OBJ += wiiu/controller_patcher/network/UDPServer.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o
OBJ += wiiu/controller_patcher/utils/CPRetainVars.o
OBJ += wiiu/controller_patcher/utils/CPStringTools.o
OBJ += wiiu/controller_patcher/utils/PadConst.o
OBJ += wiiu/controller_patcher/utils/FSHelper.o
OBJ += wiiu/tex_shader.o
OBJ += wiiu/hbl.o
ifeq ($(ENABLE_CONTROLLER_PATCHER), 1)
OBJ += wiiu/controller_patcher/ControllerPatcher.o
OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o
OBJ += wiiu/controller_patcher/ConfigReader.o
OBJ += wiiu/controller_patcher/config/ConfigParser.o
OBJ += wiiu/controller_patcher/config/ConfigValues.o
OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o
OBJ += wiiu/controller_patcher/network/TCPServer.o
OBJ += wiiu/controller_patcher/network/UDPClient.o
OBJ += wiiu/controller_patcher/network/UDPServer.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o
OBJ += wiiu/controller_patcher/utils/CPRetainVars.o
OBJ += wiiu/controller_patcher/utils/CPStringTools.o
OBJ += wiiu/controller_patcher/utils/PadConst.o
OBJ += wiiu/controller_patcher/utils/FSHelper.o
endif
DEFINES :=
ifeq ($(GRIFFIN_BUILD), 1)
@ -158,6 +161,9 @@ CFLAGS += -DWIIU -DMSB_FIRST
CFLAGS += -DHAVE_MAIN
CFLAGS += -DHAVE_UPDATE_ASSETS
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE
ifeq ($(ENABLE_CONTROLLER_PATCHER), 1)
CFLAGS += -DENABLE_CONTROLLER_PATCHER
endif
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),)

View File

@ -58,7 +58,9 @@
#include <wiiu/vpad.h>
#include <wiiu/kpad.h>
#include "wiiu/controller_patcher/ControllerPatcherWrapper.h"
#if defined(ENABLE_CONTROLLER_PATCHER)
#include "wiiu/controller_patcher/ControllerPatcherWrapper.h"
#endif
#include <fat.h>
#include <iosuhax.h>
@ -430,7 +432,7 @@ int main(int argc, char **argv)
KPADInit();
#endif
verbosity_enable();
#ifndef IS_SALAMANDER
#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER)
ControllerPatcherInit();
#endif
fflush(stdout);
@ -492,7 +494,7 @@ int main(int argc, char **argv)
}
while (1);
#ifndef IS_SALAMANDER
#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER)
ControllerPatcherDeInit();
#endif
main_exit(NULL);

View File

@ -21,7 +21,9 @@
#include <wiiu/vpad.h>
#include <wiiu/kpad.h>
#include "wiiu/controller_patcher/ControllerPatcherWrapper.h"
#if defined(ENABLE_CONTROLLER_PATCHER)
#include "wiiu/controller_patcher/ControllerPatcherWrapper.h"
#endif
#include "../input_driver.h"
@ -33,8 +35,12 @@
#include "wiiu_dbg.h"
#ifndef MAX_PADS
#define MAX_PADS 16
#if !defined(MAX_PADS)
#if defined(ENABLE_CONTROLLER_PATCHER)
#define MAX_PADS 16
#else
#define MAX_PADS 5
#endif
#endif
#define WIIUINPUT_TYPE_WIIMOTE 0x00
@ -45,22 +51,27 @@
#define GAMEPAD_COUNT 1
#define KPAD_COUNT 4
#define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT)
#define GAMEPAD_OFFSET 0
#define KPAD_OFFSET (GAMEPAD_OFFSET + GAMEPAD_COUNT)
#define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT)
#if defined(ENABLE_CONTROLLER_PATCHER)
#define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT)
#define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT)
#endif
static uint64_t pad_state[MAX_PADS];
static uint8_t pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE};
#if defined(ENABLE_CONTROLLER_PATCHER)
static uint8_t hid_status[HID_COUNT];
static InputData hid_data[HID_COUNT];
static char hidName[HID_COUNT][255];
#endif
/* 3 axis - one for touch/future IR support? */
static int16_t analog_state[MAX_PADS][3][2];
static bool wiiu_pad_inited = false;
static char hidName[HID_COUNT][255];
static const char* wiiu_joypad_name(unsigned pad)
{
if (pad > MAX_PADS) return "N/A";
@ -91,12 +102,14 @@ static const char* wiiu_joypad_name(unsigned pad)
}
}
if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT)
{
s32 hid_index = pad - HID_OFFSET;
sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad);
return hidName[hid_index];
}
#if defined(ENABLE_CONTROLLER_PATCHER)
if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT)
{
s32 hid_index = pad - HID_OFFSET;
sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad);
return hidName[hid_index];
}
#endif //defined(ENABLE_CONTROLLER_PATCHER)
return "unknown";
}
@ -194,9 +207,12 @@ static int16_t scaleTP(int16_t oldMin, int16_t oldMax, int16_t newMin, int16_t n
static void wiiu_joypad_poll(void)
{
int i, c, result;
int i, c;
VPADStatus vpad;
VPADReadError vpadError;
#if defined(ENABLE_CONTROLLER_PATCHER)
int result;
#endif
VPADRead(0, &vpad, 1, &vpadError);
@ -311,41 +327,46 @@ static void wiiu_joypad_poll(void)
}
}
memset(hid_data,0,sizeof(hid_data));
result = gettingInputAllDevices(hid_data,HID_COUNT);
#if defined(ENABLE_CONTROLLER_PATCHER)
memset(hid_data,0,sizeof(hid_data));
result = gettingInputAllDevices(hid_data,HID_COUNT);
if (result + HID_OFFSET > MAX_PADS)
result = MAX_PADS - HID_OFFSET;
if (result + HID_OFFSET > MAX_PADS)
result = MAX_PADS - HID_OFFSET;
for(i = HID_OFFSET;i < result + HID_OFFSET; i++)
{
int hid_index = i-HID_OFFSET;
uint8_t old_status = hid_status[hid_index];
uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */
if (old_status == 1 || new_status == 1)
for(i = HID_OFFSET;i < result + HID_OFFSET; i++)
{
hid_status[hid_index] = new_status;
if (old_status == 0 && new_status == 1) /* Pad was attached */
wiiu_joypad_autodetect_add(i);
else if (old_status == 1 && new_status == 0) /* Pad was detached */
input_autoconfigure_disconnect(i, wiiu_joypad.ident);
else if (old_status == 1 && new_status == 1) /* Pad still connected */
int hid_index = i-HID_OFFSET;
uint8_t old_status = hid_status[hid_index];
uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */
if (old_status == 1 || new_status == 1)
{
pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0;
hid_status[hid_index] = new_status;
if (old_status == 0 && new_status == 1) /* Pad was attached */
wiiu_joypad_autodetect_add(i);
else if (old_status == 1 && new_status == 0) /* Pad was detached */
input_autoconfigure_disconnect(i, wiiu_joypad.ident);
else if (old_status == 1 && new_status == 1) /* Pad still connected */
{
pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0;
}
}
}
}
#endif //defined(ENABLE_CONTROLLER_PATCHER)
}
static bool wiiu_joypad_init(void* data)
{
wiiu_joypad_autodetect_add(0);
memset(hid_status,0,sizeof(hid_status));
#if defined(ENABLE_CONTROLLER_PATCHER)
memset(hid_status,0,sizeof(hid_status));
#endif
wiiu_joypad_poll();
wiiu_pad_inited = true;

View File

@ -544,16 +544,16 @@ const char* const input_builtin_autoconfs[] =
#endif
#ifdef WIIU
DECL_AUTOCONF_DEVICE("WIIU Gamepad", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
DECL_AUTOCONF_DEVICE("WIIU Pro Controller", "wiiu", WIIUINPUT_PRO_CONTROLLER_DEFAULT_BINDS),
DECL_AUTOCONF_DEVICE("Wiimote Controller", "wiiu", WIIUINPUT_WIIMOTE_DEFAULT_BINDS),
DECL_AUTOCONF_DEVICE("Nunchuk Controller", "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS),
DECL_AUTOCONF_DEVICE("Classic Controller", "wiiu", WIIUINPUT_CLASSIC_CONTROLLER_DEFAULT_BINDS),
#if defined(ENABLE_CONTROLLER_PATCHER)
DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
#endif
#endif
#ifdef __CELLOS_LV2__
DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS),
#endif
NULL
};