History

input: add MP_KEY_STATE_SET_ONLY

Trivial.

nanahi committed 2 years ago

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

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
598 int scale_units)598 int scale_units)
599{599{
600 int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP);600 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);
602 603
603 if (mp_msg_test(ictx->log, MSGL_TRACE)) {604 if (mp_msg_test(ictx->log, MSGL_TRACE)) {
604 char *key = mp_input_get_key_name(code);605 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
648 return;649 return;
649 650
650 // Don't emit a command on key-down if the key is designed to emit commands651 // 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 should652 // on key-up (like mouse buttons), or setting key state only without emitting commands.
652 // be sent both on key down and key up, still emit the command.653 // Also, if the command specifically should be sent both on key down and key up,
653 if (cmd->emit_on_up && !cmd->def->on_updown) {654 // still emit the command.
655 if ((cmd->emit_on_up && !cmd->def->on_updown) || no_emit) {
654 talloc_free(cmd);656 talloc_free(cmd);
655 return;657 return;
656 }658 }
input/keycodes.h+3−0
@@ -251,6 +251,9 @@ · 250 unmodified lines
251// or don't use MP_KEY_STATE_DOWN in the first place.251// or don't use MP_KEY_STATE_DOWN in the first place.
252#define MP_KEY_STATE_UP (1u<<29)252#define MP_KEY_STATE_UP (1u<<29)
253 253
254// Only set the key state without triggering key bindings.
255#define MP_KEY_STATE_SET_ONLY (1u<<30)
256
254#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \257#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
255 MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \258 MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
256 MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)259 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