summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Feller <eugen.feller@uni-duesseldorf.de>2007-11-21 16:34:45 +0100
committerEugen Feller <eugen.feller@uni-duesseldorf.de>2007-11-21 16:34:45 +0100
commit8dd9038cc75de19500f2155c60730e14f30d3847 (patch)
treecba086724c57ac9d6a5933b3e4e4c1de40e05b75
parent79b67de40f5f6b5f94255cabd076afecd354fb78 (diff)
downloadsmackpad-8dd9038cc75de19500f2155c60730e14f30d3847.tar.gz
smackpad-8dd9038cc75de19500f2155c60730e14f30d3847.tar.bz2
added move up,down
-rw-r--r--smackpad.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/smackpad.c b/smackpad.c
index 589d4e1..9886430 100644
--- a/smackpad.c
+++ b/smackpad.c
@@ -38,7 +38,9 @@
typedef enum
{
LEFT,
- RIGHT
+ RIGHT,
+ UP,
+ DOWN
}smackDirection;
typedef enum
@@ -98,7 +100,7 @@ smackpadReadHDAPSData (smackpadMisc misc,
fread(buf, 255, 1, file);
fclose(file);
-
+
if(invert)
sscanf(buf, "(%d,%d)", &position->y, &position->x);
else
@@ -162,13 +164,19 @@ smackpadRotateDesktop (smackDirection direction)
case RIGHT:
smackpadRotate(1,0);
break;
+ case UP:
+ smackpadRotate(0,-1);
+ break;
+ case DOWN:
+ smackpadRotate(0,1);
+ break;
}
}
static void*
smackpadGetPosition (void *data)
{
- int initialX=0,pitch=0,stable=0,aPitch=0;
+ int initialX=0,initialY=0,pitchX=0,pitchY=0,stableX=0,stableY=0,aPitchX=0,aPitchY=0;
struct timespec sleepTimer;
smackpadPosition position;
@@ -182,6 +190,7 @@ smackpadGetPosition (void *data)
return NULL;
initialX=position.x;
+ initialY=position.y;
while (statusLoop)
{
@@ -190,13 +199,17 @@ smackpadGetPosition (void *data)
if(!statusHdaps)
return NULL;
- pitch=position.x-initialX;
- aPitch=abs(pitch);
+ pitchX=position.x-initialX;
+ pitchY=position.y-initialY;
+ aPitchX=abs(pitchX);
+ aPitchY=abs(pitchY);
- if(aPitch<5)
- stable+=1;
+ if(aPitchX < 5)
+ stableX+=1;
+ if(aPitchY < 5)
+ stableY+=1;
- if(aPitch > sensitivityRate && stable > 30)
+ if( aPitchX > sensitivityRate && stableX > 30)
{
smackDirection leftDirection = LEFT;
smackDirection rightDirection = RIGHT;
@@ -207,13 +220,32 @@ smackpadGetPosition (void *data)
rightDirection = LEFT;
}
- stable=0;
+ stableX=0;
- if(pitch<0)
+ if(pitchX<0)
smackpadRotateDesktop(leftDirection);
else
smackpadRotateDesktop(rightDirection);
- }
+
+ }else if (aPitchY > sensitivityRate && stableY > 30)
+ {
+ smackDirection upDirection = UP;
+ smackDirection downDirection = DOWN;
+
+
+ if(!statusAxes)
+ {
+ upDirection = DOWN;
+ downDirection = UP;
+ }
+
+ stableY=0;
+
+ if(pitchY<0)
+ smackpadRotateDesktop(upDirection);
+ else
+ smackpadRotateDesktop(downDirection);
+ }
nanosleep(&sleepTimer,NULL);
}