Changeset 173420e8c2bb2d4c20278dae3beebd2f6aaf52e5

Show
Ignore:
Timestamp:
30/05/08 13:27:31 (4 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1212146851 +0200
git-parent:

[74400291c2e06e05e51f9e959b4149f25012543c]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1212146740 +0200
Message:

Add support for applesmc motion sensors (macbooks) on linux. (Untested
since the sensor doesn't want to work on my laptop)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/control/motion.c

    r13ae40b r173420e  
    5050struct intf_sys_t 
    5151{ 
    52     enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR, UNIMOTION_SENSOR } sensor; 
     52    enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR, APPLESMC_SENSOR, 
     53           UNIMOTION_SENSOR } sensor; 
    5354#ifdef __APPLE__ 
    5455    enum sms_hardware unimotion_hw; 
     
    7778    set_category( CAT_INTERFACE ); 
    7879    set_description( N_("motion control interface") ); 
     80    set_help( N_("Use HDAPS, AMS, APPLESMC or UNIMOTION motion sensors " \ 
     81                 "to rotate the video") ) 
    7982 
    8083    add_bool( "motion-use-rotate", 0, NULL, 
     
    121124        /* Apple Motion Sensor support */ 
    122125        p_intf->p_sys->sensor = AMS_SENSOR; 
     126    } 
     127    else if( access( "/sys/devices/applesmc.768/position", R_OK ) == 0 ) 
     128    { 
     129        /* Apple SMC (newer macbooks) */ 
     130        /* Should be factorised with HDAPS */ 
     131        f = fopen( "/sys/devices/applesmc.768/calibrate", "r" ); 
     132        if( f ) 
     133        { 
     134            i_x = i_y = 0; 
     135            fscanf( f, "(%d,%d)", &i_x, &i_y ); 
     136            fclose( f ); 
     137            p_intf->p_sys->i_calibrate = i_x; 
     138            p_intf->p_sys->sensor = APPLESMC_SENSOR; 
     139        } 
     140        else 
     141        { 
     142            p_intf->p_sys->sensor = NO_SENSOR; 
     143        } 
    123144    } 
    124145#ifdef __APPLE__ 
     
    243264{ 
    244265    FILE *f; 
    245     int i_x, i_y; 
    246 #ifdef __APPLE__ 
    247     int i_z; 
    248 #endif 
     266    int i_x, i_y, i_z = 0; 
     267 
    249268    switch( p_intf->p_sys->sensor ) 
    250269    { 
     
    273292 
    274293        return - i_x * 30; /* FIXME: arbitrary */ 
     294 
     295    case APPLESMC_SENSOR: 
     296        f = fopen( "/sys/devices/applesmc.768/position", "r" ); 
     297        if( !f ) 
     298        { 
     299            return 0; 
     300        } 
     301 
     302        i_x = i_y = i_z = 0; 
     303        fscanf( f, "(%d,%d,%d)", &i_x, &i_y, &i_z ); 
     304        fclose( f ); 
     305 
     306        return ( i_x - p_intf->p_sys->i_calibrate ) * 10; 
     307 
    275308#ifdef __APPLE__ 
    276309    case UNIMOTION_SENSOR: