[Wii U] Using the HID Controller as a own controller. Currently the stick only work when it's bind manually. Mapping from controller to retroarch input port may change when you attach a new device.
This commit is contained in:
parent
ad0953ac87
commit
4393e17ea7
|
@ -407,9 +407,9 @@ int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
verbosity_enable();
|
verbosity_enable();
|
||||||
|
|
||||||
|
printf("starting\n");
|
||||||
ControllerPatcherInit();
|
ControllerPatcherInit();
|
||||||
|
|
||||||
printf("starting\n");
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
DEBUG_VAR(ARGV_PTR);
|
DEBUG_VAR(ARGV_PTR);
|
||||||
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "wiiu_dbg.h"
|
#include "wiiu_dbg.h"
|
||||||
|
|
||||||
#ifndef MAX_PADS
|
#ifndef MAX_PADS
|
||||||
#define MAX_PADS 5
|
#define MAX_PADS 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIIUINPUT_TYPE_WIIMOTE 0x00
|
#define WIIUINPUT_TYPE_WIIMOTE 0x00
|
||||||
|
@ -44,22 +44,31 @@
|
||||||
#define WIIUINPUT_TYPE_PRO_CONTROLLER 0x1F
|
#define WIIUINPUT_TYPE_PRO_CONTROLLER 0x1F
|
||||||
#define WIIUINPUT_TYPE_NONE 0xFD
|
#define WIIUINPUT_TYPE_NONE 0xFD
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
static uint64_t pad_state[MAX_PADS];
|
static uint64_t pad_state[MAX_PADS];
|
||||||
static u8 pad_type[MAX_PADS - 1] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE};
|
static u8 pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE};
|
||||||
|
|
||||||
|
static u8 hid_status[HID_COUNT];
|
||||||
|
static InputDataEx hid_data[HID_COUNT];
|
||||||
static int16_t analog_state[MAX_PADS][2][2];
|
static int16_t analog_state[MAX_PADS][2][2];
|
||||||
extern uint64_t lifecycle_state;
|
extern uint64_t lifecycle_state;
|
||||||
static bool wiiu_pad_inited = false;
|
static bool wiiu_pad_inited = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char* wiiu_joypad_name(unsigned pad)
|
static const char* wiiu_joypad_name(unsigned pad)
|
||||||
{
|
{
|
||||||
if (pad == 0)
|
if (pad == 0)
|
||||||
return "WIIU Gamepad";
|
return "WIIU Gamepad";
|
||||||
|
|
||||||
if (pad < MAX_PADS)
|
if (pad < MAX_PADS && pad < (HID_OFFSET) && pad > GAMEPAD_OFFSET)
|
||||||
{
|
{
|
||||||
switch (pad_type[pad - 1])
|
int i = pad - KPAD_OFFSET;
|
||||||
|
switch (pad_type[i])
|
||||||
{
|
{
|
||||||
case WIIUINPUT_TYPE_NONE:
|
case WIIUINPUT_TYPE_NONE:
|
||||||
return "N/A";
|
return "N/A";
|
||||||
|
@ -78,6 +87,10 @@ static const char* wiiu_joypad_name(unsigned pad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pad < MAX_PADS){
|
||||||
|
return "HID Controller";
|
||||||
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +104,7 @@ static void wiiu_joypad_autodetect_add(unsigned autoconf_pad)
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
))
|
))
|
||||||
input_config_set_device_name(autoconf_pad, wiiu_joypad_name(autoconf_pad));
|
input_config_set_device_name(autoconf_pad, wiiu_joypad_name(autoconf_pad));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wiiu_joypad_button(unsigned port_num, uint16_t key)
|
static bool wiiu_joypad_button(unsigned port_num, uint16_t key)
|
||||||
|
@ -161,7 +174,6 @@ static void wiiu_joypad_poll(void)
|
||||||
VPADStatus vpad;
|
VPADStatus vpad;
|
||||||
VPADReadError vpadError;
|
VPADReadError vpadError;
|
||||||
VPADRead(0, &vpad, 1, &vpadError);
|
VPADRead(0, &vpad, 1, &vpadError);
|
||||||
setControllerDataFromHID(&vpad);
|
|
||||||
vpadError = VPAD_READ_SUCCESS;
|
vpadError = VPAD_READ_SUCCESS;
|
||||||
if (!vpadError)
|
if (!vpadError)
|
||||||
{
|
{
|
||||||
|
@ -230,11 +242,40 @@ static void wiiu_joypad_poll(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(hid_data,0,sizeof(hid_data));
|
||||||
|
int result = gettingInputAllDevicesEx(hid_data,HID_COUNT);
|
||||||
|
|
||||||
|
if(result+HID_OFFSET > MAX_PADS){
|
||||||
|
result = MAX_PADS - HID_OFFSET;
|
||||||
|
}
|
||||||
|
for(int i = HID_OFFSET;i<result+HID_OFFSET;i++){
|
||||||
|
int hid_index = i-HID_OFFSET;
|
||||||
|
u8 old_status = hid_status[hid_index];
|
||||||
|
u8 new_status = hid_data[hid_index].status; //TODO: defines for the status.
|
||||||
|
|
||||||
|
if(old_status == 1 || new_status == 1){
|
||||||
|
hid_status[hid_index] = new_status;
|
||||||
|
if(old_status == 0 && new_status == 1){ //Pas 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 is 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wiiu_joypad_init(void* data)
|
static bool wiiu_joypad_init(void* data)
|
||||||
{
|
{
|
||||||
wiiu_joypad_autodetect_add(0);
|
wiiu_joypad_autodetect_add(0);
|
||||||
|
memset(hid_status,0,sizeof(hid_status));
|
||||||
|
|
||||||
wiiu_joypad_poll();
|
wiiu_joypad_poll();
|
||||||
wiiu_pad_inited = true;
|
wiiu_pad_inited = true;
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
|
@ -540,6 +540,7 @@ const char* const input_builtin_autoconfs[] =
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIIU
|
#ifdef WIIU
|
||||||
DECL_AUTOCONF_DEVICE("WIIU Gamepad", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
|
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("WIIU Pro Controller", "wiiu", WIIUINPUT_PRO_CONTROLLER_DEFAULT_BINDS),
|
||||||
DECL_AUTOCONF_DEVICE("Wiimote Controller", "wiiu", WIIUINPUT_WIIMOTE_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("Nunchuk Controller", "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS),
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit adfde9f3a9c61a0191cdea0a9d5f510a45c9c321
|
Subproject commit 48c554a9dd2aa2e262ddd681fc50beb2be5c44b6
|
Loading…
Reference in New Issue