mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Keep HID pads from clobbering gamepad/wiimotes
== DETAILS Trying to do weird pad math just wasn't working so I bit the bullet and just let it allocate all 16 pads in the slot list, then just mark 0-4 as connected so that the slot allocator would start at 5. I can see it detect the pad, but no idea if it works. Out of time for today.
This commit is contained in:
parent
1eea48d0c8
commit
89c1ba7929
@ -40,14 +40,12 @@ typedef struct gca_pad_data
|
|||||||
uint8_t data[9]; // pad data
|
uint8_t data[9]; // pad data
|
||||||
uint32_t slot; // slot this pad occupies
|
uint32_t slot; // slot this pad occupies
|
||||||
uint32_t buttons; // digital button state
|
uint32_t buttons; // digital button state
|
||||||
char *name; // name of the pad
|
|
||||||
} gca_pad_t;
|
} gca_pad_t;
|
||||||
|
|
||||||
|
|
||||||
static void update_pad_state(wiiu_gca_instance_t *instance);
|
static void update_pad_state(wiiu_gca_instance_t *instance);
|
||||||
static joypad_connection_t *register_pad(wiiu_gca_instance_t *instance, int port);
|
static joypad_connection_t *register_pad(wiiu_gca_instance_t *instance, int port);
|
||||||
static void unregister_pad(wiiu_gca_instance_t *instance, int port);
|
static void unregister_pad(wiiu_gca_instance_t *instance, int port);
|
||||||
static void set_pad_name_for_port(gca_pad_t *pad, int port);
|
|
||||||
|
|
||||||
extern pad_connection_interface_t wiiu_gca_pad_connection;
|
extern pad_connection_interface_t wiiu_gca_pad_connection;
|
||||||
|
|
||||||
@ -91,10 +89,17 @@ static void wiiu_gca_handle_packet(void *data, uint8_t *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
wiiu_gca_instance_t *instance = (wiiu_gca_instance_t *)data;
|
wiiu_gca_instance_t *instance = (wiiu_gca_instance_t *)data;
|
||||||
if(!instance || !instance->online)
|
if(!instance || !instance->online)
|
||||||
|
{
|
||||||
|
RARCH_WARN("[gca]: instance null or not ready yet.\n");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(size > sizeof(instance->device_state))
|
if(size > sizeof(instance->device_state))
|
||||||
|
{
|
||||||
|
RARCH_WARN("[gca]: packet size %d is too big for buffer of size %d\n",
|
||||||
|
size, sizeof(instance->device_state));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(instance->device_state, buffer, size);
|
memcpy(instance->device_state, buffer, size);
|
||||||
update_pad_state(instance);
|
update_pad_state(instance);
|
||||||
@ -141,29 +146,6 @@ static void update_pad_state(wiiu_gca_instance_t *instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is kind of cheating because it's taking advantage of the fact that
|
|
||||||
* we know what the pad handle data format is. It'd be nice if the pad
|
|
||||||
* interface had a set_name function so this wouldn't be required.
|
|
||||||
*/
|
|
||||||
static void set_pad_name_for_port(gca_pad_t *pad, int port)
|
|
||||||
{
|
|
||||||
char buf[45];
|
|
||||||
|
|
||||||
if(port >= 4)
|
|
||||||
return;
|
|
||||||
|
|
||||||
snprintf(buf, 32, "Nintendo Gamecube Controller [GCA Port %d]", port);
|
|
||||||
if(pad->name)
|
|
||||||
{
|
|
||||||
free(pad->name);
|
|
||||||
pad->name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pad->name = strdup(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static joypad_connection_t *register_pad(wiiu_gca_instance_t *instance, int port) {
|
static joypad_connection_t *register_pad(wiiu_gca_instance_t *instance, int port) {
|
||||||
int slot;
|
int slot;
|
||||||
joypad_connection_t *result;
|
joypad_connection_t *result;
|
||||||
@ -185,7 +167,6 @@ static joypad_connection_t *register_pad(wiiu_gca_instance_t *instance, int port
|
|||||||
result = &(hid_instance.pad_list[slot]);
|
result = &(hid_instance.pad_list[slot]);
|
||||||
result->iface = &wiiu_gca_pad_connection;
|
result->iface = &wiiu_gca_pad_connection;
|
||||||
result->data = result->iface->init(instance, slot, hid_instance.os_driver);
|
result->data = result->iface->init(instance, slot, hid_instance.os_driver);
|
||||||
set_pad_name_for_port(result->data, port);
|
|
||||||
result->connected = true;
|
result->connected = true;
|
||||||
input_pad_connect(slot, hid_instance.pad_driver);
|
input_pad_connect(slot, hid_instance.pad_driver);
|
||||||
|
|
||||||
@ -243,12 +224,6 @@ static void wiiu_gca_pad_deinit(void *data)
|
|||||||
|
|
||||||
if(pad)
|
if(pad)
|
||||||
{
|
{
|
||||||
if(pad->name)
|
|
||||||
{
|
|
||||||
free(pad->name);
|
|
||||||
pad->name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(pad);
|
free(pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +313,7 @@ const char *wiiu_gca_get_name(void *data)
|
|||||||
{
|
{
|
||||||
gca_pad_t *pad = (gca_pad_t *)data;
|
gca_pad_t *pad = (gca_pad_t *)data;
|
||||||
|
|
||||||
return pad->name;
|
return "GameCube Controller";
|
||||||
}
|
}
|
||||||
|
|
||||||
pad_connection_interface_t wiiu_gca_pad_connection = {
|
pad_connection_interface_t wiiu_gca_pad_connection = {
|
||||||
|
@ -612,6 +612,7 @@ const char* const input_builtin_autoconfs[] =
|
|||||||
DECL_AUTOCONF_DEVICE(PAD_NAME_NUNCHUK, "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS),
|
DECL_AUTOCONF_DEVICE(PAD_NAME_NUNCHUK, "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS),
|
||||||
DECL_AUTOCONF_DEVICE(PAD_NAME_CLASSIC, "wiiu", WIIUINPUT_CLASSIC_CONTROLLER_DEFAULT_BINDS),
|
DECL_AUTOCONF_DEVICE(PAD_NAME_CLASSIC, "wiiu", WIIUINPUT_CLASSIC_CONTROLLER_DEFAULT_BINDS),
|
||||||
DECL_AUTOCONF_DEVICE(PAD_NAME_HID, "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
|
DECL_AUTOCONF_DEVICE(PAD_NAME_HID, "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
|
||||||
|
DECL_AUTOCONF_DEVICE("GameCube Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS),
|
||||||
#endif
|
#endif
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS),
|
DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS),
|
||||||
|
@ -29,23 +29,17 @@ static const char *hidpad_name(unsigned pad);
|
|||||||
|
|
||||||
static bool ready = false;
|
static bool ready = false;
|
||||||
|
|
||||||
static unsigned to_slot(unsigned pad)
|
|
||||||
{
|
|
||||||
return pad - (WIIU_WIIMOTE_CHANNELS+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool init_hid_driver(void)
|
static bool init_hid_driver(void)
|
||||||
{
|
{
|
||||||
unsigned connections_size = MAX_USERS - (WIIU_WIIMOTE_CHANNELS+1);
|
|
||||||
|
|
||||||
memset(&hid_instance, 0, sizeof(hid_instance));
|
memset(&hid_instance, 0, sizeof(hid_instance));
|
||||||
|
|
||||||
return hid_init(&hid_instance, &wiiu_hid, &hidpad_driver, connections_size);
|
return hid_init(&hid_instance, &wiiu_hid, &hidpad_driver, MAX_USERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hidpad_init(void *data)
|
static bool hidpad_init(void *data)
|
||||||
{
|
{
|
||||||
(void *)data;
|
(void *)data;
|
||||||
|
int i;
|
||||||
|
|
||||||
if(!init_hid_driver())
|
if(!init_hid_driver())
|
||||||
{
|
{
|
||||||
@ -53,6 +47,14 @@ static bool hidpad_init(void *data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* hid_instance.pad_list[0].connected = true; */
|
||||||
|
|
||||||
|
for(i = 0; i < (WIIU_WIIMOTE_CHANNELS+1); i++)
|
||||||
|
{
|
||||||
|
hid_instance.pad_list[i].connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
hidpad_poll();
|
hidpad_poll();
|
||||||
ready = true;
|
ready = true;
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ static bool hidpad_button(unsigned pad, uint16_t button)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
return hid_driver->button(hid_data, to_slot(pad), button);
|
return hid_driver->button(hid_data, pad, button);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -89,7 +91,7 @@ static void hidpad_get_buttons(unsigned pad, retro_bits_t *state)
|
|||||||
BIT256_CLEAR_ALL_PTR(state);
|
BIT256_CLEAR_ALL_PTR(state);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
hid_driver->get_buttons(hid_data, to_slot(pad), state);
|
hid_driver->get_buttons(hid_data, pad, state);
|
||||||
#endif
|
#endif
|
||||||
BIT256_CLEAR_ALL_PTR(state);
|
BIT256_CLEAR_ALL_PTR(state);
|
||||||
}
|
}
|
||||||
@ -100,7 +102,7 @@ static int16_t hidpad_axis(unsigned pad, uint32_t axis)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
return hid_driver->axis(hid_data, to_slot(pad), axis);
|
return hid_driver->axis(hid_data, pad, axis);
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@ -120,7 +122,7 @@ static const char *hidpad_name(unsigned pad)
|
|||||||
#if 1
|
#if 1
|
||||||
return PAD_NAME_HID;
|
return PAD_NAME_HID;
|
||||||
#else
|
#else
|
||||||
return hid_driver->name(hid_data, to_slot(pad));
|
return hid_driver->name(hid_data, pad);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,16 +328,12 @@ static void synchronized_process_adapters(wiiu_hid_t *hid)
|
|||||||
{
|
{
|
||||||
switch(adapter->state)
|
switch(adapter->state)
|
||||||
{
|
{
|
||||||
case ADAPTER_STATE_DONE:
|
|
||||||
break;
|
|
||||||
case ADAPTER_STATE_NEW:
|
case ADAPTER_STATE_NEW:
|
||||||
adapter->state = try_init_driver(adapter);
|
adapter->state = try_init_driver(adapter);
|
||||||
break;
|
break;
|
||||||
case ADAPTER_STATE_READY:
|
case ADAPTER_STATE_READY:
|
||||||
case ADAPTER_STATE_READING:
|
case ADAPTER_STATE_READING:
|
||||||
#if 0
|
case ADAPTER_STATE_DONE:
|
||||||
adapter->driver->poll();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RARCH_ERR("[hid]: Invalid adapter state: %d\n", adapter->state);
|
RARCH_ERR("[hid]: Invalid adapter state: %d\n", adapter->state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user