-
Notifications
You must be signed in to change notification settings - Fork 0
/
mousepad_main.py
65 lines (47 loc) · 2.04 KB
/
mousepad_main.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
from os import environ
from tendo import singleton
from win10toast_click import ToastNotifier
from controller import *
environ["PBR_VERSION"] = "4.0.2"
mousepad = singleton.SingleInstance()
def main():
on = True
l2_pressed = False
r2_pressed = False
last_stick = timestamp()
last_trigger = timestamp()
notify = ToastNotifier()
error_notified = False
disable_notified = False
while True:
try:
events, triggers, sticks = poll_controller()
error_notified = False
except XInputNotConnectedError:
if error_notified == False:
notify.show_toast("Controller Disconnected", "Controller may not be connected, try checking if bluetooth is working or reconnect the usb cable.",
icon_path="mouse_pad.ico", duration=5, threaded=True)
error_notified = True
continue
try:
on = button_handler(events, on)
except (Keyboard.InvalidKeyException, TypeError):
pass
if on == True:
if disable_notified == True:
notify.show_toast("Controller Input Enabled", "The controller input has now been enabled, press the View Button to de-activate it.",
icon_path="mouse_pad.ico", duration=5, threaded=True)
last_trigger, l2_pressed, r2_pressed = trigger_handler(
triggers, last_trigger, l2_pressed, r2_pressed)
last_stick = stick_handler(sticks, last_stick)
disable_notified = False
else:
if disable_notified == False:
notify.show_toast("Controller Input Disabled", "The controller input has now been disabled, press the View Button to re-activate it.",
icon_path="mouse_pad.ico", duration=5, threaded=True)
disable_notified = True
if __name__ == "__main__":
main()
else:
raise ImportError(
"This is not meant to be imported as a module, it is the main program for MousePad.")