-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathnoise.py
More file actions
74 lines (66 loc) · 2.46 KB
/
noise.py
File metadata and controls
74 lines (66 loc) · 2.46 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
import time
from talon import ctrl, voice
from talon import tap
from talon.audio import noise
from talon.track.geom import Point2d
from talon_plugins import eye_zoom_mouse
class NoiseModel:
def __init__(self):
self.hiss_start = 0
self.hiss_last = 0
self.button = 0
self.mouse_origin = Point2d(0, 0)
self.mouse_last = Point2d(0, 0)
self.dragging = False
tap.register(tap.MMOVE, self.on_move)
noise.register("noise", self.on_noise)
def on_move(self, typ, e):
if typ != tap.MMOVE:
return
self.mouse_last = pos = Point2d(e.x, e.y)
if self.hiss_start and not self.dragging:
if (pos - self.mouse_origin).len() > 10:
self.dragging = True
self.button = 0
x, y = self.mouse_origin.x, self.mouse_origin.y
ctrl.mouse(x, y)
# removing click and drag for now
# ctrl.mouse_click(x, y, button=0, down=True)
def on_noise(self, noise):
# now = time.time()
if not voice.talon.enabled:
return
if noise == "pop" and eye_zoom_mouse.zoom_mouse.enabled:
return
if noise == "pop":
ctrl.mouse_click(button=0, hold=16000)
# elif noise == 'hiss_start':
# if now - self.hiss_last < 0.25:
# # removing click and drag for now
# # ctrl.mouse_click(button=self.button, down=True)
# self.hiss_last = now
# self.dragging = True
# else:
# self.mouse_origin = self.mouse_last
# self.hiss_start = now
# elif noise == 'hiss_end':
# if self.dragging:
#
# # removing click and drag for now
# # ctrl.mouse_click(button=self.button, up=True)
# self.dragging = False
# else:
# duration = time.time() - self.hiss_start
#
# # 0.5 hiss or greater triggers right-click
# if duration > 0.5:
# self.button = 1
# ctrl.mouse_click(button=1)
# self.hiss_last = now
# # deleting clicking for now
# # elif duration > 0.3:
# # self.button = 0
# # ctrl.mouse_click(button=0)
# # self.hiss_last = now
# self.hiss_start = 0
model = NoiseModel()