Script demo_remoteSource_py
|
|
1 from joy import *
2 from joy.remote import Source as RemoteSource
3
10
12 self.rs = RemoteSource(self, self.dst)
13 self.rs.start()
14
16 if evt.type in set([KEYDOWN,KEYUP,JOYAXISMOTION]):
17
18 if evt.type == KEYDOWN:
19 JoyApp.onEvent(self,evt)
20 self.rs.push( evt )
21 return
22 elif evt.type == MOUSEMOTION:
23 return
24 JoyApp.onEvent(self,evt)
25
26 if __name__=="__main__":
27 print """
28 Demonstration of RemoteSource plan
29 ------------------------------------
30
31 Sends keyboard events to a remote JoyApp, specified on the commandline as two parameters: host port
32
33 """
34 import sys
35 from joy.remote import DEFAULT_PORT
36 if len(sys.argv)>1:
37 if len(sys.argv)>2:
38 port = int(sys.argv[2])
39 else:
40 port = DEFAULT_PORT
41 progress("**** Using default port "+str(DEFAULT_PORT))
42 app = RemoteSourceApp(sink=(sys.argv[1],port))
43 else:
44 app = RemoteSourceApp()
45 app.run()
46