Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multitouch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
multitouch
Commits
2f572483
Commit
2f572483
authored
May 08, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added simple pan detection.
parent
eba31ca6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
28 deletions
+44
-28
src/events.py
src/events.py
+2
-2
src/touch.py
src/touch.py
+42
-26
No files found.
src/events.py
View file @
2f572483
...
...
@@ -107,6 +107,6 @@ class Pan(Gesture):
self
.
n
=
n
def
__str__
(
self
):
return
'<%s (%s, %s)
to
(%s, %s) n=%d>'
%
\
return
'<%s (%s, %s)
direction=
(%s, %s) n=%d>'
%
\
(
self
.
__class__
.
__name__
,
self
.
x
,
self
.
y
,
self
.
dx
,
self
.
dy
,
self
.
amount
,
self
.
n
)
self
.
n
)
src/touch.py
View file @
2f572483
...
...
@@ -273,36 +273,47 @@ class MultiTouchListener(Logger):
return
cx
-
ocx
,
cy
-
ocy
def
detect_pan
(
self
):
"""
Look for multi-finger drag events. Multi-drag is defined as all the
fingers moving close-ish together in the same direction.
"""
l
=
len
(
self
.
points
)
#
def detect_pan(self):
#
"""
#
Look for multi-finger drag events. Multi-drag is defined as all the
#
fingers moving close-ish together in the same direction.
#
"""
#
l = len(self.points)
if
not
l
:
return
False
#
if not l:
#
return False
m
=
MAX_MULTI_DRAG_DISTANCE
clustered
=
l
==
1
or
all
([
p
.
distance
(
*
self
.
centroid
)
<=
m
\
for
p
in
self
.
points
])
directions
=
[(
cmp
(
p
.
dx
(),
0
),
cmp
(
p
.
dy
(),
0
))
for
p
in
self
.
points
]
#
m = MAX_MULTI_DRAG_DISTANCE
#
clustered = l == 1 or all([p.distance(*self.centroid) <= m \
#
for p in self.points])
#
directions = [(cmp(p.dx(), 0), cmp(p.dy(), 0))
#
for p in self.points]
if
not
clustered
or
not
any
(
map
(
all
,
zip
(
*
directions
))):
return
False
#
if not clustered or not any(map(all, zip(*directions))):
#
return False
if
l
==
1
:
p
=
self
.
points
[
0
]
cx
,
cy
,
dx
,
dy
=
p
.
x
,
p
.
y
,
p
.
dx
(),
p
.
dy
()
else
:
cx
,
cy
=
self
.
centroid
old_cx
,
old_cy
=
self
.
old_centroid
dx
,
dy
=
cx
-
old_cx
,
cy
-
old_cy
# if l == 1:
# p = self.points[0]
# cx, cy, dx, dy = p.x, p.y, p.dx(), p.dy()
# else:
# cx, cy = self.centroid
# old_cx, old_cy = self.old_centroid
# dx, dy = cx - old_cx, cy - old_cy
# self.trigger(Pan(cx, cy, dx, dy, l))
self
.
trigger
(
Pan
(
cx
,
cy
,
dx
,
dy
,
l
))
# return True
return
True
def
detect_pan
(
self
):
l
=
len
(
self
.
points
)
if
not
l
:
return
if
distance
(
self
.
centroid
,
self
.
old_centroid
)
>
DIST_THRESHOLD
:
cx
,
cy
=
self
.
centroid
dx
,
dy
=
self
.
centroid_movement
()
self
.
trigger
(
Pan
(
cx
,
cy
,
dx
,
dy
,
l
))
def
find_point
(
self
,
sid
,
index
=
False
):
for
i
,
p
in
enumerate
(
self
.
points
):
...
...
@@ -340,8 +351,10 @@ class MultiTouchListener(Logger):
# If a pan event is detected, ignore any rotate or pinch movement
# (they are considered noise)
if
not
self
.
detect_pan
():
self
.
detect_rotation_and_pinch
()
self
.
detect_pan
()
self
.
detect_rotation_and_pinch
()
#if not self.detect_pan():
# self.detect_rotation_and_pinch()
self
.
points_changed
=
False
...
...
@@ -427,8 +440,11 @@ if __name__ == '__main__':
listener
.
bind
(
'tap'
,
tap
,
0
)
listener
.
bind
(
'single_tap'
,
tap
,
1
)
listener
.
bind
(
'double_tap'
,
tap
,
2
)
# Add empty handlers sp that the events are actually triggered
listener
.
bind
(
'rotate'
,
lambda
e
:
0
)
listener
.
bind
(
'pinch'
,
lambda
e
:
0
)
listener
.
bind
(
'pan'
,
lambda
e
:
0
)
try
:
listener
.
start
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment