From 0079b7b467ff6ba790f4db035be1f9c0178f5748 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 21 Mar 2011 00:53:19 +0200 Subject: [PATCH] frontend: input: kill "merge with defaults" behavior this is hard to maintain and reportedly buggy --- frontend/common/input.c | 49 +++-------------------------------------- frontend/common/input.h | 8 +++++-- 2 files changed, 9 insertions(+), 48 deletions(-) diff --git a/frontend/common/input.c b/frontend/common/input.c index 52505355..75eba0ff 100644 --- a/frontend/common/input.c +++ b/frontend/common/input.c @@ -764,32 +764,6 @@ int in_config_parse_dev(const char *name) return i; } -/* - * To reduce size of game specific configs, default binds are not saved. - * So we mark default binds in in_config_start(), override them in in_config_bind_key(), - * and restore whatever default binds are left in in_config_end(). - */ -void in_config_start(void) -{ - int i; - - /* mark all default binds, so they get overwritten by func below */ - for (i = 0; i < IN_MAX_DEVS; i++) { - int n, count, *binds, *def_binds; - - binds = in_devices[i].binds; - if (binds == NULL) - continue; - - count = in_devices[i].key_count; - def_binds = binds + count * IN_BINDTYPE_COUNT; - - for (n = 0; n < count * IN_BINDTYPE_COUNT; n++) - if (binds[n] == def_binds[n]) - binds[n] = -1; - } -} - int in_config_bind_key(int dev_id, const char *key, int acts, int bind_type) { in_dev_t *dev; @@ -812,7 +786,6 @@ int in_config_bind_key(int dev_id, const char *key, int acts, int bind_type) dev->binds = in_alloc_binds(dev->drv_id, dev->key_count); if (dev->binds == NULL) return -1; - in_config_start(); } kc = -1; @@ -852,37 +825,21 @@ int in_config_bind_key(int dev_id, const char *key, int acts, int bind_type) return 0; } -void in_config_end(void) +void in_clean_binds(void) { int i; for (i = 0; i < IN_MAX_DEVS; i++) { - int n, t, ret, count, *binds, *def_binds; + int ret, count, *binds, *def_binds; in_dev_t *dev = &in_devices[i]; - if (dev->binds == NULL) + if (dev->binds == NULL || dev->drv_data == NULL) continue; count = dev->key_count; binds = dev->binds; def_binds = binds + count * IN_BINDTYPE_COUNT; - for (n = 0; n < count; n++) { - int is_default = 1; - for (t = 0; t < IN_BINDTYPE_COUNT; t++) - if (binds[IN_BIND_OFFS(n, t)] == -1) - binds[IN_BIND_OFFS(n, t)] = 0; - else - is_default = 0; - - if (is_default) - for (t = 0; t < IN_BINDTYPE_COUNT; t++) - binds[IN_BIND_OFFS(n, t)] = def_binds[IN_BIND_OFFS(n, t)]; - } - - if (dev->drv_data == NULL) - continue; - ret = DRV(dev->drv_id).clean_binds(dev->drv_data, binds, def_binds); if (ret == 0) { /* no useable binds */ diff --git a/frontend/common/input.h b/frontend/common/input.h index 41ff8767..bcafaa51 100644 --- a/frontend/common/input.h +++ b/frontend/common/input.h @@ -1,3 +1,6 @@ +#ifndef INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc +#define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1 + #define IN_MAX_DEVS 10 /* unified menu keys */ @@ -105,16 +108,15 @@ int in_update(int *result); int in_update_keycode(int *dev_id, int *is_down, int timeout_ms); int in_menu_wait_any(int timeout_ms); int in_menu_wait(int interesting, int autorep_delay_ms); -void in_config_start(void); int in_config_parse_dev(const char *dev_name); int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type); -void in_config_end(void); int in_get_config(int dev_id, int what, void *val); int in_set_config(int dev_id, int what, const void *val, int size); int in_get_key_code(int dev_id, const char *key_name); int in_name_to_id(const char *dev_name); int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind); void in_unbind_all(int dev_id, int act_mask, int bind_type); +void in_clean_binds(void); void in_debug_dump(void); const int *in_get_dev_binds(int dev_id); @@ -126,3 +128,5 @@ const char *in_get_key_name(int dev_id, int keycode); int val_ = v; \ in_set_config(dev_id, what, &val_, sizeof(val_)); \ } + +#endif /* INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc */ -- 2.39.5