makcu 2.3.0__py3-none-any.whl → 2.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- makcu/mouse.py +7 -31
- {makcu-2.3.0.dist-info → makcu-2.3.1.dist-info}/METADATA +1 -1
- {makcu-2.3.0.dist-info → makcu-2.3.1.dist-info}/RECORD +6 -6
- {makcu-2.3.0.dist-info → makcu-2.3.1.dist-info}/WHEEL +0 -0
- {makcu-2.3.0.dist-info → makcu-2.3.1.dist-info}/licenses/LICENSE +0 -0
- {makcu-2.3.0.dist-info → makcu-2.3.1.dist-info}/top_level.txt +0 -0
makcu/mouse.py
CHANGED
@@ -11,8 +11,6 @@ class AxisButton:
|
|
11
11
|
self.name = name
|
12
12
|
|
13
13
|
class Mouse:
|
14
|
-
|
15
|
-
|
16
14
|
_BUTTON_COMMANDS = {
|
17
15
|
MouseButton.LEFT: "left",
|
18
16
|
MouseButton.RIGHT: "right",
|
@@ -20,7 +18,6 @@ class Mouse:
|
|
20
18
|
MouseButton.MOUSE4: "ms1",
|
21
19
|
MouseButton.MOUSE5: "ms2",
|
22
20
|
}
|
23
|
-
|
24
21
|
|
25
22
|
_PRESS_COMMANDS = {}
|
26
23
|
_RELEASE_COMMANDS = {}
|
@@ -32,18 +29,13 @@ class Mouse:
|
|
32
29
|
self.transport = transport
|
33
30
|
self._lock_states_cache: int = 0
|
34
31
|
self._cache_valid = False
|
35
|
-
|
36
|
-
|
37
32
|
self._init_command_cache()
|
38
33
|
|
39
34
|
def _init_command_cache(self) -> None:
|
40
|
-
|
41
35
|
for button, cmd in self._BUTTON_COMMANDS.items():
|
42
36
|
self._PRESS_COMMANDS[button] = f"km.{cmd}(1)"
|
43
37
|
self._RELEASE_COMMANDS[button] = f"km.{cmd}(0)"
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
|
47
39
|
lock_targets = [
|
48
40
|
("LEFT", "ml", 0),
|
49
41
|
("RIGHT", "mr", 1),
|
@@ -53,7 +45,7 @@ class Mouse:
|
|
53
45
|
("X", "mx", 5),
|
54
46
|
("Y", "my", 6),
|
55
47
|
]
|
56
|
-
|
48
|
+
|
57
49
|
for name, cmd, bit in lock_targets:
|
58
50
|
self._LOCK_COMMANDS[name] = (f"km.lock_{cmd}(1)", bit)
|
59
51
|
self._UNLOCK_COMMANDS[name] = (f"km.lock_{cmd}(0)", bit)
|
@@ -62,7 +54,6 @@ class Mouse:
|
|
62
54
|
def _send_button_command(self, button: MouseButton, state: int) -> None:
|
63
55
|
if button not in self._BUTTON_COMMANDS:
|
64
56
|
raise MakcuCommandError(f"Unsupported button: {button}")
|
65
|
-
|
66
57
|
|
67
58
|
cmd = self._PRESS_COMMANDS[button] if state else self._RELEASE_COMMANDS[button]
|
68
59
|
self.transport.send_command(cmd)
|
@@ -79,8 +70,7 @@ class Mouse:
|
|
79
70
|
def move_abs(self,
|
80
71
|
target: tuple[int, int],
|
81
72
|
speed: int = 1,
|
82
|
-
wait_ms: int = 2
|
83
|
-
debug: bool = False) -> None:
|
73
|
+
wait_ms: int = 2) -> None:
|
84
74
|
|
85
75
|
def get_mouse_speed_multiplier() -> float:
|
86
76
|
"""Return multiplier to convert pixels to mickeys based on Windows pointer speed."""
|
@@ -99,9 +89,11 @@ class Mouse:
|
|
99
89
|
return pt.x, pt.y
|
100
90
|
|
101
91
|
multiplier = get_mouse_speed_multiplier()
|
102
|
-
last_pos = None
|
103
92
|
end_x, end_y = target
|
104
93
|
|
94
|
+
# clamp speed to be between 1-14. >15 creates an infinite overflick loop issue.
|
95
|
+
speed = max(1, min(speed, 14))
|
96
|
+
|
105
97
|
while True:
|
106
98
|
cx, cy = get_cursor_pos()
|
107
99
|
dx, dy = end_x - cx, end_y - cy
|
@@ -112,26 +104,16 @@ class Mouse:
|
|
112
104
|
move_x = max(-speed, min(speed, int(dx / multiplier)))
|
113
105
|
move_y = max(-speed, min(speed, int(dy / multiplier)))
|
114
106
|
|
115
|
-
if debug and (cx, cy) != last_pos:
|
116
|
-
print(
|
117
|
-
f"[DEBUG] Current: ({cx}, {cy}) | Target delta: ({move_x}, {move_y}) -> "
|
118
|
-
f"Multiplier={multiplier:.3f} | Speed={speed} | Last=({last_pos[0]}, {last_pos[1]}) | "
|
119
|
-
f"|Δx|={abs(dx):.2f}, |Δy|={abs(dy):.2f}"
|
120
|
-
)
|
121
|
-
last_pos = (cx, cy)
|
122
|
-
|
123
107
|
self.transport.send_command(f"km.move({move_x},{move_y})")
|
124
108
|
time.sleep(wait_ms / 1000)
|
125
109
|
|
126
110
|
def click(self, button: MouseButton) -> None:
|
127
111
|
if button not in self._BUTTON_COMMANDS:
|
128
112
|
raise MakcuCommandError(f"Unsupported button: {button}")
|
129
|
-
|
130
113
|
|
131
114
|
press_cmd = self._PRESS_COMMANDS[button]
|
132
115
|
release_cmd = self._RELEASE_COMMANDS[button]
|
133
116
|
|
134
|
-
|
135
117
|
transport = self.transport
|
136
118
|
transport.send_command(press_cmd)
|
137
119
|
transport.send_command(release_cmd)
|
@@ -154,7 +136,6 @@ class Mouse:
|
|
154
136
|
|
155
137
|
self.transport.send_command(cmd)
|
156
138
|
|
157
|
-
|
158
139
|
if lock:
|
159
140
|
self._lock_states_cache |= (1 << bit)
|
160
141
|
else:
|
@@ -243,7 +224,6 @@ class Mouse:
|
|
243
224
|
"MOUSE5": bool(self._lock_states_cache & (1 << 4)),
|
244
225
|
}
|
245
226
|
|
246
|
-
|
247
227
|
states = {}
|
248
228
|
targets = ["X", "Y", "LEFT", "RIGHT", "MIDDLE", "MOUSE4", "MOUSE5"]
|
249
229
|
|
@@ -255,7 +235,6 @@ class Mouse:
|
|
255
235
|
is_locked = result.strip() == '1'
|
256
236
|
states[target] = is_locked
|
257
237
|
|
258
|
-
|
259
238
|
if is_locked:
|
260
239
|
self._lock_states_cache |= (1 << bit)
|
261
240
|
else:
|
@@ -271,12 +250,10 @@ class Mouse:
|
|
271
250
|
def is_locked(self, button: Union[MouseButton, AxisButton]) -> bool:
|
272
251
|
try:
|
273
252
|
target_name = button.name if hasattr(button, 'name') else str(button)
|
274
|
-
|
275
253
|
|
276
254
|
if self._cache_valid and target_name in self._LOCK_QUERY_COMMANDS:
|
277
255
|
_, bit = self._LOCK_QUERY_COMMANDS[target_name]
|
278
256
|
return bool(self._lock_states_cache & (1 << bit))
|
279
|
-
|
280
257
|
|
281
258
|
cmd, bit = self._LOCK_QUERY_COMMANDS[target_name]
|
282
259
|
result = self.transport.send_command(cmd, expect_response=True, timeout=0.05)
|
@@ -287,7 +264,6 @@ class Mouse:
|
|
287
264
|
result = result.strip()
|
288
265
|
is_locked = result == '1'
|
289
266
|
|
290
|
-
|
291
267
|
if is_locked:
|
292
268
|
self._lock_states_cache |= (1 << bit)
|
293
269
|
else:
|
@@ -296,4 +272,4 @@ class Mouse:
|
|
296
272
|
return is_locked
|
297
273
|
|
298
274
|
except Exception:
|
299
|
-
return False
|
275
|
+
return False
|
@@ -7,11 +7,11 @@ makcu/controller.py,sha256=DRSS9qySJjdKKlUYXf90GemF_HXMTK3ewdqEBJRe06U,14069
|
|
7
7
|
makcu/enums.py,sha256=1SvIv5IoMIfXyoMAq8I5r_aKMVKjYR-L_hXkFLJ_5mw,119
|
8
8
|
makcu/errors.py,sha256=hXdeUCHvbzfqWX3uotG12Xv8EPwWs-5aHQ12xpgwx3Y,229
|
9
9
|
makcu/makcu.pyi,sha256=UfbX7774u_a9oyIa1rweWqIRoQxVAjhhHUuukDp3jiA,237
|
10
|
-
makcu/mouse.py,sha256=
|
10
|
+
makcu/mouse.py,sha256=dawpgWUs6V-CeMlsiPrELSbJmmgYl7QjlqK15Y0bXGI,9819
|
11
11
|
makcu/py.typed,sha256=ks2XNwsNldow4qVp9kuCuGBuHTmngmrzgvRnkzWIGMY,110
|
12
12
|
makcu/test_suite.py,sha256=mfzr7L63Eim1z4-l7WHtWs7szGr6bNk2U13vXVlWeM4,4295
|
13
|
-
makcu-2.3.
|
14
|
-
makcu-2.3.
|
15
|
-
makcu-2.3.
|
16
|
-
makcu-2.3.
|
17
|
-
makcu-2.3.
|
13
|
+
makcu-2.3.1.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
14
|
+
makcu-2.3.1.dist-info/METADATA,sha256=Y-ATRFlY_DLYQf3MKz5WpqI6dHhkWp2nhHFrn83u_RM,53904
|
15
|
+
makcu-2.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
makcu-2.3.1.dist-info/top_level.txt,sha256=IRO1UVb5LK_ovjau0g4oObyXQqy00tVEE-yF5lPgw1w,6
|
17
|
+
makcu-2.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|