summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Feller <eugen.feller@uni-duesseldorf.de>2007-11-25 20:19:15 +0100
committerEugen Feller <eugen.feller@uni-duesseldorf.de>2007-11-25 20:19:15 +0100
commitc21c9e97fa95c27c847ad218781bd3cea837e6b9 (patch)
tree6f3f5fdfc85f70cd9485c02f4cf88c60c5f038a0
parent8dd9038cc75de19500f2155c60730e14f30d3847 (diff)
downloadsmackpad-c21c9e97fa95c27c847ad218781bd3cea837e6b9.tar.gz
smackpad-c21c9e97fa95c27c847ad218781bd3cea837e6b9.tar.bz2
added smackpadData struct
-rw-r--r--smackpad.c55
-rw-r--r--smackpad.xml.in4
2 files changed, 35 insertions, 24 deletions
diff --git a/smackpad.c b/smackpad.c
index 9886430..ec54c9b 100644
--- a/smackpad.c
+++ b/smackpad.c
@@ -55,6 +55,16 @@ typedef struct
int y;
}smackpadPosition;
+typedef struct
+{
+ int pitchX;
+ int pitchY;
+ int stableX;
+ int stableY;
+ int aPitchX;
+ int aPitchY;
+}smackpadData;
+
static int sensitivityRate=5;
pthread_t readPositionThread;
static int readPositionThreadStatus=-1;
@@ -174,11 +184,12 @@ smackpadRotateDesktop (smackDirection direction)
}
static void*
-smackpadGetPosition (void *data)
+smackpadGetPosition (void *misc)
{
- int initialX=0,initialY=0,pitchX=0,pitchY=0,stableX=0,stableY=0,aPitchX=0,aPitchY=0;
struct timespec sleepTimer;
smackpadPosition position;
+ smackpadPosition initialPosition;
+ smackpadData data = {0,0,0,0,0,0};
sleepTimer.tv_sec=0;
sleepTimer.tv_nsec=20000000; /* 20ms */
@@ -189,27 +200,27 @@ smackpadGetPosition (void *data)
if(!statusHdaps)
return NULL;
- initialX=position.x;
- initialY=position.y;
+ initialPosition.x=position.x;
+ initialPosition.y=position.y;
while (statusLoop)
{
statusHdaps=smackpadReadHDAPSData(POSITION,statusAxes,&position);
-
+
if(!statusHdaps)
return NULL;
- pitchX=position.x-initialX;
- pitchY=position.y-initialY;
- aPitchX=abs(pitchX);
- aPitchY=abs(pitchY);
+ data.pitchX=position.x-initialPosition.x;
+ data.pitchY=position.y-initialPosition.y;
+ data.aPitchX=abs(data.pitchX);
+ data.aPitchY=abs(data.pitchY);
- if(aPitchX < 5)
- stableX+=1;
- if(aPitchY < 5)
- stableY+=1;
+ if(data.aPitchX < 5)
+ data.stableX+=1;
+ if(data.aPitchY < 5)
+ data.stableY+=1;
- if( aPitchX > sensitivityRate && stableX > 30)
+ if(data.aPitchX > sensitivityRate && data.stableX > 30)
{
smackDirection leftDirection = LEFT;
smackDirection rightDirection = RIGHT;
@@ -219,33 +230,33 @@ smackpadGetPosition (void *data)
leftDirection = RIGHT;
rightDirection = LEFT;
}
+
+ data.stableX=0;
- stableX=0;
-
- if(pitchX<0)
+ if(data.pitchX<0)
smackpadRotateDesktop(leftDirection);
else
smackpadRotateDesktop(rightDirection);
- }else if (aPitchY > sensitivityRate && stableY > 30)
+ }else if(data.aPitchY > sensitivityRate && data.stableY > 30)
{
smackDirection upDirection = UP;
smackDirection downDirection = DOWN;
-
if(!statusAxes)
{
upDirection = DOWN;
downDirection = UP;
}
- stableY=0;
+ data.stableY=0;
- if(pitchY<0)
+ if(data.pitchY<0)
smackpadRotateDesktop(upDirection);
else
- smackpadRotateDesktop(downDirection);
+ smackpadRotateDesktop(downDirection);
}
+
nanosleep(&sleepTimer,NULL);
}
diff --git a/smackpad.xml.in b/smackpad.xml.in
index e70cc44..a46541c 100644
--- a/smackpad.xml.in
+++ b/smackpad.xml.in
@@ -7,8 +7,8 @@
<option name="sensitivity_rate" type="int">
<_short>Sensitivity</_short>
<_long>Adjust sensitivity rate</_long>
- <default>5</default>
- <min>5</min>
+ <default>4</default>
+ <min>4</min>
<max>100</max>
</option>
<option name="initiate_key" type="key">