Prevent crash with udev driver

This commit is contained in:
twinaphex 2016-10-26 10:21:56 +02:00
parent 858f96d082
commit d6901685f7

View File

@ -467,9 +467,9 @@ static int16_t udev_analog_pressed(const struct retro_keybind *binds, unsigned i
input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus);
if (binds[id_minus].valid && udev_input_is_pressed(binds, id_minus))
if (binds && binds[id_minus].valid && udev_input_is_pressed(binds, id_minus))
pressed_minus = -0x7fff;
if (binds[id_plus].valid && udev_input_is_pressed(binds, id_plus))
if (binds && binds[id_plus].valid && udev_input_is_pressed(binds, id_plus))
pressed_plus = 0x7fff;
return pressed_plus + pressed_minus;
@ -519,13 +519,13 @@ static int16_t udev_input_state(void *data, const struct retro_keybind **binds,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
if (binds[port][id].valid)
if (binds[port] && binds[port][id].valid)
return udev_input_is_pressed(binds[port], id) ||
input_joypad_pressed(udev->joypad, port, binds[port], id);
break;
case RETRO_DEVICE_ANALOG:
ret = udev_analog_pressed(binds[port], idx, id);
if (!ret)
if (!ret && binds[port])
ret = input_joypad_analog(udev->joypad, port, idx, id, binds[port]);
return ret;