Enums and Constantsο
This section documents the enumerations and constants used in the Makcu library, aligned with the current API as shown in the main documentation.
Human-Like Profilesο
The library supports string-based timing profiles for human-like mouse interactions, used with the click_human_like() method.
Available Profiles:
- GAMING_PROFILE: str = "gaming"ο
Ultra-fast profile optimized for competitive gaming (1-5ms delays)
Usage Examples:
# Synchronous API
makcu.click_human_like(MouseButton.LEFT, count=3, profile="gaming")
makcu.click_human_like(MouseButton.RIGHT, count=5, profile="normal", jitter=5)
# Asynchronous API
await makcu.click_human_like(MouseButton.LEFT, count=2, profile="gaming", jitter=3)
await makcu.click_human_like(MouseButton.RIGHT, count=3, profile="variable")
Profile Characteristics:
Profile |
Min Delay |
Max Delay |
Best For |
|---|---|---|---|
|
1ms |
5ms |
Competitive gaming, maximum speed |
|
10ms |
30ms |
Productivity automation, quick tasks |
|
50ms |
150ms |
General automation, natural feel |
|
200ms |
500ms |
Careful automation, older systems |
|
50ms |
300ms |
Anti-detection, randomized patterns |
Lock Targetsο
The locking system accepts string identifiers for buttons and axes that can be locked to prevent input.
Button Lock Targets:
Axis Lock Targets:
Usage Examples:
# Lock buttons (synchronous)
makcu.lock(MouseButton.LEFT) # Using enum
makcu.lock("RIGHT") # Using string
makcu.lock("MIDDLE")
# Lock movement axes
makcu.lock("X") # Lock horizontal movement
makcu.lock("Y") # Lock vertical movement
# Asynchronous API
await makcu.lock(MouseButton.LEFT)
await makcu.lock("X")
await makcu.unlock("Y")
# Check lock status
is_locked = makcu.is_locked(MouseButton.LEFT)
all_locks = makcu.get_all_lock_states()
# Returns: {"LEFT": True, "RIGHT": False, "X": True, "Y": False, ...}
Constants and Default Valuesο
Serial Communicationο
- VID_PID: tuple = (0x1a86, 0x55d3)ο
USB Vendor ID and Product ID for auto-detection (CH343 chipset)
Usage Examples:
# Custom timeout (synchronous)
makcu = create_controller(timeout=0.05) # 50ms timeout
# Custom timeout (asynchronous)
makcu = await create_async_controller(timeout=0.05)
Device Limitsο
Usage Examples:
# Large movements are automatically clamped
makcu.move(50000, 25000) # Clamped to MAX_MOVE_DISTANCE
# Asynchronous version
await makcu.move(50000, 25000)
# Maximum scroll
makcu.scroll(MAX_SCROLL_STEPS)
await makcu.scroll(-MAX_SCROLL_STEPS) # Scroll down maximum
Performance Constantsο
- GAMING_REFRESH_RATES: dict = {"60Hz": 16.7, "144Hz": 7.0, "240Hz": 4.2, "360Hz": 2.8}ο
Common gaming refresh rates and their frame times in milliseconds
- PERFORMANCE_TARGETS: dict = {"excellent": 1, "good": 3, "acceptable": 5}ο
Performance targets in milliseconds per operation (v2.0 benchmarks)
Usage Examples:
# Performance-aware gaming code
import time
# Benchmark operation timing
start = time.perf_counter()
makcu.click(MouseButton.LEFT)
operation_time = (time.perf_counter() - start) * 1000 # Convert to ms
if operation_time < PERFORMANCE_TARGETS["excellent"]:
print(f"Excellent performance: {operation_time:.2f}ms (suitable for 360Hz gaming)")
elif operation_time < GAMING_REFRESH_RATES["144Hz"]:
print(f"Good for 144Hz gaming: {operation_time:.2f}ms")
Error Handling Constantsο
The library defines specific error types for different failure conditions.
- ERROR_TYPES: tuple = (MakcuError, MakcuConnectionError, MakcuTimeoutError)ο
Main exception types used by the library
Usage Examples:
from makcu import MakcuError, MakcuConnectionError, MakcuTimeoutError
# Synchronous error handling
try:
makcu = create_controller()
makcu.click(MouseButton.LEFT)
except MakcuConnectionError as e:
print(f"Connection failed: {e}")
except MakcuTimeoutError as e:
print(f"Operation timed out: {e}")
except MakcuError as e:
print(f"General error: {e}")
# Asynchronous error handling
try:
makcu = await create_async_controller()
await makcu.click(MouseButton.LEFT)
except MakcuConnectionError as e:
print(f"Connection failed: {e}")
Version Informationο
Usage Examples:
# Check library version
import makcu
print(f"Makcu library version: {makcu.__version__}")
# Version-specific feature usage
if makcu.__version__ >= "2.0":
# Use new async features
makcu = await create_async_controller()
else:
# Fall back to sync only
makcu = create_controller()
Type Hints and Validationο
The library provides flexible input types while maintaining type safety.
Acceptable Button Types:
MouseButtonenum values (recommended)Integer values (0-4, mapped to buttons)
String names (βLEFTβ, βRIGHTβ, etc., case-insensitive)
Acceptable Profile Types:
String literals (βgamingβ, βfastβ, βnormalβ, βslowβ, βvariableβ)
Acceptable Lock Target Types:
MouseButtonenum values for button locksString identifiers (βXβ, βYβ for axes; βLEFTβ, βRIGHTβ, etc. for buttons)
Usage Examples:
# All of these work (flexible input types):
# Using enums (recommended for type safety)
makcu.click(MouseButton.LEFT)
# Using integers
makcu.click(0) # Same as MouseButton.LEFT
# Using strings (case-insensitive)
makcu.click("left")
makcu.click("LEFT")
makcu.click("Left")
# Profile flexibility
makcu.click_human_like(MouseButton.LEFT, profile="gaming")
makcu.click_human_like(MouseButton.LEFT, profile="GAMING")
# Lock target flexibility
makcu.lock(MouseButton.LEFT) # Enum
makcu.lock("LEFT") # String
makcu.lock("x") # Axis (case-insensitive)
Best Practicesο
Use MouseButton Enum for Type Safety:
# Recommended: Clear and type-safe await makcu.click(MouseButton.LEFT) # Avoid: Magic numbers await makcu.click(0)
Consistent Profile Usage:
# Consistent profile strings GAMING_PROFILE = "gaming" await makcu.click_human_like(MouseButton.LEFT, profile=GAMING_PROFILE)
Error Handling:
# Always handle connection errors try: async with await create_async_controller() as makcu: await makcu.click(MouseButton.LEFT) except MakcuConnectionError: print("Could not connect to Makcu device")
Performance-Aware Code:
# Check performance for gaming applications if operation_time < GAMING_REFRESH_RATES["240Hz"]: print("Suitable for 240Hz gaming!")
Use Context Managers:
# Automatic connection management async with await create_async_controller() as makcu: await makcu.click(MouseButton.LEFT) # Automatically disconnects
Integration with Main APIο
These enums and constants integrate seamlessly with both synchronous and asynchronous APIs:
from makcu import create_controller, create_async_controller, MouseButton
import asyncio
# Synchronous usage
def sync_example():
with create_controller() as makcu:
makcu.click(MouseButton.LEFT)
makcu.move(100, 50)
makcu.click_human_like(MouseButton.RIGHT, count=3, profile="gaming")
# Asynchronous usage
async def async_example():
async with await create_async_controller() as makcu:
await makcu.click(MouseButton.LEFT)
await makcu.move(100, 50)
await makcu.click_human_like(MouseButton.RIGHT, count=3, profile="gaming")
# Run async version
asyncio.run(async_example())
See Alsoο
MakcuController API Reference - Main synchronous controller API
async_controller - Asynchronous controller API
Getting Started with Makcu Python Library - Basic usage tutorial
Examples - More code examples with enums
Async Usage - Async/await patterns