API
Ethernet UDP mouse API
Python helper for relative mouse move and clicks over UDP to our RP2350/RP2040/Teensy4.1 Ethernet firmware.
Overview
Communicate with our RP2350/RP2040/Teensy4.1 Ethernet firmware. Supports W5500, Adafruit Ethernet FeatherWing, and other similar Ethernet modules.
Install
- Download rpudp.py and example.py
- Flash / power your Ethernet board and note its IP address
- Firmware listens on port 7777 by default. Currently it cannot be changed.
Quick start
Point RPUDP at the board IP and port, then call open() before move/click.
from rpudp import RPUDP
dev = RPUDP('192.168.68.69', 7777)
if not dev.open():
raise SystemExit("Failed to open socket")
dev.move(50, -20)
dev.click(RPUDP.BTN_L)
dev.close()Methods
| Method | Returns | Description |
|---|---|---|
RPUDP(ip, port=7777) | RPUDP | Create a client for the board at ip:port. |
open() | bool | Create the UDP socket. Returns False if IP/port are invalid. |
close() | None | Close the socket. |
isConnected() | bool | True when a socket exists (does not prove the board is reachable). |
move(x, y) | None | Send relative mouse movement. |
setButtons(mask) | None | Set the held button mask (bitfield). Use RELEASE (0x00) to release. |
click(mask, down_ms=30) | None | Press buttons for down_ms milliseconds, then release. |
Button constants
Pass these masks to click() and setButtons().
RPUDP.RELEASE # 0x00 — release all
RPUDP.BTN_L # 0x01 — left
RPUDP.BTN_R # 0x02 — right
RPUDP.BTN_M # 0x04 — middle
RPUDP.BTN_X1 # 0x08 — side / back
RPUDP.BTN_X2 # 0x10 — side / forwardFull example
from rpudp import RPUDP
dev = RPUDP('192.168.68.69', 7777)
print(f'RP connected on port: {dev.port}') # always prints even if wrong IP. I need to add a handshake
# Relative mouse movement (x, y)
dev.move(50, -20)
# Button press
dev.click(RPUDP.BTN_L) # left click for 30 ms (default)
dev.click(RPUDP.BTN_R, down_ms=50) # right click for 50ms
# Hold a button down until you tell it to release
dev.setButtons(RPUDP.BTN_L) # hold left click
# do something
dev.setButtons(RPUDP.RELEASE) # release all
dev.close()