0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

input: add MP_KEY_STATE_SET_ONLY

Trivial.
This commit is contained in:
nanahi 2024-09-07 07:51:51 -04:00 committed by Dudemanguy
parent 4295141703
commit c4ff675198
2 changed files with 9 additions and 4 deletions

View File

@ -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;
}

View File

@ -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)