summaryrefslogtreecommitdiffstats
path: root/core/input/keycodes.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-26 02:13:30 +0200
committerwm4 <wm4@nowhere>2013-06-29 22:58:13 +0200
commit5b38a522f17aa24d89b807846c2f76760923351f (patch)
tree44fc0bf235cb6df8e8bdf3a4dc19fdd616553081 /core/input/keycodes.h
parentd4680aaecdc8711a878d973c74e223d49cdf9da3 (diff)
downloadmpv-5b38a522f17aa24d89b807846c2f76760923351f.tar.bz2
mpv-5b38a522f17aa24d89b807846c2f76760923351f.tar.xz
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command ("set_mouse_pos"), which was specially handled in command.c. This was once special-cased to the dvdnav and menu code, and did nothing after libmenu and dvdnav were removed. Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"), which then can be bound to an arbitrary command. The mouse position is now managed in input.c. A command which actually needs the mouse position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos() to query it. The former returns raw window-space coordinates, while the latter returns coordinates transformed to OSD- space. (Both are the same for most VOs, except vo_xv and vo_x11, which can't render OSD in window-space. These require extra code for mapping mouse position.) As of this commit, there is still nothing that uses mouse movement, so MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the mouse (much like MOUSE_BTN0). Extend the concept of input sections. Allow multiple sections to be active at once, and organize them as stack. Bindings from the top of the stack are preferred to lower ones. Each section has a mouse input section associated, inside which mouse events are associated with the bindings. If the mouse pointer is outside of a section's mouse area, mouse events will be dispatched to an input section lower on the stack of active sections. This is intended for scripting, which is to be added later. Two scripts could occupy different areas of the screen without conflicting with each other. (If it turns out that this mechanism is useless, we'll just remove it again.)
Diffstat (limited to 'core/input/keycodes.h')
-rw-r--r--core/input/keycodes.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/core/input/keycodes.h b/core/input/keycodes.h
index 92608aa6fa..b086d82809 100644
--- a/core/input/keycodes.h
+++ b/core/input/keycodes.h
@@ -126,7 +126,7 @@
// Mouse events from VOs
-#define MP_MOUSE_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY)
+#define MP_MOUSE_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
#define MP_MOUSE_BTN0 (MP_MOUSE_BASE+0)
#define MP_MOUSE_BTN1 (MP_MOUSE_BASE+1)
#define MP_MOUSE_BTN2 (MP_MOUSE_BASE+2)
@@ -149,6 +149,9 @@
#define MP_MOUSE_BTN19 (MP_MOUSE_BASE+19)
#define MP_MOUSE_BTN_END (MP_MOUSE_BASE+20)
+#define MP_KEY_IS_MOUSE_BTN_SINGLE(code) \
+ ((code) >= MP_MOUSE_BASE && (code) < MP_MOUSE_BTN_END)
+
#define MP_MOUSE_BASE_DBL ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
#define MP_MOUSE_BTN0_DBL (MP_MOUSE_BASE_DBL+0)
#define MP_MOUSE_BTN1_DBL (MP_MOUSE_BASE_DBL+1)
@@ -172,6 +175,9 @@
#define MP_MOUSE_BTN19_DBL (MP_MOUSE_BASE_DBL+19)
#define MP_MOUSE_BTN_DBL_END (MP_MOUSE_BASE_DBL+20)
+#define MP_KEY_IS_MOUSE_BTN_DBL(code) \
+ ((code) >= MP_MOUSE_BTN0_DBL && (code) < MP_MOUSE_BTN_DBL_END)
+
// Apple Remote input module
#define MP_AR_BASE (MP_KEY_BASE+0xE0)
#define MP_AR_PLAY (MP_AR_BASE + 0)
@@ -198,6 +204,13 @@
/* Special keys */
#define MP_KEY_INTERN (MP_KEY_BASE+0x1000)
#define MP_KEY_CLOSE_WIN (MP_KEY_INTERN+0)
+// Generated by input.c (VOs use mp_input_set_mouse_pos())
+#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
+
+
+#define MP_KEY_DEPENDS_ON_MOUSE_POS(code) \
+ (MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code) || \
+ (code) == MP_KEY_MOUSE_MOVE)
/* Modifiers added to individual keys */
#define MP_KEY_MODIFIER_SHIFT (1<<22)
@@ -208,13 +221,19 @@
#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META)
-// Use this when the key shouldn't be auto-repeated (like mouse buttons)
-// This is not a modifier, but is part of the keycode itself.
-#define MP_NO_REPEAT_KEY (1<<28)
-
// Flag for key events. Multiple down events are idempotent. Release keys by
// sending the key code without this flag, or by sending MP_INPUT_RELEASE_ALL
// as key code.
-#define MP_KEY_STATE_DOWN (1<<29)
+#define MP_KEY_STATE_DOWN (1<<26)
+
+// The following flags are not modifiers, but are part of the keycode itself.
+
+// Emit a command even on key-up (normally key-up is ignored). The command
+// handling code has to ignore unwanted commands specifically.
+#define MP_KEY_EMIT_ON_UP (1<<27)
+
+// Use this when the key shouldn't be auto-repeated (like mouse buttons)
+// Also means both key-down key-up events produce emit bound commands.
+#define MP_NO_REPEAT_KEY (1<<28)
#endif /* MPLAYER_KEYCODES_H */