]> git.sesse.net Git - vlc/blobdiff - modules/control/motion.c
* collection of various fixes and edits
[vlc] / modules / control / motion.c
index d723b936d358ffe275a3d84762bb93d75249296b..98f53edcfe0c604a5edd6779cf02f62fc117b2ab 100644 (file)
@@ -28,8 +28,8 @@
 #include <string.h>
 
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/vout.h>
+#include <vlc_interface.h>
+#include <vlc_vout.h>
 
 #ifdef HAVE_UNISTD_H
 #    include <unistd.h>
@@ -42,8 +42,9 @@ struct intf_sys_t
 {
     enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR } sensor;
 
-    int i_last_x, i_calibrate;
-    int i_threshold;
+    int i_calibrate;
+
+    vlc_bool_t b_use_rotate;
 };
 
 /*****************************************************************************
@@ -55,6 +56,8 @@ static void Close  ( vlc_object_t * );
 static void RunIntf( intf_thread_t *p_intf );
 static int GetOrientation( intf_thread_t *p_intf );
 
+#define USE_ROTATE_TEXT N_("Use the rotate video filter instead of transform")
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -63,6 +66,9 @@ vlc_module_begin();
     set_category( CAT_INTERFACE );
     set_description( _("motion control interface") );
 
+    add_bool( "motion-use-rotate", 0, NULL,
+              USE_ROTATE_TEXT, USE_ROTATE_TEXT, VLC_FALSE );
+
     set_capability( "interface", 0 );
     set_callbacks( Open, Close );
 vlc_module_end();
@@ -112,6 +118,13 @@ int Open ( vlc_object_t *p_this )
 
     p_intf->pf_run = RunIntf;
 
+    p_intf->p_sys->b_use_rotate = config_GetInt( p_intf, "motion-use-rotate" );
+
+    if( p_intf->p_sys->b_use_rotate )
+    {
+        var_Create( p_intf->p_libvlc, "rotate_angle", VLC_VAR_INTEGER );
+    }
+
     return VLC_SUCCESS;
 }
 
@@ -132,12 +145,12 @@ static void RunIntf( intf_thread_t *p_intf )
 {
     int i_x, i_oldx = 0;
 
-    while( !p_intf->b_die )
+    while( !intf_ShouldDie( p_intf ) )
     {
 #define LOW_THRESHOLD 80
 #define HIGH_THRESHOLD 100
         vout_thread_t *p_vout;
-        char *psz_filter, *psz_type;
+        const char *psz_filter, *psz_type;
         vlc_bool_t b_change = VLC_FALSE;
 
         /* Wait a bit, get orientation, change filter if necessary */
@@ -145,6 +158,17 @@ static void RunIntf( intf_thread_t *p_intf )
 
         i_x = GetOrientation( p_intf );
 
+        if( p_intf->p_sys->b_use_rotate )
+        {
+            if( i_oldx != i_x )
+            {
+                var_SetInteger( p_intf->p_libvlc, "rotate_angle",
+                            ((360+i_x/2)%360) );
+                i_oldx = i_x;
+            }
+            continue;
+        }
+
         if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD )
         {
             b_change = VLC_TRUE;