-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyInputHandler.py
49 lines (36 loc) · 1.1 KB
/
myInputHandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import *
import time
class InputHandler(DirectObject):
def __init__(self):
#setting it active by default
self.setActive()
self.pressedP = False
def modObjects(self,task):
dt = globalClock.getDt()
#resolving P event
if self.pressedP == True:
# figure out how much the mouse has moved (in pixels)
millis = int(round(time.time() * 1000))
print "ping happened at ",millis,"!"
return Task.cont
def setInactive(self):
# Main Modifier
self.ignoreAll()
taskMgr.remove("objectModifierTask")
def setActive(self):
# Main Modifier
self.accept("p", self.pressKey, ["p"])
self.accept("p-up", self.releaseKey, ["p"])
#self.ignore()
taskMgr.add(self.modObjects, "objectModifierTask")
def releaseKey(self,key):
myCamera.ce.keyReleased()
if key == "p":
self.pressedP = False
def pressKey(self,key):
#default behaviour when hiding camera
myCamera.ce.keyPressed()
if key == "p":
self.pressedP = True