aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2023-01-29 21:49:23 +0000
committerneonloop2023-01-29 21:49:23 +0000
commit436f55f7975cf6ab5c8308c5071086047b46201e (patch)
treeae71269188f866f8bc65d4b24180089827147d1d
parent67740303f51ca3e5aa7edb19d1d2760990bf0b0c (diff)
downloadpicoarch-436f55f7975cf6ab5c8308c5071086047b46201e.tar.gz
picoarch-436f55f7975cf6ab5c8308c5071086047b46201e.tar.bz2
picoarch-436f55f7975cf6ab5c8308c5071086047b46201e.zip
Fixes binding keys after first combo keybinding
After first combo keybinding, mods_bound is still empty so mod key release is missed. Instead, keep combos enabled until binding menu is exited.
-rw-r--r--patches/libpicofe/0001-key-combos.patch69
1 files changed, 46 insertions, 23 deletions
diff --git a/patches/libpicofe/0001-key-combos.patch b/patches/libpicofe/0001-key-combos.patch
index ba95c81..a274ae8 100644
--- a/patches/libpicofe/0001-key-combos.patch
+++ b/patches/libpicofe/0001-key-combos.patch
@@ -1,5 +1,5 @@
diff --git a/in_sdl.c b/in_sdl.c
-index a84c781..4813cc0 100644
+index a84c781..4dddfd9 100644
--- a/in_sdl.c
+++ b/in_sdl.c
@@ -19,14 +19,24 @@
@@ -191,6 +191,14 @@ index a84c781..4813cc0 100644
+ if (!pdata->mod_key)
+ return;
+
++ if (state->delayed_key != 0) {
++ delayed_event.type = SDL_KEYUP;
++ delayed_event.key.state = SDL_RELEASED;
++ delayed_event.key.keysym.sym = state->delayed_key;
++ SDL_PushEvent(&delayed_event);
++ state->delayed_key = 0;
++ }
++
+ if (!state->allow_unbound_mods && state->mods_bound) {
+ int bound = 0;
+ for (i = 0; i < pdata->modmap_size; i++) {
@@ -212,14 +220,6 @@ index a84c781..4813cc0 100644
+
+ count = SDL_PeepEvents(events, (sizeof(events) / sizeof(events[0])), SDL_GETEVENT, mask);
+
-+ if (state->delayed_key != 0) {
-+ delayed_event.type = SDL_KEYUP;
-+ delayed_event.key.state = SDL_RELEASED;
-+ delayed_event.key.keysym.sym = state->delayed_key;
-+ SDL_PushEvent(&delayed_event);
-+ state->delayed_key = 0;
-+ }
-+
+ for (i = 0; i < count; i++) {
+ translate_combo_event(state, &events[i], keystate);
+ }
@@ -353,29 +353,52 @@ index 360b65b..f95ddf0 100644
/* to be called by drivers */
diff --git a/menu.c b/menu.c
-index 3c98f1f..a506d27 100644
+index e91f84a..5c81a5f 100644
--- a/menu.c
+++ b/menu.c
@@ -1455,6 +1455,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0;
int dev_id, bind_dev_id, dev_count, kc, is_down, mkey;
int unbind, bindtype, mask_shift;
-+ int allow_unbound_mods = 0;
++ int allow_unbound_mods[IN_MAX_DEVS] = {0};
for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {
if (in_get_dev_name(i, 1, 0) != NULL) {
-@@ -1515,10 +1516,14 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
-
- draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 1);
+@@ -1475,6 +1476,12 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
+ mask_shift = 16;
+ bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU;
-+ in_get_config(bind_dev_id, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, &allow_unbound_mods);
-+ in_set_config_int(bind_dev_id, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, 1);
- /* wait for some up event */
- for (is_down = 1; is_down; )
- kc = in_update_keycode(&bind_dev_id, &is_down, NULL, -1);
-
-+ in_set_config_int(bind_dev_id, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, allow_unbound_mods);
++ for (i = 0; i < IN_MAX_DEVS; i++)
++ {
++ in_get_config(i, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, &allow_unbound_mods[i]);
++ in_set_config_int(i, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, 1);
++ }
++
+ for (;;)
+ {
+ draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);
+@@ -1500,10 +1507,10 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
+ }
+ continue;
+ case PBTN_MBACK:
+- return;
++ goto finish;
+ case PBTN_MOK:
+ if (sel >= opt_cnt)
+- return;
++ goto finish;
+ while (in_menu_wait_any(NULL, 30) & PBTN_MOK)
+ ;
+ break;
+@@ -1536,5 +1543,11 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
+ if (dev_id != -1)
+ dev_id = bind_dev_id;
+ }
+
- i = count_bound_keys(bind_dev_id, opts[sel].mask << mask_shift, bindtype);
- unbind = (i > 0);
++finish:
++ for (i = 0; i < IN_MAX_DEVS; i++)
++ {
++ in_set_config_int(i, IN_CFG_ALLOW_UNBOUND_MOD_KEYS, allow_unbound_mods[i]);
++ }
+ }