-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
105 lines (96 loc) · 3.03 KB
/
Main.py
File metadata and controls
105 lines (96 loc) · 3.03 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from pynput.mouse import Button, Controller
import pygame
pygame.init()
pygame.joystick.init()
controller = pygame.joystick.Joystick(0)
controller.init()
mouse = Controller()
changeX = 0
changeY = 0
six = False
seven = False
end = False
exit = False
side = 0
updown = 0
while True:
while True:
for event in pygame.event.get():
if event.type == pygame.JOYHATMOTION:
side = -event.value[0]
updown = event.value[1]
if event.type == pygame.JOYAXISMOTION:
if(event.axis==0):
changeX = int(event.value*1.5)
elif(event.axis==1):
changeY = int(event.value*1.5)
elif(event.axis==2):
changeX = int(event.value*3)
elif(event.axis==3):
changeY = int(event.value*3)
if event.type == pygame.JOYBUTTONDOWN:
if(event.button==12):
exit = True
break
elif event.button == 6:
six = True
elif event.button == 7:
seven = True
elif event.button == 10:
mouse.press(Button.left)
elif event.button == 11:
mouse.press(Button.right)
else:
mouse.press(Button.left)
if event.type == pygame.JOYBUTTONUP:
if event.button == 6:
six = False
elif event.button == 7:
seven = False
elif event.button == 10:
mouse.release(Button.left)
elif event.button == 11:
mouse.release(Button.right)
else:
mouse.release(Button.left)
if(exit):
exit = False
break
mouse.scroll(side,updown)
if(six and seven):
end = True
break
mouse.move(changeX, changeY)
if(mouse.position[0]<10):
mouse.position=(2550,mouse.position[1])
if(mouse.position[1]<10):
mouse.position=(mouse.position[0],790)
if(mouse.position[0]>2550):
mouse.position=(10,mouse.position[1])
if(mouse.position[1]>790):
mouse.position=(mouse.position[0],10)
if end:
break
while True:
for event in pygame.event.get():
if event.type == pygame.JOYBUTTONDOWN:
if event.button == 12:
exit = True
break
if event.button == 6:
six = True
if event.button == 7:
seven = True
if event.type == pygame.JOYBUTTONUP:
if event.button == 6:
six = False
if event.button == 7:
seven = False
if(exit):
exit=False
break
if (six and seven):
end = True
break
if end:
break