From 0dadcc7bf0f6cd7b1b020ebcd70a87c196b769f6 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 28 Aug 2009 12:54:33 +0000 Subject: Add osx_common.c and move the keycode conversion (OSX to MPlayer) there. Also get rid of our own defines for the keycodes and instead use the predefined ones from Carbon. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29573 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/osx_common.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 libvo/osx_common.c (limited to 'libvo/osx_common.c') diff --git a/libvo/osx_common.c b/libvo/osx_common.c new file mode 100644 index 0000000000..da340438fc --- /dev/null +++ b/libvo/osx_common.c @@ -0,0 +1,45 @@ +// only to get keycode definitions from HIToolbox/Events.h +#include "config.h" + +#include +#include "osx_common.h" +#include "video_out.h" +#include "osdep/keycodes.h" + +static const struct keymap keymap[] = { + // special keys + {0x34, KEY_ENTER}, // Enter key on some iBooks? + {kVK_Return, KEY_ENTER}, + {kVK_Escape, KEY_ESC}, + {kVK_Delete, KEY_BACKSPACE}, {kVK_Option, KEY_BACKSPACE}, {kVK_Control, KEY_BACKSPACE}, {kVK_Shift, KEY_BACKSPACE}, + {kVK_Tab, KEY_TAB}, + + // cursor keys + {kVK_UpArrow, KEY_UP}, {kVK_DownArrow, KEY_DOWN}, {kVK_LeftArrow, KEY_LEFT}, {kVK_RightArrow, KEY_RIGHT}, + + // navigation block + {kVK_Help, KEY_INSERT}, {kVK_ForwardDelete, KEY_DELETE}, {kVK_Home, KEY_HOME}, + {kVK_End, KEY_END}, {kVK_PageUp, KEY_PAGE_UP}, {kVK_PageUp, KEY_PAGE_DOWN}, + + // F-keys + {kVK_F1, KEY_F + 1}, {kVK_F2, KEY_F + 2}, {kVK_F3, KEY_F + 3}, {kVK_F4, KEY_F + 4}, + {kVK_F5, KEY_F + 5}, {kVK_F6, KEY_F + 6}, {kVK_F7, KEY_F + 7}, {kVK_F8, KEY_F + 8}, + {kVK_F9, KEY_F + 9}, {kVK_F10, KEY_F + 10}, {kVK_F11, KEY_F + 11}, {kVK_F12, KEY_F + 12}, + + // numpad + {kVK_ANSI_KeypadPlus, '+'}, {kVK_ANSI_KeypadMinus, '-'}, {kVK_ANSI_KeypadMultiply, '*'}, + {kVK_ANSI_KeypadDivide, '/'}, {kVK_ANSI_KeypadEnter, KEY_KPENTER}, {kVK_ANSI_KeypadDecimal, KEY_KPDEC}, + {kVK_ANSI_Keypad0, KEY_KP0}, {kVK_ANSI_Keypad1, KEY_KP1}, {kVK_ANSI_Keypad2, KEY_KP2}, {kVK_ANSI_Keypad3, KEY_KP3}, + {kVK_ANSI_Keypad4, KEY_KP4}, {kVK_ANSI_Keypad5, KEY_KP5}, {kVK_ANSI_Keypad6, KEY_KP6}, {kVK_ANSI_Keypad7, KEY_KP7}, + {kVK_ANSI_Keypad8, KEY_KP8}, {kVK_ANSI_Keypad9, KEY_KP9}, + + {0, 0} +}; + +int convert_key(unsigned key, unsigned charcode) +{ + int mpkey = lookup_keymap_table(keymap, key); + if (mpkey) + return mpkey; + return charcode; +} -- cgit v1.2.3 From 4ce7a487480cd5dc9effc531b9846b7bee83e766 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 28 Aug 2009 13:25:30 +0000 Subject: Move aspect change handling from vo_quartz to osx_common. This could probably be even moved to video_out, though the names should be improved. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29574 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/osx_common.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libvo/osx_common.c') diff --git a/libvo/osx_common.c b/libvo/osx_common.c index da340438fc..aa1de118f0 100644 --- a/libvo/osx_common.c +++ b/libvo/osx_common.c @@ -43,3 +43,31 @@ int convert_key(unsigned key, unsigned charcode) return mpkey; return charcode; } + +static int our_aspect_change; +static float old_movie_aspect; + +/** + * Sends MPlayer a command to change aspect to the requested value. + * @param new_aspect desired new aspect, < 0 means restore original. + */ +void change_movie_aspect(float new_aspect) +{ + char cmd_str[64]; + if (new_aspect < 0) + new_aspect = old_movie_aspect; + our_aspect_change = 1; + snprintf(cmd_str, 64, "switch_ratio %f", old_movie_aspect); + mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); +} + +/** + * Call in config to save the original movie aspect. + * This will ignore config calls caused by change_movie_aspect. + */ +void config_movie_aspect(float config_aspect) +{ + if (!our_aspect_change) + old_movie_aspect = config_aspect; + our_aspect_change = 0; +} -- cgit v1.2.3 From 6497662b92f8f62a94d9d0bc43a5db1c6b408eaf Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 28 Aug 2009 13:30:32 +0000 Subject: 1l, use sizeof for snprintf size instead of hard-coding the current value. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29576 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/osx_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libvo/osx_common.c') diff --git a/libvo/osx_common.c b/libvo/osx_common.c index aa1de118f0..588980dfe5 100644 --- a/libvo/osx_common.c +++ b/libvo/osx_common.c @@ -57,7 +57,7 @@ void change_movie_aspect(float new_aspect) if (new_aspect < 0) new_aspect = old_movie_aspect; our_aspect_change = 1; - snprintf(cmd_str, 64, "switch_ratio %f", old_movie_aspect); + snprintf(cmd_str, sizeof(cmd_str), "switch_ratio %f", old_movie_aspect); mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); } -- cgit v1.2.3 From cc1b58e34874b0ad16a4e6999c6b07cbe94aef83 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 28 Aug 2009 14:02:32 +0000 Subject: Fix implicit declaration of mp_input_.. functions. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29577 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/osx_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libvo/osx_common.c') diff --git a/libvo/osx_common.c b/libvo/osx_common.c index 588980dfe5..5eb64fa56b 100644 --- a/libvo/osx_common.c +++ b/libvo/osx_common.c @@ -5,6 +5,7 @@ #include "osx_common.h" #include "video_out.h" #include "osdep/keycodes.h" +#include "input/input.h" static const struct keymap keymap[] = { // special keys -- cgit v1.2.3 From b7c73183522c766c8079ae083f86a1680725c8fc Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 28 Aug 2009 14:38:44 +0000 Subject: Make aspect switching work again (used the wrong variable and always switched to the original aspect). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29578 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/osx_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libvo/osx_common.c') diff --git a/libvo/osx_common.c b/libvo/osx_common.c index 5eb64fa56b..642fa9e4da 100644 --- a/libvo/osx_common.c +++ b/libvo/osx_common.c @@ -58,7 +58,7 @@ void change_movie_aspect(float new_aspect) if (new_aspect < 0) new_aspect = old_movie_aspect; our_aspect_change = 1; - snprintf(cmd_str, sizeof(cmd_str), "switch_ratio %f", old_movie_aspect); + snprintf(cmd_str, sizeof(cmd_str), "switch_ratio %f", new_aspect); mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); } -- cgit v1.2.3