mirror of https://github.com/mpv-player/mpv
input: add value argument for mp_input_put_key_artificial
This commit is contained in:
parent
ba547cb098
commit
a08e8e0b46
|
@ -757,10 +757,12 @@ void mp_input_put_key(struct input_ctx *ictx, int code)
|
|||
input_unlock(ictx);
|
||||
}
|
||||
|
||||
void mp_input_put_key_artificial(struct input_ctx *ictx, int code)
|
||||
void mp_input_put_key_artificial(struct input_ctx *ictx, int code, double value)
|
||||
{
|
||||
if (value == 0.0)
|
||||
return;
|
||||
input_lock(ictx);
|
||||
mp_input_feed_key(ictx, code, 1, true);
|
||||
mp_input_feed_key(ictx, code, value, true);
|
||||
input_unlock(ictx);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,8 @@ void mp_input_src_feed_cmd_text(struct mp_input_src *src, char *buf, size_t len)
|
|||
void mp_input_put_key(struct input_ctx *ictx, int code);
|
||||
|
||||
// Like mp_input_put_key(), but ignore mouse disable option for mouse buttons.
|
||||
void mp_input_put_key_artificial(struct input_ctx *ictx, int code);
|
||||
// value can be used like with mp_input_put_wheel(), use 1 if not applicable.
|
||||
void mp_input_put_key_artificial(struct input_ctx *ictx, int code, double value);
|
||||
|
||||
// Like mp_input_put_key(), but process all UTF-8 characters in the given
|
||||
// string as key events.
|
||||
|
|
|
@ -6158,7 +6158,7 @@ static void cmd_mouse(void *p)
|
|||
|
||||
if (button == -1) {// no button
|
||||
if (pre_key)
|
||||
mp_input_put_key_artificial(mpctx->input, pre_key);
|
||||
mp_input_put_key_artificial(mpctx->input, pre_key, 1);
|
||||
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
|
||||
return;
|
||||
}
|
||||
|
@ -6176,9 +6176,9 @@ static void cmd_mouse(void *p)
|
|||
}
|
||||
button += dbc ? MP_MBTN_DBL_BASE : MP_MBTN_BASE;
|
||||
if (pre_key)
|
||||
mp_input_put_key_artificial(mpctx->input, pre_key);
|
||||
mp_input_put_key_artificial(mpctx->input, pre_key, 1);
|
||||
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
|
||||
mp_input_put_key_artificial(mpctx->input, button);
|
||||
mp_input_put_key_artificial(mpctx->input, button, 1);
|
||||
}
|
||||
|
||||
static void cmd_key(void *p)
|
||||
|
@ -6189,7 +6189,7 @@ static void cmd_key(void *p)
|
|||
|
||||
const char *key_name = cmd->args[0].v.s;
|
||||
if (key_name[0] == '\0' && action == MP_KEY_STATE_UP) {
|
||||
mp_input_put_key_artificial(mpctx->input, MP_INPUT_RELEASE_ALL);
|
||||
mp_input_put_key_artificial(mpctx->input, MP_INPUT_RELEASE_ALL, 1);
|
||||
} else {
|
||||
int code = mp_input_get_key_from_name(key_name);
|
||||
if (code < 0) {
|
||||
|
@ -6197,7 +6197,7 @@ static void cmd_key(void *p)
|
|||
cmd->success = false;
|
||||
return;
|
||||
}
|
||||
mp_input_put_key_artificial(mpctx->input, code | action);
|
||||
mp_input_put_key_artificial(mpctx->input, code | action, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue