(Apple) Input - some cleanups

This commit is contained in:
twinaphex 2014-05-13 13:49:29 +02:00
parent d236552aeb
commit 277b1f6702
2 changed files with 9 additions and 5 deletions

View File

@ -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);

View File

@ -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;
}