diff --git a/input/apple_input.c b/input/apple_input.c index 9bea6e61a8..6b18bb972d 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -575,7 +575,9 @@ static bool apple_bind_button_pressed(void *data, int key) static void apple_input_free_input(void *data) { (void)data; - g_joydriver->destroy(); + + if (g_joydriver && g_joydriver->destroy) + g_joydriver->destroy(); } static void apple_input_set_keybinds(void *data, unsigned device, unsigned port, @@ -640,7 +642,7 @@ static void apple_input_set_keybinds(void *data, unsigned device, unsigned port, { struct platform_bind *ret = (struct platform_bind*)data; - if (ret->joykey == NO_BTN) + if (ret && ret->joykey == NO_BTN) strlcpy(ret->desc, "No button", sizeof(ret->desc)); else snprintf(ret->desc, sizeof(ret->desc), "Button %llu", ret->joykey); diff --git a/input/apple_joypad.c b/input/apple_joypad.c index a3ec403a0a..0c6229c02c 100644 --- a/input/apple_joypad.c +++ b/input/apple_joypad.c @@ -56,7 +56,8 @@ static int32_t find_empty_slot(void) int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* connection) { - int32_t slot = find_empty_slot(); + int32_t slot; + slot = find_empty_slot(); if (slot >= 0 && slot < MAX_PLAYERS) { @@ -88,11 +89,12 @@ int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* conn int32_t apple_joypad_connect_gcapi(void) { - int32_t slot = find_empty_slot(); + int32_t slot; + slot = find_empty_slot(); if (slot >= 0 && slot < MAX_PLAYERS) { - joypad_slot_t* s = (joypad_slot_t*)&slots[slot]; + joypad_slot_t *s = (joypad_slot_t*)&slots[slot]; s->used = true; s->is_gcapi = true; }