]> git.sesse.net Git - vlc/blobdiff - modules/access/dvdplay/intf.c
* ALL: improved hotkeys support.
[vlc] / modules / access / dvdplay / intf.c
index 215c25b2c091c96c65bbe9ee407abc61d3ab3b8e..15b1cb4c58ca4fbea336ef8e4baf24b1d9f89be2 100644 (file)
@@ -2,7 +2,7 @@
  * intf.c: interface for DVD video manager
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: intf.c,v 1.7 2003/08/13 01:45:13 gbazin Exp $
+ * $Id: intf.c,v 1.9 2003/10/29 01:33:27 gbazin Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -35,6 +35,8 @@
 #include "input_ext-intf.h"
 #include "input_ext-dec.h"
 
+#include "vlc_keys.h"
+
 #include "dvd.h"
 
 /*****************************************************************************
@@ -80,7 +82,8 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
     };
 
     p_intf->pf_run = RunIntf;
-
+    
+    var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
     p_intf->p_sys->m_still_time = 0;
     p_intf->p_sys->b_inf_still = 0;
     p_intf->p_sys->b_still = 0;
@@ -94,7 +97,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
 void E_(CloseIntf) ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
-
+    var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
     /* Destroy structure */
     free( p_intf->p_sys );
 }
@@ -214,33 +217,43 @@ static void RunIntf( intf_thread_t *p_intf )
         /*
          * keyboard event
          */
-        if( p_vout && p_intf->p_sys->b_key_pressed )
+        if( p_intf->p_sys->b_key_pressed )
         {
             vlc_value_t val;
-            int i_activate;
+            int i, i_activate, i_action = -1;
+            struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
 
             p_intf->p_sys->b_key_pressed = VLC_FALSE;
             
-            var_Get( p_vout, "key-pressed", &val );
-            if ( val.psz_string )
+            /* Find action triggered by hotkey (if any) */
+            var_Get( p_intf->p_vlc, "key-pressed", &val );
+            for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+            {
+                if( p_hotkeys[i].i_key == val.i_int )
+                {
+                    i_action = p_hotkeys[i].i_action;
+                }
+            }
+
+            if( i_action )
             {
-                if( !strcmp( val.psz_string, "LEFT" ) )
+                if( i_action == ACTIONID_NAV_LEFT )
                 {
                     p_intf->p_sys->control.type = DVDCtrlLeftButtonSelect;
                 }
-                else if( !strcmp( val.psz_string, "RIGHT" ) )
+                else if( i_action == ACTIONID_NAV_RIGHT )
                 {
                     p_intf->p_sys->control.type = DVDCtrlRightButtonSelect;
                 }
-                else if( !strcmp( val.psz_string, "UP" ) )
+                else if( i_action == ACTIONID_NAV_UP )
                 {
                     p_intf->p_sys->control.type = DVDCtrlUpperButtonSelect;
                 }
-                else if( !strcmp( val.psz_string, "DOWN" ) )
+                else if( i_action == ACTIONID_NAV_DOWN )
                 {
                     p_intf->p_sys->control.type = DVDCtrlLowerButtonSelect;
                 }
-                else if( !strcmp( val.psz_string, "ENTER" ) )
+                else if( i_action == ACTIONID_NAV_ACTIVATE )
                 {
                     p_intf->p_sys->control.type = DVDCtrlButtonActivate;
                 }
@@ -273,7 +286,6 @@ static void RunIntf( intf_thread_t *p_intf )
         {
             var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
             var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
-            var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
             vlc_object_release( p_vout );
             p_vout = NULL;
         }
@@ -286,7 +298,6 @@ static void RunIntf( intf_thread_t *p_intf )
             {
                 var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
                 var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
-                var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
             }
         }
 
@@ -298,7 +309,6 @@ static void RunIntf( intf_thread_t *p_intf )
     {
         var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
         var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
-        var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
         vlc_object_release( p_vout );
     }