summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorxylosper <darklin20@gmail.com>2015-01-24 05:45:13 +0900
committerwm4 <wm4@nowhere>2015-01-23 22:07:47 +0100
commit4a1a0e98d8f7ce8e1ab61ff740699cce9bb43f70 (patch)
treef09036422b389247b0dbfa5f231bbeea8f09998f /player/command.c
parenta0a40eb2872d137898e6f96b8d46490f2e63071f (diff)
downloadmpv-4a1a0e98d8f7ce8e1ab61ff740699cce9bb43f70.tar.bz2
mpv-4a1a0e98d8f7ce8e1ab61ff740699cce9bb43f70.tar.xz
input, player: new command for mouse event
New command `mouse <x> <y> [<button> [single|double]]` is introduced. This will update mouse position with given coordinate (`<x>`, `<y>`), and additionally, send single-click or double-click event if `<button>` is given.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index e7ecb4d375..556a0c4308 100644
--- a/player/command.c
+++ b/player/command.c
@@ -39,6 +39,7 @@
#include "osdep/timer.h"
#include "common/common.h"
#include "input/input.h"
+#include "input/keycodes.h"
#include "stream/stream.h"
#include "demux/demux.h"
#include "demux/stheader.h"
@@ -4711,6 +4712,24 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
mp_hook_run(mpctx, cmd->sender, cmd->args[0].v.s);
break;
+ case MP_CMD_MOUSE: {
+ const int x = cmd->args[0].v.i, y = cmd->args[1].v.i;
+ int button = cmd->args[2].v.i;
+ if (button == -1) {// no button
+ mp_input_set_mouse_pos(mpctx->input, x, y);
+ break;
+ }
+ if (button < 0 || button >= 20) {// invalid button
+ MP_ERR(mpctx, "%d is not a valid mouse button number.\n", button);
+ return -1;
+ }
+ const bool dbc = cmd->args[3].v.i;
+ button += dbc ? MP_MOUSE_BASE_DBL : MP_MOUSE_BASE;
+ mp_input_set_mouse_pos(mpctx->input, x, y);
+ mp_input_put_key(mpctx->input, button);
+ break;
+ }
+
default:
MP_VERBOSE(mpctx, "Received unknown cmd %s\n", cmd->name);
return -1;