multi-touch-dev team mailing list archive
-
multi-touch-dev team
-
Mailing list archive
-
Message #00158
Re: Touch analysis
... and the attachments ...
Henrik
=== modified file 'ts_test.py'
--- ts_test.py 2010-05-07 18:12:02 +0000
+++ ts_test.py 2010-05-11 07:15:22 +0000
@@ -310,6 +310,8 @@
dot_color = pygame.Color("purple")
mt_scale_x = 0
mt_scale_y = 0
+mt_min_x = 0
+mt_min_y = 0
mt_x = -1
mt_y = -1
@@ -413,9 +415,9 @@
global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_maj, mt_min, mt_orient,screen, current_frame,last_seen
if event.type == 'EV_ABS':
if event.code == 'ABS_MT_POSITION_X':
- mt_x = mt_scale_x * event.value
+ mt_x = mt_scale_x * (event.value - mt_min_x)
elif event.code == 'ABS_MT_POSITION_Y':
- mt_y = mt_scale_y * event.value
+ mt_y = mt_scale_y * (event.value - mt_min_y)
elif event.code == 'ABS_MT_TOUCH_MAJOR':
mt_maj = event.value
elif event.code == 'ABS_MT_TOUCH_MINOR':
@@ -437,19 +439,21 @@
current_frame = []
def mt_draw(mt_dev):
- global mt_x, mt_y, mt_scale_x, mt_scale_y, background
+ global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_min_x, mt_min_y, background
points = []
done = False
try:
info = mt_dev.absAxisInfo["ABS_MT_POSITION_X"]
mt_scale_x = float(screen.get_rect().width)/(info['max']-info['min'])
+ mt_min_x = info['min']
print "ABS_MT_POSITION_X range: " +str(info['min'])+":"+str(info['max'])
except KeyError:
return
try:
info = mt_dev.absAxisInfo["ABS_MT_POSITION_Y"]
mt_scale_y = float(screen.get_rect().height)/(info['max']-info['min'])
+ mt_min_y = info['min']
print "ABS_MT_POSITION_Y range: " +str(info['min'])+":"+str(info['max'])
except KeyError:
return
=== modified file 'ts_test.py'
--- ts_test.py 2010-05-11 08:29:37 +0000
+++ ts_test.py 2010-05-11 09:04:24 +0000
@@ -310,6 +310,7 @@
dot_color = pygame.Color("purple")
mt_scale_x = 0
mt_scale_y = 0
+mt_scale_orient = 1
mt_min_x = 0
mt_min_y = 0
@@ -324,8 +325,8 @@
track_id = -1
color = None
def __init__(self,x,y,major,minor,orientation):
- global mt_scale_x, mt_scale_y
- if orientation:
+ global mt_scale_x, mt_scale_y, mt_scale_orient
+ if abs(orientation) > mt_scale_orient / 2:
self.width = major
self.height = minor
else:
@@ -412,7 +413,8 @@
next_id+=1
def mt_event(event):
- global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_maj, mt_min, mt_orient,screen, current_frame,last_seen
+ global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_scale_orient
+ global mt_maj, mt_min, mt_orient,screen, current_frame,last_seen
if event.type == 'EV_ABS':
if event.code == 'ABS_MT_POSITION_X':
mt_x = mt_scale_x * (event.value - mt_min_x)
@@ -439,7 +441,8 @@
current_frame = []
def mt_draw(mt_dev):
- global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_min_x, mt_min_y, background
+ global mt_x, mt_y, mt_scale_x, mt_scale_y, mt_scale_orient
+ global mt_min_x, mt_min_y, background
points = []
done = False
@@ -457,6 +460,12 @@
print "ABS_MT_POSITION_Y range: " +str(info['min'])+":"+str(info['max'])
except KeyError:
return
+ try:
+ info = mt_dev.absAxisInfo["ABS_MT_ORIENTATION"]
+ mt_scale_orient = info['max']
+ print "ABS_MT_ORIENTATION range: " +str(info['min'])+":"+str(info['max'])
+ except KeyError:
+ return
background = pygame.Surface(screen.get_size())
Follow ups
References
-
n-trig updates
From: Rafi Rubin, 2010-03-31
-
Touch analysis
From: Rafi Rubin, 2010-04-11
-
Re: Touch analysis
From: Rafi Rubin, 2010-04-11
-
Re: Touch analysis
From: Bryce Harrington, 2010-05-07
-
Re: Touch analysis
From: Rafi Rubin, 2010-05-07
-
Re: Touch analysis
From: Chase Douglas, 2010-05-07
-
Re: Touch analysis
From: Chase Douglas, 2010-05-11
-
Re: Touch analysis
From: Chase Douglas, 2010-05-11
-
Re: Touch analysis
From: Rafi Rubin, 2010-05-11
-
Re: Touch analysis
From: Rafi Rubin, 2010-05-11