diff --git a/input/input.c b/input/input.c index 686b672dce..68bb2b0859 100644 --- a/input/input.c +++ b/input/input.c @@ -598,7 +598,8 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, int scale_units) { int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP); - code = code & ~(unsigned)state; + bool no_emit = code & MP_KEY_STATE_SET_ONLY; + code = code & ~(unsigned)(state | MP_KEY_STATE_SET_ONLY); if (mp_msg_test(ictx->log, MSGL_TRACE)) { char *key = mp_input_get_key_name(code); @@ -648,9 +649,10 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, return; // Don't emit a command on key-down if the key is designed to emit commands - // on key-up (like mouse buttons). Also, if the command specifically should - // be sent both on key down and key up, still emit the command. - if (cmd->emit_on_up && !cmd->def->on_updown) { + // on key-up (like mouse buttons), or setting key state only without emitting commands. + // Also, if the command specifically should be sent both on key down and key up, + // still emit the command. + if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) { talloc_free(cmd); return; } diff --git a/input/keycodes.h b/input/keycodes.h index 93633e69de..e2384d6719 100644 --- a/input/keycodes.h +++ b/input/keycodes.h @@ -251,6 +251,9 @@ // or don't use MP_KEY_STATE_DOWN in the first place. #define MP_KEY_STATE_UP (1u<<29) +// Only set the key state without triggering key bindings. +#define MP_KEY_STATE_SET_ONLY (1u<<30) + #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \ MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \ MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)