-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswipe_controller.py
63 lines (50 loc) · 1.97 KB
/
swipe_controller.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
from typing import List
from pyautogui import press, hotkey
from abc import ABC, abstractmethod
class SwipeController:
def __init__(self, os: str, swipe_type: str):
self.os: str = os
self.swipe_type: str = swipe_type
def swipe_right(self) -> None:
print("Swipe right")
SwipeRight(self.os, self.swipe_type).swipe()
def swipe_left(self) -> None:
print("Swipe left")
SwipeLeft(self.os, self.swipe_type).swipe()
def is_swipe_right(self, left_up_fingers: List[bool]) -> bool:
return (not left_up_fingers[0] and left_up_fingers[1] and left_up_fingers[2] and
not left_up_fingers[3] and not left_up_fingers[4])
def is_swipe_left(self, right_up_fingers: List[bool]) -> bool:
return (not right_up_fingers[0] and right_up_fingers[1] and right_up_fingers[2] and
not right_up_fingers[3] and not right_up_fingers[4])
class SwipeAction(ABC):
def __init__(self, os: str, swipe_type: str):
self.os = os
self.swipe_type = swipe_type
@abstractmethod
def swipe(self) -> None:
pass
class SwipeRight(SwipeAction):
def swipe(self) -> None:
if self.os == "mac":
if self.swipe_type == "screens":
hotkey('ctrl', 'right')
elif self.swipe_type == "slides":
hotkey('right')
elif self.os == "windows":
if self.swipe_type == "screens":
press('alt', 'tab')
elif self.swipe_type == "slides":
press('right')
class SwipeLeft(SwipeAction):
def swipe(self) -> None:
if self.os == "mac":
if self.swipe_type == "screens":
hotkey('ctrl', 'left')
elif self.swipe_type == "slides":
hotkey('left')
elif self.os == "windows":
if self.swipe_type == "screens":
press('alt', 'shift', 'tab')
elif self.swipe_type == "slides":
press('left')