From f440a3c1bfd558b556c41f8eab4484c4eaf73c2e Mon Sep 17 00:00:00 2001 From: albeu Date: Sat, 18 Mar 2006 18:13:22 +0000 Subject: Enable gui key bindings only when running the gui. Fix enter and esc not working with a GUI enabled build running w/o GUI. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17891 b3059339-0415-0410-9bf9-f77b7e298cf2 --- input/input.c | 42 ++++++++++++++++++++++++++++-------------- input/input.h | 2 +- 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'input') diff --git a/input/input.c b/input/input.c index dfdcb22021..4fd0dfe8d0 100644 --- a/input/input.c +++ b/input/input.c @@ -311,19 +311,15 @@ static mp_cmd_bind_t def_cmd_binds[] = { { { KEY_BACKSPACE, 0 }, "speed_set 1.0" }, { { 'q', 0 }, "quit" }, { { 'Q', 0 }, "quit" }, -#ifndef HAVE_NEW_GUI { { KEY_ESC, 0 }, "quit" }, { { 'p', 0 }, "pause" }, { { 'P', 0 }, "pause" }, -#endif { { ' ', 0 }, "pause" }, { { '.', 0 }, "frame_step" }, { { KEY_HOME, 0 }, "pt_up_step 1" }, { { KEY_END, 0 }, "pt_up_step -1" }, { { '>', 0 }, "pt_step 1" }, -#ifndef HAVE_NEW_GUI { { KEY_ENTER, 0 }, "pt_step 1 1" }, -#endif { { '<', 0 }, "pt_step -1" }, { { KEY_INS, 0 }, "alt_src_step 1" }, { { KEY_DEL, 0 }, "alt_src_step -1" }, @@ -365,15 +361,6 @@ static mp_cmd_bind_t def_cmd_binds[] = { { { 'n', 0 }, "tv_step_norm" }, { { 'u', 0 }, "tv_step_chanlist" }, #endif -#ifdef HAVE_NEW_GUI - { { 'l', 0 }, "gui_loadfile" }, - { { 't', 0 }, "gui_loadsubtitle" }, - { { KEY_ENTER, 0 }, "gui_play" }, - { { KEY_ESC, 0 }, "gui_stop" }, - { { 'p', 0 }, "gui_playlist" }, - { { 'r', 0 }, "gui_preferences" }, - { { 'c', 0 }, "gui_skinbrowser" }, -#endif #ifdef HAVE_JOYSTICK { { JOY_AXIS0_PLUS, 0 }, "seek 10" }, { { JOY_AXIS0_MINUS, 0 }, "seek -10" }, @@ -409,6 +396,22 @@ static mp_cmd_bind_t def_cmd_binds[] = { { { 0 }, NULL } }; + +#ifdef HAVE_NEW_GUI +static mp_cmd_bind_t gui_def_cmd_binds[] = { + + { { 'l', 0 }, "gui_loadfile" }, + { { 't', 0 }, "gui_loadsubtitle" }, + { { KEY_ENTER, 0 }, "gui_play" }, + { { KEY_ESC, 0 }, "gui_stop" }, + { { 'p', 0 }, "gui_playlist" }, + { { 'r', 0 }, "gui_preferences" }, + { { 'c', 0 }, "gui_skinbrowser" }, + + { { 0 }, NULL } +}; +#endif + #ifndef MP_MAX_KEY_FD #define MP_MAX_KEY_FD 10 #endif @@ -1378,6 +1381,12 @@ mp_input_bind_keys(int keys[MP_MAX_KEY_DOWN+1], char* cmd) { memcpy(bind->input,keys,(MP_MAX_KEY_DOWN+1)*sizeof(int)); } +void +mp_input_add_binds(mp_cmd_bind_t* list) { + int i; + for(i = 0 ; list[i].cmd ; i++) + mp_input_bind_keys(list[i].input,list[i].cmd); +} static void mp_input_free_binds(mp_cmd_bind_t* binds) { @@ -1552,9 +1561,14 @@ mp_input_parse_config(char *file) { extern char *get_path(char *filename); void -mp_input_init(void) { +mp_input_init(int use_gui) { char* file; +#ifdef HAVE_NEW_GUI + if(use_gui) + mp_input_add_binds(gui_def_cmd_binds); +#endif + file = config_file[0] != '/' ? get_path(config_file) : config_file; if(!file) return; diff --git a/input/input.h b/input/input.h index d27b3e11bf..006c3ea991 100644 --- a/input/input.h +++ b/input/input.h @@ -230,7 +230,7 @@ mp_cmd_clone(mp_cmd_t* cmd); // When you create a new driver you should add it in these 2 functions. void -mp_input_init(void); +mp_input_init(int use_gui); void mp_input_uninit(void); -- cgit v1.2.3