input: handle unprobed devices better

This commit is contained in:
notaz 2012-11-11 22:08:38 +02:00
parent e515f1a40b
commit a4025790b5
2 changed files with 13 additions and 7 deletions

14
input.c
View file

@ -514,6 +514,9 @@ int in_get_config(int dev_id, int what, void *val)
case IN_CFG_KEY_NAMES: case IN_CFG_KEY_NAMES:
return -1; /* not implemented */ return -1; /* not implemented */
default: default:
if (!dev->probed)
return -1;
return DRV(dev->drv_id).get_config(dev->drv_data, what, ival); return DRV(dev->drv_id).get_config(dev->drv_data, what, ival);
} }
@ -527,9 +530,12 @@ static int in_set_blocking(int is_blocking)
/* have_async_devs means we will have to do all reads async anyway.. */ /* have_async_devs means we will have to do all reads async anyway.. */
if (!in_have_async_devs) { if (!in_have_async_devs) {
for (i = 0; i < in_dev_count; i++) { for (i = 0; i < in_dev_count; i++) {
if (in_devices[i].probed) if (!in_devices[i].probed)
DRV(in_devices[i].drv_id).set_config(in_devices[i].drv_data, continue;
IN_CFG_BLOCKING, is_blocking);
DRV(in_devices[i].drv_id).set_config(
in_devices[i].drv_data, IN_CFG_BLOCKING,
is_blocking);
} }
} }
@ -876,7 +882,7 @@ void in_clean_binds(void)
int ret, count, *binds, *def_binds; int ret, count, *binds, *def_binds;
in_dev_t *dev = &in_devices[i]; in_dev_t *dev = &in_devices[i];
if (dev->binds == NULL || dev->drv_data == NULL) if (dev->binds == NULL || !dev->probed)
continue; continue;
count = dev->key_count; count = dev->key_count;

6
menu.c
View file

@ -1307,7 +1307,7 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
if (dev_id < 0) if (dev_id < 0)
dev_name = "(all devices)"; dev_name = "(all devices)";
else else
dev_name = in_get_dev_name(dev_id, 1, 1); dev_name = in_get_dev_name(dev_id, 0, 1);
w = strlen(dev_name) * me_mfont_w; w = strlen(dev_name) * me_mfont_w;
if (w < 30 * me_mfont_w) if (w < 30 * me_mfont_w)
w = 30 * me_mfont_w; w = 30 * me_mfont_w;
@ -1370,7 +1370,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (i = 0, dev_id--; i < IN_MAX_DEVS + 1; i++, dev_id--) { for (i = 0, dev_id--; i < IN_MAX_DEVS + 1; i++, dev_id--) {
if (dev_id < -1) if (dev_id < -1)
dev_id = IN_MAX_DEVS - 1; dev_id = IN_MAX_DEVS - 1;
if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL) if (dev_id == -1 || in_get_dev_name(dev_id, 0, 0) != NULL)
break; break;
} }
continue; continue;
@ -1378,7 +1378,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) { for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) {
if (dev_id >= IN_MAX_DEVS) if (dev_id >= IN_MAX_DEVS)
dev_id = -1; dev_id = -1;
if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL) if (dev_id == -1 || in_get_dev_name(dev_id, 0, 0) != NULL)
break; break;
} }
continue; continue;