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

Replaced occurences of 'listener' with 'server'.

parent 0fc618e5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import pygame import pygame
import sys import sys
import time import time
from touch import MultiTouchListener, screen_size from touch import MultitouchServer, screen_size
from math import degrees, cos, sin from math import degrees, cos, sin
from events import Rotate from events import Rotate
...@@ -73,9 +73,9 @@ def update(): ...@@ -73,9 +73,9 @@ def update():
screen.blit(transformed, rect) screen.blit(transformed, rect)
# Draw touch points # 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) xy = coord(p.x, p.y)
# Draw line to centroid # Draw line to centroid
...@@ -131,14 +131,14 @@ def pinch(event): ...@@ -131,14 +131,14 @@ def pinch(event):
scale = min(scale * event.amount, MAX_SCALE) scale = min(scale * event.amount, MAX_SCALE)
# Start touch event listener in separate thread # Start touch event server in separate thread
listener = MultiTouchListener(verbose=1, tuio_verbose=0) server = MultitouchServer(verbose=1, tuio_verbose=0)
listener.bind('rotate', rotate) server.bind('rotate', rotate)
listener.bind('pinch', pinch) server.bind('pinch', pinch)
listener.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS])) server.bind('tap', lambda e: taps.append([coord(*e.xy), FINGER_RADIUS]))
listener.bind('single_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [1])) server.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])) server.bind('double_tap', lambda e: dtaps.append(list(coord(*e.xy)) + [0]))
listener.start(threaded=True) server.start(threaded=True)
def is_quit_event(e): def is_quit_event(e):
...@@ -153,4 +153,4 @@ try: ...@@ -153,4 +153,4 @@ try:
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
finally: finally:
listener.stop() server.stop()
...@@ -127,9 +127,9 @@ class TouchPoint(object): ...@@ -127,9 +127,9 @@ class TouchPoint(object):
return rotation(prev, current) return rotation(prev, current)
class MultiTouchListener(Logger): class MultitouchServer(Logger):
def __init__(self, verbose=0, tuio_verbose=0, **kwargs): def __init__(self, verbose=0, tuio_verbose=0, **kwargs):
super(MultiTouchListener, self).__init__(**kwargs) super(MultitouchServer, self).__init__(**kwargs)
self.verbose = verbose self.verbose = verbose
self.last_tap = None self.last_tap = None
self.last_tap_time = 0 self.last_tap_time = 0
...@@ -151,7 +151,7 @@ class MultiTouchListener(Logger): ...@@ -151,7 +151,7 @@ class MultiTouchListener(Logger):
def point_down(self, sid, x, y): 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. DownEvent.
""" """
if self.find_point(sid): if self.find_point(sid):
...@@ -165,7 +165,7 @@ class MultiTouchListener(Logger): ...@@ -165,7 +165,7 @@ class MultiTouchListener(Logger):
def point_up(self, sid): 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 UpEvent. Also, simple/double tap detection is located here instead of
in the gesture thread (for responsiveness reasons). in the gesture thread (for responsiveness reasons).
""" """
...@@ -204,7 +204,7 @@ class MultiTouchListener(Logger): ...@@ -204,7 +204,7 @@ class MultiTouchListener(Logger):
def point_move(self, sid, x, y): 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 The move event is only used if the movement distance is greater that a
preset constant, so that negligible movement is ignored. This prevents preset constant, so that negligible movement is ignored. This prevents
unnecessary gesture detection. unnecessary gesture detection.
...@@ -394,7 +394,7 @@ class MultiTouchListener(Logger): ...@@ -394,7 +394,7 @@ class MultiTouchListener(Logger):
gesture_thread.daemon = True gesture_thread.daemon = True
gesture_thread.start() gesture_thread.start()
# Start TUIO listener # Start TUIO server
try: try:
self.log('Starting TUIO server') self.log('Starting TUIO server')
self.server.start() self.server.start()
...@@ -430,17 +430,17 @@ if __name__ == '__main__': ...@@ -430,17 +430,17 @@ if __name__ == '__main__':
def tap(event, tap_type): def tap(event, tap_type):
print 'tap:', tap_type print 'tap:', tap_type
listener = MultiTouchListener(verbose=1, tuio_verbose=0) server = MultitouchServer(verbose=1, tuio_verbose=0)
listener.bind('tap', tap, 0) server.bind('tap', tap, 0)
listener.bind('single_tap', tap, 1) server.bind('single_tap', tap, 1)
listener.bind('double_tap', tap, 2) server.bind('double_tap', tap, 2)
# Add empty handlers sp that the events are actually triggered # Add empty handlers sp that the events are actually triggered
listener.bind('rotate', lambda e: 0) server.bind('rotate', lambda e: 0)
listener.bind('pinch', lambda e: 0) server.bind('pinch', lambda e: 0)
listener.bind('pan', lambda e: 0) server.bind('pan', lambda e: 0)
try: try:
listener.start() server.start()
except KeyboardInterrupt: 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