Figured out the cause of crash

== DETAILS
cause of crash: trying to deference init when it's null
the reason it was going into deregister: the HID/VID lookup was
failing because it wasn't getting initialized first
cause of 2nd crash: the "end of pad list" method looked for an entry
with a magic value, so we add an end marker
This commit is contained in:
Nathan Strong 2021-10-04 00:01:46 +00:00
parent a4d8ce7753
commit c832828ddb
3 changed files with 9 additions and 2 deletions

View File

@ -143,10 +143,15 @@ void init_pad_map() {
pad_map[12].pid = PID_HORI_MINI_WIRED_PS4;
}
joypad_connection_entry_t *find_connection_entry(int16_t vid, int16_t pid, const char *name) {
unsigned i;
const bool has_name = !string_is_empty(name);
if(pad_map[0].vid == 0) {
init_pad_map();
}
for(i = 0; pad_map[i].name != NULL; i++) {
const char *name_match = has_name ? strstr(pad_map[i].name, name) : NULL;
/* The Wii Pro Controller and Wii U pro controller have the same VID/PID, so we have to use the
@ -169,9 +174,10 @@ void pad_connection_pad_deregister(joypad_connection_t *joyconn, pad_connection_
int i;
RARCH_LOG("pad_connection_pad_deregister\n");
RARCH_LOG("joyconn: 0x%08lx iface: 0x%08lx pad_data: 0x%08lx\n", (unsigned long)joyconn, (unsigned long)iface, (unsigned long)pad_data);
for(i = 0; !joypad_is_end_of_list(&joyconn[i]); i++) {
RARCH_LOG("joyconn[i].connected = %d, joyconn[i].iface == iface = %d\n", joyconn[i].connected, joyconn[i].iface == iface);
if(joyconn[i].connected && joyconn[i].iface == iface) {
if(joyconn[i].connected && joyconn[i].iface == iface && iface != NULL) {
if(iface->set_rumble) {
RARCH_LOG("set_rumble");
iface->set_rumble(joyconn[i].connection, RETRO_RUMBLE_STRONG, 0);

View File

@ -25,6 +25,7 @@ wiiu_joypad_t joypad_state = {0};
static void *wiiu_joypad_init(void *data)
{
memset(&joypad_state, 0, sizeof(wiiu_joypad_t));
joypad_state.pads[MAX_USERS].data = (void *)0xdeadbeef;
joypad_state.max_slot = MAX_USERS;
input_hid_init_first();

View File

@ -93,7 +93,7 @@ typedef struct wiiu_hidpad {
} wiiu_hidpad_t;
typedef struct wiiu_joypad {
joypad_connection_t pads[MAX_USERS];
joypad_connection_t pads[MAX_USERS+1];
int max_slot;
wiiu_kpad_t kpad;