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
0a7f8692
Commit
0a7f8692
authored
May 18, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced occurences of 'listener' with 'server'.
parent
0fc618e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
27 deletions
+27
-27
src/draw.py
src/draw.py
+12
-12
src/touch.py
src/touch.py
+15
-15
No files found.
src/draw.py
View file @
0a7f8692
...
...
@@ -2,7 +2,7 @@
import
pygame
import
sys
import
time
from
touch
import
Multi
TouchListen
er
,
screen_size
from
touch
import
Multi
touchServ
er
,
screen_size
from
math
import
degrees
,
cos
,
sin
from
events
import
Rotate
...
...
@@ -73,9 +73,9 @@ def update():
screen
.
blit
(
transformed
,
rect
)
# Draw touch points
c
=
coord
(
*
listen
er
.
centroid
)
c
=
coord
(
*
serv
er
.
centroid
)
for
p
in
listen
er
.
points
:
for
p
in
serv
er
.
points
:
xy
=
coord
(
p
.
x
,
p
.
y
)
# Draw line to centroid
...
...
@@ -131,14 +131,14 @@ def pinch(event):
scale
=
min
(
scale
*
event
.
amount
,
MAX_SCALE
)
# Start touch event
listen
er in separate thread
listener
=
MultiTouchListen
er
(
verbose
=
1
,
tuio_verbose
=
0
)
listen
er
.
bind
(
'rotate'
,
rotate
)
listen
er
.
bind
(
'pinch'
,
pinch
)
listen
er
.
bind
(
'tap'
,
lambda
e
:
taps
.
append
([
coord
(
*
e
.
xy
),
FINGER_RADIUS
]))
listen
er
.
bind
(
'single_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
1
]))
listen
er
.
bind
(
'double_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
0
]))
listen
er
.
start
(
threaded
=
True
)
# Start touch event
serv
er in separate thread
server
=
MultitouchServ
er
(
verbose
=
1
,
tuio_verbose
=
0
)
serv
er
.
bind
(
'rotate'
,
rotate
)
serv
er
.
bind
(
'pinch'
,
pinch
)
serv
er
.
bind
(
'tap'
,
lambda
e
:
taps
.
append
([
coord
(
*
e
.
xy
),
FINGER_RADIUS
]))
serv
er
.
bind
(
'single_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
1
]))
serv
er
.
bind
(
'double_tap'
,
lambda
e
:
dtaps
.
append
(
list
(
coord
(
*
e
.
xy
))
+
[
0
]))
serv
er
.
start
(
threaded
=
True
)
def
is_quit_event
(
e
):
...
...
@@ -153,4 +153,4 @@ try:
except
KeyboardInterrupt
:
pass
finally
:
listen
er
.
stop
()
serv
er
.
stop
()
src/touch.py
View file @
0a7f8692
...
...
@@ -127,9 +127,9 @@ class TouchPoint(object):
return
rotation
(
prev
,
current
)
class
Multi
TouchListen
er
(
Logger
):
class
Multi
touchServ
er
(
Logger
):
def
__init__
(
self
,
verbose
=
0
,
tuio_verbose
=
0
,
**
kwargs
):
super
(
Multi
TouchListen
er
,
self
).
__init__
(
**
kwargs
)
super
(
Multi
touchServ
er
,
self
).
__init__
(
**
kwargs
)
self
.
verbose
=
verbose
self
.
last_tap
=
None
self
.
last_tap_time
=
0
...
...
@@ -151,7 +151,7 @@ class MultiTouchListener(Logger):
def
point_down
(
self
,
sid
,
x
,
y
):
"""
Called by TUIO
listen
er when a new touch point is created, triggers a
Called by TUIO
serv
er when a new touch point is created, triggers a
DownEvent.
"""
if
self
.
find_point
(
sid
):
...
...
@@ -165,7 +165,7 @@ class MultiTouchListener(Logger):
def
point_up
(
self
,
sid
):
"""
Called by TUIO
listen
er when a touch point is removed, triggers an
Called by TUIO
serv
er when a touch point is removed, triggers an
UpEvent. Also, simple/double tap detection is located here instead of
in the gesture thread (for responsiveness reasons).
"""
...
...
@@ -204,7 +204,7 @@ class MultiTouchListener(Logger):
def
point_move
(
self
,
sid
,
x
,
y
):
"""
Called by TUIO
listen
er when a touch point moves, triggers a MoveEvent.
Called by TUIO
serv
er when a touch point moves, triggers a MoveEvent.
The move event is only used if the movement distance is greater that a
preset constant, so that negligible movement is ignored. This prevents
unnecessary gesture detection.
...
...
@@ -394,7 +394,7 @@ class MultiTouchListener(Logger):
gesture_thread
.
daemon
=
True
gesture_thread
.
start
()
# Start TUIO
listen
er
# Start TUIO
serv
er
try
:
self
.
log
(
'Starting TUIO server'
)
self
.
server
.
start
()
...
...
@@ -430,17 +430,17 @@ if __name__ == '__main__':
def
tap
(
event
,
tap_type
):
print
'tap:'
,
tap_type
listener
=
MultiTouchListen
er
(
verbose
=
1
,
tuio_verbose
=
0
)
listen
er
.
bind
(
'tap'
,
tap
,
0
)
listen
er
.
bind
(
'single_tap'
,
tap
,
1
)
listen
er
.
bind
(
'double_tap'
,
tap
,
2
)
server
=
MultitouchServ
er
(
verbose
=
1
,
tuio_verbose
=
0
)
serv
er
.
bind
(
'tap'
,
tap
,
0
)
serv
er
.
bind
(
'single_tap'
,
tap
,
1
)
serv
er
.
bind
(
'double_tap'
,
tap
,
2
)
# Add empty handlers sp that the events are actually triggered
listen
er
.
bind
(
'rotate'
,
lambda
e
:
0
)
listen
er
.
bind
(
'pinch'
,
lambda
e
:
0
)
listen
er
.
bind
(
'pan'
,
lambda
e
:
0
)
serv
er
.
bind
(
'rotate'
,
lambda
e
:
0
)
serv
er
.
bind
(
'pinch'
,
lambda
e
:
0
)
serv
er
.
bind
(
'pan'
,
lambda
e
:
0
)
try
:
listen
er
.
start
()
serv
er
.
start
()
except
KeyboardInterrupt
:
listen
er
.
stop
()
serv
er
.
stop
()
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