mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Handle errors in qnx_input
I had errors with null driver. While this setup is not really usable, we shouldn't crash on it
This commit is contained in:
parent
c5e2099dd9
commit
ab34a0a34f
@ -306,18 +306,35 @@ static void qnx_handle_device(qnx_input_t *qnx,
|
||||
}
|
||||
|
||||
/* Find currently connected gamepads. */
|
||||
static void qnx_discover_controllers(qnx_input_t *qnx)
|
||||
static int qnx_discover_controllers(qnx_input_t *qnx)
|
||||
{
|
||||
/* Get an array of all available devices. */
|
||||
int deviceCount;
|
||||
int deviceCount = 0;
|
||||
int ret;
|
||||
unsigned i;
|
||||
|
||||
screen_get_context_property_iv(screen_ctx,
|
||||
ret = screen_get_context_property_iv(screen_ctx,
|
||||
SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount);
|
||||
if (ret < 0) {
|
||||
RARCH_ERR("Error querying SCREEN_PROPERTY_DEVICE_COUNT: [%d] %s\n",
|
||||
errno, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
screen_device_t* devices_found = (screen_device_t*)
|
||||
calloc(deviceCount, sizeof(screen_device_t));
|
||||
screen_get_context_property_pv(screen_ctx,
|
||||
if (!devices_found) {
|
||||
RARCH_ERR("Error allocating devices_found, deviceCount=%d\n",
|
||||
deviceCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = screen_get_context_property_pv(screen_ctx,
|
||||
SCREEN_PROPERTY_DEVICES, (void**)devices_found);
|
||||
if (ret < 0) {
|
||||
RARCH_ERR("Error querying SCREEN_PROPERTY_DEVICES: [%d] %s\n",
|
||||
errno, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Scan the list for gamepad and joystick devices. */
|
||||
for(i = 0; i < qnx->pads_connected; ++i)
|
||||
@ -347,6 +364,8 @@ static void qnx_discover_controllers(qnx_input_t *qnx)
|
||||
}
|
||||
|
||||
free(devices_found);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user