From 86a086ed64aadc1e87fc58a90703a07d91c9cdbe Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 13 Oct 2024 20:04:56 +0200 Subject: [PATCH] automatically map input devs of same type to different players --- input.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/input.c b/input.c index 4bf2e32..a39f3b5 100644 --- a/input.c +++ b/input.c @@ -41,6 +41,7 @@ static int in_driver_count = 0; static int in_dev_count = 0; /* probed + bind devices */ static int in_have_async_devs = 0; static int in_probe_dev_id; +static int in_probe_dev_ix; static int menu_key_state = 0; static int menu_last_used_dev = 0; static int menu_key_prev = 0; @@ -69,8 +70,13 @@ static int *in_alloc_binds(int drv_id, int key_count) && defbinds[i].bit == 0) break; - binds_d[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] |= - 1 << defbinds[i].bit; + if (defbinds[i].btype == IN_BINDTYPE_PLAYER12) { + unsigned btype = IN_BINDTYPE_PLAYER12 + (in_probe_dev_ix >= 2); + binds_d[IN_BIND_OFFS(defbinds[i].code, btype)] |= + 1 <<(defbinds[i].bit + (in_probe_dev_ix&1)*16); + } else + binds_d[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] |= + 1 << defbinds[i].bit; } } @@ -170,6 +176,7 @@ update: in_devices[i].binds = NULL; } } + in_probe_dev_ix ++; } /* key combo handling, to be called by drivers that support it. @@ -252,6 +259,7 @@ void in_probe(void) for (i = 0; i < in_driver_count; i++) { in_probe_dev_id = i; + in_probe_dev_ix = 0; in_drivers[i].probe(&DRV(i)); } -- 2.39.5