-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.py
More file actions
68 lines (59 loc) · 2.52 KB
/
Controller.py
File metadata and controls
68 lines (59 loc) · 2.52 KB
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
import pipes
"""
self.pipe = this is variable that is the pipe, you can write to it, or read to it and it will write to the file
self.path = the location to where the dolphin folder is inside the computer
"""
class Controller:
def __init__(self, path):
self.path = path;
self.__setupPipe();
def __setupPipe(self):
# pipeTemplate = pipes.Template()
# pipeTemplate.append('tr a-z A-Z', '--')
self.pipe = open(self.path+'/Pipes/SmashBot', 'w');
#call this at the end of every script
def releaseButtons(self):
# if(not self.pipe): self.__setupPipe();
# print("self.pipe: ", self.pipe );
self.pipe.write("SET MAIN 0.5 0.5\n");
self.pipe.write("SET C 0.5 0.5\n");
self.pipe.write("SET L 0\n");
self.pipe.write("SET R 0\n");
self.pipe.write("RELEASE X\n");
self.pipe.write("RELEASE A\n");
self.pipe.write("RELEASE B\n");
self.pipe.write("RELEASE Z\n");
self.pipe.write("RELEASE L\n");
self.pipe.write("RELEASE START\n");
self.pipe.flush();
"""
this function will press or release the given button for the given amount of time
par1 = button2Press = the current button that needs to be pressed
par2 = timeHeld = the time that the button needs to be held
par3 = if you want the button to be released make pressOrReleased to False
"""
def inputs(self,button2Press,pressOrRelease=True):
# pipeTemplate = pipes.Template()
# pipeTemplate.append('tr a-z A-Z', '--')
action = "PRESS";
if(not pressOrRelease): action = "RELEASE";
self.pipe.write(action + " "+button2Press+"\n")
# self.pipe.close();
self.pipe.flush();
def inputAnalog(self,action,buttonXCord,buttonYCord,pressOrRelease=True):
# pipeTemplate = pipes.Template()
# print (buttonXCord,buttonYCord,pressOrRelease)
# pipeTemplate.append('tr a-z A-Z', '--')
if(not pressOrRelease): action = "RELEASE";
self.pipe.write("SET"+" "+action+" "+buttonXCord+" "+buttonYCord+"\n")
# self.pipe.close();
self.pipe.flush();
def triggerAnalog(self,action,buttonXCord,pressOrRelease=True):
# pipeTemplate = pipes.Template()
# pipeTemplate.append('tr a-z A-Z', '--')
if(not pressOrRelease): action = "RELEASE";
self.pipe.write("SET"+" "+action+" "+buttonXCord+" "+"\n")
self.pipe.flush();
# self.pipe.close();
#still a work in progress
# if __name__ == "__main__":