Changeset 1007


Ignore:
Timestamp:
Aug 2, 2006, 3:15:52 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • A few changes to the matrix program. I do not plan to maintain it.
Location:
libcaca/trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test

    • Property svn:ignore
      •  

        old new  
        1515import
        1616input
         17matrix
        1718spritedit
        1819text
  • libcaca/trunk/test/matrix.c

    r995 r1007  
    4444    int i, j;
    4545    int w, h, xo, yo, dx = 0, dy = 0, newdx, newdy;
    46     int have_hdaps = 1;
     46    int have_hdaps = 1, have_ams = 1;
    4747
    4848    cv = cucul_create_canvas(0, 0);
     
    6363    for(;;)
    6464    {
    65         int sensorx = -387, sensory = -387;
     65        int sensorx, sensory;
    6666
    67         /* IBM HDAPS support */
    6867        if(have_hdaps)
    6968        {
     69            /* IBM HDAPS support */
    7070            FILE *f = fopen("/sys/devices/platform/hdaps/position", "r");
    7171
    7272            if(f)
    7373            {
     74                sensorx = sensory = -387; /* FIXME */
     75
    7476                fscanf(f, "(%d,%d)", &sensorx, &sensory);
    7577                fclose(f);
     78
     79                sensorx = (sensorx + 387) * 180 / 387 * 4;
     80                sensory = (sensory + 387) * 180 / 387 * 4;
    7681            }
    7782            else
    7883                have_hdaps = 0;
     84        }
     85        else if(have_ams)
     86        {
     87            /* Apple Motion Sensor support */
     88            FILE *fx = fopen("/sys/devices/ams/x", "r");
     89            FILE *fy = fopen("/sys/devices/ams/y", "r");
     90
     91            if(fx && fy)
     92            {
     93                sensorx = sensory = 0;
     94                fscanf(fx, "%d", &sensorx);
     95                fscanf(fy, "%d", &sensory);
     96                fclose(fx);
     97                fclose(fy);
     98                sensorx = - sensorx * 180 / 60;
     99            }
     100            else
     101                have_ams = 0;
    79102        }
    80103
     
    83106        xo = w / 2;
    84107        yo = h / 2;
    85         //newdx = 1000.0 * cos((M_PI / 360.0) * (sensorx + 387));
    86         //newdy = -1000.0 * sin((M_PI / 360.0) * (sensorx + 387));
    87         newdx = sensorx + 387;
     108        //newdx = 1000.0 * cos((M_PI / 360.0) * (sensorx));
     109        //newdy = -1000.0 * sin((M_PI / 360.0) * (sensorx));
     110        newdx = sensorx;
    88111        newdy = 100;
    89112
Note: See TracChangeset for help on using the changeset viewer.