changeset 17890:633f3d0a621b

Enable gui key bindings only when running the gui. Fix enter and esc not working with a GUI enabled build running w/o GUI.
author albeu
date Sat, 18 Mar 2006 18:13:22 +0000
parents 180736f5c1d8
children 2bd51d3e6c0f
files input/input.c input/input.h mplayer.c
diffstat 3 files changed, 30 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Sat Mar 18 17:41:24 2006 +0000
+++ b/input/input.c	Sat Mar 18 18:13:22 2006 +0000
@@ -311,19 +311,15 @@
   { { 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 @@
   { { '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 @@
   { { 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 @@
   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 @@
 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;
--- a/input/input.h	Sat Mar 18 17:41:24 2006 +0000
+++ b/input/input.h	Sat Mar 18 18:13:22 2006 +0000
@@ -230,7 +230,7 @@
 
 // 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);
--- a/mplayer.c	Sat Mar 18 17:41:24 2006 +0000
+++ b/mplayer.c	Sat Mar 18 18:13:22 2006 +0000
@@ -1621,7 +1621,7 @@
 
 // Init input system
 current_module = "init_input";
-mp_input_init();
+mp_input_init(use_gui);
 #if 0
 make_pipe(&keyb_fifo_get,&keyb_fifo_put);