History

input: add MP_KEY_STATE_SET_ONLY

Trivial.

nanahi committed 2 years ago

Commit c4ff6751 parent 42951412 files · +9 −4Browse files

Showing the changes to input (2 of 2 files). Show all

Unified · Split

2 files
  1. input/input.c +6 −4
  2. input/keycodes.h +3 −0
input/input.c+6−4
@@ -598,7 +598,8 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, · 597 unmodified lines
598598 int scale_units)
599599 {
600600 int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP);
601− code = code & ~(unsigned)state;
601+ bool no_emit = code & MP_KEY_STATE_SET_ONLY;
602+ code = code & ~(unsigned)(state | MP_KEY_STATE_SET_ONLY);
602603
603604 if (mp_msg_test(ictx->log, MSGL_TRACE)) {
604605 char *key = mp_input_get_key_name(code);
@@ -648,9 +649,10 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, · 43 unmodified lines
648649 return;
649650
650651 // Don't emit a command on key-down if the key is designed to emit commands
651− // on key-up (like mouse buttons). Also, if the command specifically should
652− // be sent both on key down and key up, still emit the command.
653− if (cmd->emit_on_up && !cmd->def->on_updown) {
652+ // on key-up (like mouse buttons), or setting key state only without emitting commands.
653+ // Also, if the command specifically should be sent both on key down and key up,
654+ // still emit the command.
655+ if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) {
654656 talloc_free(cmd);
655657 return;
656658 }
input/keycodes.h+3−0
@@ -251,6 +251,9 @@ · 250 unmodified lines
251251 // or don't use MP_KEY_STATE_DOWN in the first place.
252252 #define MP_KEY_STATE_UP (1u<<29)
253253
254+// Only set the key state without triggering key bindings.
255+#define MP_KEY_STATE_SET_ONLY (1u<<30)
256+
254257 #define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
255258 MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
256259 MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t