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
530c6a5f
Commit
530c6a5f
authored
May 18, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'unbind' method and moved screen_size to a separate file to prevent cyclic imports.
parent
d0ffb5c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
13 deletions
+31
-13
src/screen.py
src/screen.py
+11
-0
src/touch.py
src/touch.py
+20
-13
No files found.
src/screen.py
0 → 100644
View file @
530c6a5f
import
pygame.display
__all__
=
[
'screen_size'
]
# get screen resolution
pygame
.
display
.
init
()
info
=
pygame
.
display
.
Info
()
screen_size
=
info
.
current_w
,
info
.
current_h
pygame
.
display
.
quit
()
src/touch.py
View file @
530c6a5f
#!/usr/bin/env python
from
__future__
import
division
import
time
import
pygame.display
from
math
import
atan2
,
pi
from
threading
import
Thread
from
screen
import
screen_size
from
tuio_server
import
TuioServer2D
from
logger
import
Logger
from
events
import
Event
,
DownEvent
,
UpEvent
,
MoveEvent
,
Tap
,
\
SingleTap
,
DoubleTap
,
Flick
,
Rotate
,
Pinch
,
\
Pan
# get screen resolution
pygame
.
display
.
init
()
info
=
pygame
.
display
.
Info
()
screen_size
=
info
.
current_w
,
info
.
current_h
pygame
.
display
.
quit
()
# Heuristic constants
# TODO: Encapsulate screen resolution in distance heuristics
SUPPORTED_EVENTS
=
(
'down'
,
'up'
,
'move'
,
'tap'
,
'single_tap'
,
'double_tap'
,
...
...
@@ -401,17 +395,30 @@ class MultitouchServer(Logger):
except
SystemExit
:
self
.
stop
()
def
bind
(
self
,
gestur
e
,
handler
,
*
args
,
**
kwargs
):
def
bind
(
self
,
nam
e
,
handler
,
*
args
,
**
kwargs
):
"""
Bind a handler to an event or gesture.
"""
if
gesture
not
in
SUPPORTED_EVENTS
:
raise
ValueError
(
'Unsupported gesture "%s".'
%
gesture
)
if
name
not
in
SUPPORTED_EVENTS
:
raise
ValueError
(
'Unsupported event name "%s".'
%
name
)
if
name
not
in
self
.
handlers
:
self
.
handlers
[
name
]
=
[]
self
.
handlers
[
name
].
append
((
handler
,
args
,
kwargs
))
if
gesture
not
in
self
.
handlers
:
self
.
handlers
[
gesture
]
=
[]
def
unbind
(
self
,
name
,
handler
=
None
):
"""
Remove one or all handlers that are bound to an event name.
"""
if
name
not
in
self
.
handlers
:
raise
KeyError
(
'No handlers are bound to event name "%s".'
%
name
)
self
.
handlers
[
gesture
].
append
((
handler
,
args
,
kwargs
))
if
handler
:
self
.
handlers
[
name
]
=
[
h
for
h
in
self
.
handlers
[
name
]
if
h
[
0
]
!=
handler
]
else
:
del
self
.
handlers
[
name
]
def
trigger
(
self
,
event
):
"""
...
...
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