Changeset bf2bdccad3f2bcca29d4b102005e6ff1b3a8ccc0

Show
Ignore:
Timestamp:
06/20/07 22:19:24 (1 year ago)
Author:
Jérome Decoodt <djc@videolan.org>
git-committer:
Jérome Decoodt <djc@videolan.org> 1182370764 +0000
git-parent:

[22462d18862065dd0ac58f940b65beeb64ff50a2]

git-author:
Jérome Decoodt <djc@videolan.org> 1182370764 +0000
Message:

Add rotate-deciangle for more precision in rotate
Add unimotion (http://members.optusnet.com.au/lbramsay/programs/unimotion.html)
to motion interface
Add a low band filter to the motion

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r9acaa4b rbf2bdcc  
    174174    VLC_ADD_CFLAGS([libvlc vlc],[-x objective-c]) 
    175175    VLC_ADD_LDFLAGS([vlc],[-undefined dynamic_lookup]) 
     176    VLC_ADD_LDFLAGS([motion],[-framework IOKit -framework CoreFoundation]) 
    176177    AC_ARG_ENABLE(macosx-defaults, 
    177178        [  --enable-macosx-defaults Build the default configuration on Mac OS X (default enabled)]) 
     
    33303331  ] ) 
    33313332]) 
    3332  
    33333333 
    33343334dnl 
  • modules/control/Modules.am

    r147753f rbf2bdcc  
    77SOURCES_lirc = lirc.c 
    88SOURCES_rc = rc.c 
    9 SOURCES_motion = motion.c 
    109SOURCES_dbus = dbus.c dbus.h 
     10if HAVE_DARWIN 
     11motion_extra = unimotion.c unimotion.h 
     12else 
     13motion_extra = $(NULL) 
     14endif 
     15SOURCES_motion = \ 
     16        motion.c \ 
     17        $(motion_extra) \ 
     18        $(NULL) 
     19 
  • modules/control/motion.c

    r610d26b rbf2bdcc  
    22 * motion.c: control VLC with laptop built-in motion sensors 
    33 ***************************************************************************** 
    4  * Copyright (C) 2006 the VideoLAN team 
     4 * Copyright (C) 2006 - 2007 the VideoLAN team 
    55 * $Id$ 
    66 * 
    77 * Author: Sam Hocevar <sam@zoy.org> 
     8 *         Jérôme Decoodt <djc@videolan.org> (unimotion integration) 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    2728#include <stdlib.h>                                      /* malloc(), free() */ 
    2829#include <string.h> 
     30#include <math.h> 
    2931 
    3032#include <vlc/vlc.h> 
     
    3638#endif 
    3739 
     40#ifdef __APPLE__ 
     41#include "unimotion.h" 
     42#endif 
     43 
    3844/***************************************************************************** 
    3945 * intf_sys_t: description and status of interface 
     
    4147struct intf_sys_t 
    4248{ 
    43     enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR } sensor; 
     49    enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR, UNIMOTION_SENSOR } sensor; 
     50    enum sms_hardware unimotion_hw; 
    4451 
    4552    int i_calibrate; 
     
    111118        p_intf->p_sys->sensor = AMS_SENSOR; 
    112119    } 
     120#ifdef __APPLE__ 
     121    else if( p_intf->p_sys->unimotion_hw = detect_sms() ) 
     122        p_intf->p_sys->sensor = UNIMOTION_SENSOR; 
     123#endif 
    113124    else 
    114125    { 
     
    137148 * RunIntf: main loop 
    138149 *****************************************************************************/ 
     150#define FILTER_LENGTH 16 
     151#define LOW_THRESHOLD 800 
     152#define HIGH_THRESHOLD 1000 
    139153static void RunIntf( intf_thread_t *p_intf ) 
    140154{ 
    141     int i_x, i_oldx = 0; 
     155    int i_x, i_oldx = 0, i_sum = 0, i = 0; 
     156    int p_oldx[FILTER_LENGTH]; 
     157    memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) ); 
    142158 
    143159    while( !intf_ShouldDie( p_intf ) ) 
    144160    { 
    145 #define LOW_THRESHOLD 80 
    146 #define HIGH_THRESHOLD 100 
    147161        vout_thread_t *p_vout; 
    148162        const char *psz_filter, *psz_type; 
     
    153167 
    154168        i_x = GetOrientation( p_intf ); 
     169        i_sum += i_x - p_oldx[i]; 
     170        p_oldx[i++] = i_x; 
     171        if( i == FILTER_LENGTH ) i = 0; 
     172        i_x = i_sum / FILTER_LENGTH; 
    155173 
    156174        if( p_intf->p_sys->b_use_rotate ) 
     
    163181                if( p_obj ) 
    164182                { 
    165                     var_SetInteger( p_obj, "rotate-angle",((360+i_x/2)%360) ); 
     183                    var_SetInteger( p_obj, "rotate-deciangle", 
     184                            ((3600+i_x/2)%3600) ); 
    166185                    i_oldx = i_x; 
    167186                    vlc_object_release( p_obj ); 
     
    210229    } 
    211230} 
    212  
    213 /***************************************************************************** 
    214  * GetOrientation: get laptop orientation, range -180 / +180 
     231#undef FILTER_LENGTH 
     232#undef LOW_THRESHOLD 
     233#undef HIGH_THRESHOLD 
     234 
     235/***************************************************************************** 
     236 * GetOrientation: get laptop orientation, range -1800 / +1800 
    215237 *****************************************************************************/ 
    216238static int GetOrientation( intf_thread_t *p_intf ) 
    217239{ 
    218240    FILE *f; 
    219     int i_x, i_y
     241    int i_x, i_y, i_z
    220242 
    221243    switch( p_intf->p_sys->sensor ) 
     
    232254        fclose( f ); 
    233255 
    234         return i_x - p_intf->p_sys->i_calibrate
     256        return ( i_x - p_intf->p_sys->i_calibrate ) * 10
    235257 
    236258    case AMS_SENSOR: 
     
    244266        fclose( f ); 
    245267 
    246         return - i_x * 3; /* FIXME: arbitrary */ 
    247  
     268        return - i_x * 30; /* FIXME: arbitrary */ 
     269#ifdef __APPLE__ 
     270    case UNIMOTION_SENSOR: 
     271        if( read_sms_raw( p_intf->p_sys->unimotion_hw, &i_x, &i_y, &i_z ) ) 
     272        { 
     273            double d_norm = sqrt( i_x*i_x+i_z*i_z ); 
     274            if( d_norm < 100 ) 
     275                return 0; 
     276            double d_x = i_x / d_norm; 
     277            if( i_z > 0 ) 
     278                return -asin(d_x)*3600/3.141; 
     279            else 
     280                return 3600 + asin(d_x)*3600/3.141; 
     281        } 
     282#endif 
     283        else 
     284            return 0; 
    248285    default: 
    249286        return 0; 
  • modules/video_filter/rotate.c

    r610d26b rbf2bdcc  
    4444 
    4545static int RotateCallback( vlc_object_t *p_this, char const *psz_var, 
     46                           vlc_value_t oldval, vlc_value_t newval, 
     47                           void *p_data ); 
     48 
     49static int PreciseRotateCallback( vlc_object_t *p_this, char const *psz_var, 
    4650                           vlc_value_t oldval, vlc_value_t newval, 
    4751                           void *p_data ); 
     
    8589static inline void cache_trigo( int i_angle, int *i_sin, int *i_cos ) 
    8690{ 
    87     const double f_angle = (((double)i_angle)*M_PI)/180.; 
     91    const double f_angle = (((double)i_angle)*M_PI)/1800.; 
    8892    *i_sin = (int)(sin( f_angle )*256.); 
    8993    *i_cos = (int)(cos( f_angle )*256.); 
     
    111115 
    112116    p_sys->i_angle = var_CreateGetIntegerCommand( p_filter, 
    113                                                   FILTER_PREFIX "angle" ); 
     117                                                  FILTER_PREFIX "angle" ) * 10; 
     118    var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "deciangle" ); 
    114119    var_AddCallback( p_filter, FILTER_PREFIX "angle", RotateCallback, p_sys ); 
     120    var_AddCallback( p_filter, FILTER_PREFIX "deciangle", PreciseRotateCallback, p_sys ); 
    115121 
    116122    cache_trigo( p_sys->i_angle, &p_sys->i_sin, &p_sys->i_cos ); 
     
    221227    if( !strcmp( psz_var, "rotate-angle" ) ) 
    222228    { 
     229        p_sys->i_angle = newval.i_int*10; 
     230 
     231        cache_trigo( p_sys->i_angle, &p_sys->i_sin, &p_sys->i_cos ); 
     232    } 
     233    return VLC_SUCCESS; 
     234} 
     235static int PreciseRotateCallback( vlc_object_t *p_this, char const *psz_var, 
     236                           vlc_value_t oldval, vlc_value_t newval, 
     237                           void *p_data ) 
     238{ 
     239    filter_sys_t *p_sys = (filter_sys_t *)p_data; 
     240 
     241    if( !strcmp( psz_var, "rotate-deciangle" ) ) 
     242    { 
    223243        p_sys->i_angle = newval.i_int; 
    224244