mirror of https://github.com/mpv-player/mpv
parent
4295141703
commit
c4ff675198
|
@ -598,7 +598,8 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale,
|
||||||
int scale_units)
|
int scale_units)
|
||||||
{
|
{
|
||||||
int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP);
|
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)) {
|
if (mp_msg_test(ictx->log, MSGL_TRACE)) {
|
||||||
char *key = mp_input_get_key_name(code);
|
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;
|
return;
|
||||||
|
|
||||||
// Don't emit a command on key-down if the key is designed to emit commands
|
// 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
|
// on key-up (like mouse buttons), or setting key state only without emitting commands.
|
||||||
// be sent both on key down and key up, still emit the command.
|
// Also, if the command specifically should be sent both on key down and key up,
|
||||||
if (cmd->emit_on_up && !cmd->def->on_updown) {
|
// still emit the command.
|
||||||
|
if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) {
|
||||||
talloc_free(cmd);
|
talloc_free(cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,9 @@
|
||||||
// or don't use MP_KEY_STATE_DOWN in the first place.
|
// or don't use MP_KEY_STATE_DOWN in the first place.
|
||||||
#define MP_KEY_STATE_UP (1u<<29)
|
#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 | \
|
#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
|
||||||
MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
|
MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
|
||||||
MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
|
MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
|
||||||
|
|
Loading…
Reference in New Issue