-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPSPEWC.py
executable file
·68 lines (55 loc) · 2.13 KB
/
PSPEWC.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
#/* ---------------------------------------------------------------------------
#** This software is in the public domain, furnished "as is", without technical
#** support, and with no warranty, express or implied, as to its usefulness for
#** any purpose.
#** -------------------------------------------------------------------------*/
#
# Use Protocol 1 (PSP in keypad #1 mode) to simulate regular buttons. The analog stick should control the mouse.
#
# This program will receive a string of keystates and simulate key presses and mouse events.
# This string is 17-char long and contain '0's and '1's acording to that key state. This
# software was conceived as a port of the PSPEWC (http://PSPEWC.blogspot.com) server, Anyway,
# which runs on Microsoft Windows systems.it can work with any other client that sends a similar
# string at the port 30666 of this UDP socket.
# Use Protocol 1 (PSP in keypad #1 mode) to simulate regular buttons. The analog stick also simulates key presses,
# so you can use it in regular emulators, for example.should control the mouse.
import EWCnetworking
import EWCcontroller
import rumps
import threading
import time
srv = EWCnetworking.Server()
ctrl = EWCcontroller.Controller()
VERSION = 'Version: 0.4'
SERVER = srv.localaddr
MOUSE = 'Enable mouse'
def rumpsGUI():
@rumps.clicked('Quit')
def clean_up_before_quit(_):
print 'execute clean up code'
rumps.quit_application()
@rumps.clicked(MOUSE)
def not_actually_prefs(sender):
ctrl.mouse = 1
sender.state = not sender.state
app = rumps.App(u"\U0001F579", menu=['PSP Wireless Controller', VERSION, SERVER, MOUSE, None, None, 'Quit'], quit_button=None)
app.run()
def runServer():
while 1:
srv.receive()
ctrl.handle_string(srv.message)
##Start test
class ThreadingExample(object):
def __init__(self, interval=1):
self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.daemon = True
thread.start()
def run(self):
while True:
srv.receive()
ctrl.handle_string(srv.message)
example = ThreadingExample()
rumpsGUI()
print('Bye')