Commit 0a7f8692 authored by Taddeus Kroes's avatar Taddeus Kroes

Replaced occurences of 'listener' with 'server'.

parent 0fc618e5
......@@ -2,7 +2,7 @@
import pygame
import sys
import time
from touch import MultiTouchListener, screen_size
from touch import MultitouchServer, 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(*listener.centroid)
c = coord(*server.centroid)
for p in listener.points:
for p in server.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 listener in separate thread
listener = MultiTouchListener(verbose=1, tuio_verbose=0)
listener.bind('rotate', rotate)
listener.bind('pinch', pinch)
listener.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS]))
listener.bind('single_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [1]))
listener.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0]))
listener.start(threaded=True)
# Start touch event server in separate thread
server = MultitouchServer(verbose=1, tuio_verbose=0)
server.bind('rotate', rotate)
server.bind('pinch', pinch)
server.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS]))
server.bind('single_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [1]))
server.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0]))
server.start(threaded=True)
def is_quit_event(e):
......@@ -153,4 +153,4 @@ try:
except KeyboardInterrupt:
pass
finally:
listener.stop()
server.stop()
......@@ -127,9 +127,9 @@ class TouchPoint(object):
return rotation(prev, current)
class MultiTouchListener(Logger):
class MultitouchServer(Logger):
def __init__(self, verbose=0, tuio_verbose=0, **kwargs):
super(MultiTouchListener, self).__init__(**kwargs)
super(MultitouchServer, 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 listener when a new touch point is created, triggers a
Called by TUIO server 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 listener when a touch point is removed, triggers an
Called by TUIO server 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 listener when a touch point moves, triggers a MoveEvent.
Called by TUIO server 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 listener
# Start TUIO server
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 = MultiTouchListener(verbose=1, tuio_verbose=0)
listener.bind('tap', tap, 0)
listener.bind('single_tap', tap, 1)
listener.bind('double_tap', tap, 2)
server = MultitouchServer(verbose=1, tuio_verbose=0)
server.bind('tap', tap, 0)
server.bind('single_tap', tap, 1)
server.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)
server.bind('rotate', lambda e: 0)
server.bind('pinch', lambda e: 0)
server.bind('pan', lambda e: 0)
try:
listener.start()
server.start()
except KeyboardInterrupt:
listener.stop()
server.stop()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment