summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-19 12:12:20 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-20 19:02:24 +0200
commit67fd58d6f01ad84387421e2fc861c28dcf5c4f3c (patch)
treef1b93bc0ac9effc590771ce86aacc09eb050fbc1 /libvo
parentb4564c2d4fdc14f1fcb6987b8f57a2c27a08bf54 (diff)
downloadmpv-67fd58d6f01ad84387421e2fc861c28dcf5c4f3c.tar.bz2
mpv-67fd58d6f01ad84387421e2fc861c28dcf5c4f3c.tar.xz
input: support bindings with modifier keys for X input
Add support for binding commands to modifier+key combinations like "Shift+Left" or "Ctrl+Alt+x", and support reading such combinations from the output window of X VOs. The recognized modifier names are Shift, Ctrl, Alt and Meta. Any combination of those and then a non-modifier key name, separated by '+', is accepted as a key name in input.conf. For non-special keys that produce characters shift is ignored as a modifier. For example "A" is handled as a key without modifiers even if you use shift to write the capital letter; 'a' vs 'A' already distinguishes the combinations with a normal keymap, and having separate 'a', 'Shift+A' and 'A' (written with caps lock for example) would bring more confusion than benefit. Currently reading the modifier+key combinations is only supported in the output window of those VOs that use x11_common.c event handling. It's not possible to input the key combinations in other VOs or in a terminal window.
Diffstat (limited to 'libvo')
-rw-r--r--libvo/x11_common.c21
-rw-r--r--libvo/x11_common.h2
2 files changed, 15 insertions, 8 deletions
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index b7fbb72307..596645662c 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -540,12 +540,12 @@ static const struct mp_keymap keysym_map[] = {
{0, 0}
};
-static void vo_x11_putkey_ext(struct vo *vo, int keysym)
+static void vo_x11_putkey_ext(struct vo *vo, int keysym, int modifiers)
{
struct mp_fifo *f = vo->key_fifo;
int mpkey = lookup_keymap_table(keysym_map, keysym);
if (mpkey)
- mplayer_put_key(f, mpkey);
+ mplayer_put_key(f, mpkey + modifiers);
}
#endif
@@ -584,7 +584,7 @@ static const struct mp_keymap keymap[] = {
{0, 0}
};
-void vo_x11_putkey(struct vo *vo, int key)
+static void vo_x11_putkey(struct vo *vo, int key, int modifiers)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -598,7 +598,7 @@ void vo_x11_putkey(struct vo *vo, int key)
mpkey = lookup_keymap_table(keymap, key);
if (mpkey)
- mplayer_put_key(vo->key_fifo, mpkey);
+ mplayer_put_key(vo->key_fifo, mpkey + modifiers);
}
@@ -814,13 +814,22 @@ int vo_x11_check_events(struct vo *vo)
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
&x11->compose_status);
+ int modifiers = 0;
+ if (Event.xkey.state & ShiftMask)
+ modifiers |= KEY_MODIFIER_SHIFT;
+ if (Event.xkey.state & ControlMask)
+ modifiers |= KEY_MODIFIER_CTRL;
+ if (Event.xkey.state & Mod1Mask)
+ modifiers |= KEY_MODIFIER_ALT;
+ if (Event.xkey.state & Mod4Mask)
+ modifiers |= KEY_MODIFIER_META;
#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(vo, keySym);
+ vo_x11_putkey_ext(vo, keySym, modifiers);
#endif
key =
((keySym & 0xff00) !=
0 ? ((keySym & 0x00ff) + 256) : (keySym));
- vo_x11_putkey(vo, key);
+ vo_x11_putkey(vo, key, modifiers);
ret |= VO_EVENT_KEYPRESS;
}
break;
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 57b1d79f33..824f55b4c8 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -170,8 +170,6 @@ void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str, const c
int xv_test_ck( void * arg );
int xv_test_ckm( void * arg );
-void vo_x11_putkey(struct vo *vo, int key);
-
#ifdef CONFIG_XF86VM
void vo_vm_switch(struct vo *vo);
void vo_vm_close(struct vo *vo);