summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/input.rst4
-rw-r--r--DOCS/man/en/options.rst5
-rw-r--r--mpvcore/input/input.c11
-rw-r--r--mpvcore/input/input.h4
-rw-r--r--mpvcore/options.c1
-rw-r--r--mpvcore/options.h1
-rw-r--r--osdep/macosx_events.m10
-rw-r--r--video/out/vo_sdl.c8
-rw-r--r--video/out/w32_common.c2
9 files changed, 40 insertions, 6 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst
index 7d62784b97..ac93d01105 100644
--- a/DOCS/man/en/input.rst
+++ b/DOCS/man/en/input.rst
@@ -31,6 +31,10 @@ General Input Command Syntax
``[Shift+][Ctrl+][Alt+][Meta+]<key> [{<section>}] [<prefixes>] <command> (<argument>)* [; <command>]``
+Note that by default, the right Alt key can be used to create special
+characters, and thus does not register as a modifier. The option
+``--no-right-alt-gr`` changes this behavior.
+
Newlines always start a new binding. ``#`` starts a comment (outside of quoted
string arguments). To bind commands to the ``#`` key, ``SHARP`` can be used.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index fec8aa0575..15cba5e460 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1823,6 +1823,11 @@ OPTIONS
- ``--reset-on-next-file=""``
Do not reset pause mode.
+``--right-alt-gr``, ``--no-right-alt-gr``
+ (Cocoa and Windows only)
+ Use the right Alt key as Alt Gr to produce special characters. If disabled,
+ count the right Alt as an Alt modifier key. Enabled by default.
+
``--rtsp-transport=<lavf|udp|tcp|http>``
Select RTSP transport method (default: tcp). This selects the underlying
network transport when playing ``rtsp://...`` URLs. The value ``lavf``
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index c1711a94d8..8b31352f72 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -550,6 +550,7 @@ struct input_ctx {
pthread_mutex_t mutex;
struct mp_log *log;
+ bool using_alt_gr;
bool using_ar;
bool using_cocoa_media_keys;
@@ -635,6 +636,7 @@ const m_option_t mp_input_opts[] = {
OPT_FLAG("joystick", input.use_joystick, CONF_GLOBAL),
OPT_FLAG("lirc", input.use_lirc, CONF_GLOBAL),
OPT_FLAG("lircc", input.use_lircc, CONF_GLOBAL),
+ OPT_FLAG("right-alt-gr", input.use_alt_gr, CONF_GLOBAL),
#if HAVE_COCOA
OPT_FLAG("ar", input.use_ar, CONF_GLOBAL),
OPT_FLAG("media-keys", input.use_media_keys, CONF_GLOBAL),
@@ -2387,6 +2389,10 @@ struct input_ctx *mp_input_init(struct mpv_global *global)
}
#endif
+ if (input_conf->use_alt_gr) {
+ ictx->using_alt_gr = true;
+ }
+
#if HAVE_COCOA
if (input_conf->use_ar) {
cocoa_init_apple_remote();
@@ -2528,3 +2534,8 @@ unsigned int mp_input_get_mouse_event_counter(struct input_ctx *ictx)
input_unlock(ictx);
return ret;
}
+
+bool mp_input_use_alt_gr(struct input_ctx *ictx)
+{
+ return ictx->using_alt_gr;
+}
diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h
index 9e897abbbb..2465fe6010 100644
--- a/mpvcore/input/input.h
+++ b/mpvcore/input/input.h
@@ -287,6 +287,10 @@ void mp_input_wakeup(struct input_ctx *ictx);
// Interruptible usleep: (used by demux)
int mp_input_check_interrupt(struct input_ctx *ictx, int time);
+// If this returns true, use Right Alt key as Alt Gr to produce special
+// characters. If false, count Right Alt as the modifier Alt key.
+bool mp_input_use_alt_gr(struct input_ctx *ictx);
+
extern int async_quit_request;
#endif /* MPLAYER_INPUT_H */
diff --git a/mpvcore/options.c b/mpvcore/options.c
index c8112b496d..08b1f10fe2 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -873,6 +873,7 @@ const struct MPOpts mp_default_opts = {
.use_joystick = 1,
.use_lirc = 1,
.use_lircc = 1,
+ .use_alt_gr = 1,
#if HAVE_COCOA
.use_ar = 1,
.use_media_keys = 1,
diff --git a/mpvcore/options.h b/mpvcore/options.h
index 3a4333f891..cb700cb775 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -251,6 +251,7 @@ typedef struct MPOpts {
int use_joystick;
int use_lirc;
int use_lircc;
+ int use_alt_gr;
int use_ar;
int use_media_keys;
int default_bindings;
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index ef67647f61..4831904aa7 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -174,6 +174,11 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
HIDRemote *_remote;
}
+- (BOOL)useAltGr
+{
+ return mp_input_use_alt_gr(mpv_shared_app().inputContext);
+}
+
- (void)startAppleRemote
{
dispatch_async(dispatch_get_main_queue(), ^{
@@ -287,7 +292,8 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
mask |= MP_KEY_MODIFIER_SHIFT;
if (cocoaModifiers & NSControlKeyMask)
mask |= MP_KEY_MODIFIER_CTRL;
- if (LeftAltPressed(cocoaModifiers))
+ if (LeftAltPressed(cocoaModifiers) ||
+ RightAltPressed(cocoaModifiers) && ![self useAltGr])
mask |= MP_KEY_MODIFIER_ALT;
if (cocoaModifiers & NSCommandKeyMask)
mask |= MP_KEY_MODIFIER_META;
@@ -333,7 +339,7 @@ void cocoa_put_key_with_modifiers(int keycode, int modifiers)
NSString *chars;
- if (RightAltPressed([event modifierFlags]))
+ if ([self useAltGr] && RightAltPressed([event modifierFlags]))
chars = [event characters];
else
chars = [event charactersIgnoringModifiers];
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index 6fe62b187b..86643788b9 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -495,11 +495,13 @@ static void check_events(struct vo *vo)
case SDL_TEXTINPUT: {
int sdl_mod = SDL_GetModState();
int mpv_mod = 0;
- // we ignore KMOD_LSHIFT, KMOD_RSHIFT and KMOD_RALT because
- // these are already factored into ev.text.text
+ // we ignore KMOD_LSHIFT, KMOD_RSHIFT and KMOD_RALT (if
+ // mp_input_use_alt_gr() is true) because these are already
+ // factored into ev.text.text
if (sdl_mod & (KMOD_LCTRL | KMOD_RCTRL))
mpv_mod |= MP_KEY_MODIFIER_CTRL;
- if (sdl_mod & KMOD_LALT)
+ if ((sdl_mod & KMOD_LALT) ||
+ (sdl_mod & KMOD_RALT) && !mp_input_use_alt_gr(vo->input_ctx))
mpv_mod |= MP_KEY_MODIFIER_ALT;
if (sdl_mod & (KMOD_LGUI | KMOD_RGUI))
mpv_mod |= MP_KEY_MODIFIER_META;
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index f5b2729956..6c5ebe1703 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -203,7 +203,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
// Windows enables Ctrl+Alt when AltGr (VK_RMENU) is pressed.
// E.g. AltGr+9 on a German keyboard would yield Ctrl+Alt+[
// Warning: wine handles this differently. Don't test this on wine!
- if (key_state(vo, VK_RMENU))
+ if (key_state(vo, VK_RMENU) && mp_input_use_alt_gr(vo->input_ctx))
mods &= ~(MP_KEY_MODIFIER_CTRL | MP_KEY_MODIFIER_ALT);
// Apparently Ctrl+A to Ctrl+Z is special cased, and produces
// character codes from 1-26. Work it around.