Python API for MAKXD USB HID devices
Project description
makxd
makxd is the Python API in mak-suite
for controlling MAKXD devices over their serial interface. It provides the
firmware-native ASCII command surface, mouse and keyboard helpers, and the
shared binary input-stream codec.
Install
The package is published on PyPI:
python -m pip install makxd
The package requires Python 3.10 or newer.
Quick start
from makxd import MouseButton, create_controller
device = create_controller()
device.move(100, 50)
device.click(MouseButton.LEFT)
device.scroll(-3)
device.disconnect()
create_controller() discovers the available MAKXD serial port. Pass
fallback_com_port="COM31" when a specific port is required. Use the
context manager to close the connection automatically:
from makxd import MouseButton, create_controller
with create_controller() as device:
device.move(100, 50)
device.click(MouseButton.LEFT)
The controller also supports asynchronous use:
import asyncio
from makxd import MouseButton, create_async_controller
async def main() -> None:
device = await create_async_controller()
await device.move(100, 50)
await device.click(MouseButton.LEFT)
await device.disconnect()
asyncio.run(main())
Mouse API
device.move(100, 50)
device.move_smooth(200, 100, segments=20)
device.move_bezier(150, 150, segments=30, ctrl_x=75, ctrl_y=200)
device.press(MouseButton.LEFT)
device.release(MouseButton.LEFT)
device.click_count(MouseButton.LEFT, count=2)
device.scroll(-5)
The controller also exposes movement, locking, button-state, device-info, firmware-version, serial, and command-stream helpers matching the MAKXD command surface.
Keyboard API
device.keyboard_down("a")
device.keyboard_up(4)
device.keyboard_press("space", hold_ms=25)
device.keyboard_string("hello")
device.keyboard_mask("a", True)
device.keyboard_remap("a", "b")
device.keyboard_multidown(["ctrl", "c"])
device.keyboard_multiup(["ctrl", "c"])
Keyboard names and numeric HID usages are accepted through KeyboardKey.
Binary input streaming
The public makxd.stream module encodes and decodes the shared binary input
stream for mouse, keyboard, and controller sources. The frame is deliberately
small:
DE AD + uint16 payload length (little-endian) + command byte + payload
Input-stream frames use command 0x01. Timing is preserved as the raw
16-bit word, including dt_uframes, baseline, and invalid flags.
from makxd import (
StreamFrameDecoder,
StreamRequest,
decode_stream_input_record,
)
request = StreamRequest.mouse().encode()
decoder = StreamFrameDecoder()
decoder.feed(incoming_bytes)
while frame := decoder.next():
record = decode_stream_input_record(frame)
if record is not None:
print(
record.kind,
record.sequence,
record.timing.dt_uframes,
)
Use StreamRequest.mouse(), keyboard(), controller(), or all() to
select sources. StreamRequest.stop() and status() control the stream.
The complete wire contract is in
protocol/MAKXD_PROTOCOL.md.
Command line
python -m makxd --debug
python -m makxd --testPort COM31
python -m makxd --runtest
The debug command opens the interactive command console. The port check tests
one explicit serial port, and --runtest runs the package test entry point.
Build and verify
From the python directory:
python -m pytest
python -m build
python -m twine check dist/*
License and attribution
This package is licensed under GPL-3.0-only. The Python API is maintained in
the mak-suite project; its command compatibility began from the open-source
SleepyTotem/makcu-py-lib API by
SleepyTotem.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file makxd-2.3.0.tar.gz.
File metadata
- Download URL: makxd-2.3.0.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ab589ab3e1459f8d049353a46ab402cd46096e55ec7a072c787054f93db7a2e
|
|
| MD5 |
9f8028537c63ed5afeedf64e6bfc8cc9
|
|
| BLAKE2b-256 |
7ac8ce65ef08741b3be3ed3deb9b2c115080e323af14d1494dc50ab142974e7e
|
File details
Details for the file makxd-2.3.0-py3-none-any.whl.
File metadata
- Download URL: makxd-2.3.0-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9792fe9f9002dde57973d3ab8d4f2f51b1965ad9949e7f93efe4a3bc05bd1ce
|
|
| MD5 |
f2d17e93092991660aa992fc6517b6ef
|
|
| BLAKE2b-256 |
c40cdd5e2ca66dbb4adee8758941a0c4f285c6ffcdb1c9259591c30c6caf5d56
|