Skip to main content

A Python library for controlling Arduino HID devices

Project description

Arduino HID Emulator

arduino-hid-emulator is a Python library designed to control HID devices (keyboard and mouse) emulated using Arduino. The library allows you to send commands to control mouse movements, key presses, and mouse button actions, as well as perform calibration for precise positioning.

Features

  • Mouse Control:

    • Direct movement by specified offset.
    • Smooth mouse movement using a Bézier curve.
    • Press, release, and click mouse buttons.
  • Keyboard Control:

    • Press and release keys.
    • Simulate key combinations (e.g., Ctrl + C).
  • Calibration:

    • Automatic calibration of mouse movement factors for precise positioning.
  • Flexibility:

    • Adjustable minimum and maximum duration for mouse movements.
    • Easy connection and control via serial port.

Installation

Ensure Python 3.x is installed on your system, then install the library using pip:

pip install arduino-hid-emulator

Requirements

  • Arduino with HID support (e.g., Arduino Pro Micro or Leonardo).
  • Upload the Arduino sketch (hid_emulator.ino) located in the arduino/hid_emulator directory.
  • Python libraries:
    • pyserial
    • pyautogui

Quick Start

  1. Connect Arduino: Upload the hid_emulator.ino sketch to your Arduino board and connect it to your computer via USB.

  2. Create a connection object:

    from arduino_hid_emulator.arduino import ArduinoConnection
    from arduino_hid_emulator.mouse import MouseController
    
    arduino = ArduinoConnection()
    mouse = MouseController(arduino)
    
  3. Usage example:

    # Move the mouse to a specified point
    mouse.move_direct(100, 100)
    
    # Smoothly move the mouse to a specified point
    mouse.mouse_move(500, 500, duration_min=1000, duration_max=2000)
    
    # Click the left mouse button
    mouse.click("left")
    
  4. Close the connection:

    arduino.close()
    

Calibration

For precise movement, it is recommended to perform calibration:

mouse.calibrate()

Calibration is performed automatically, adjusting mouse movement factors.

Project Structure

  • arduino_hid_emulator/ — source code of the library.
  • arduino/hid_emulator/ — sketch for uploading to Arduino.
  • examples/ — usage examples.

License

The project is distributed under the GPL-3.0 license. You are free to use, modify, and distribute the library under its terms.

Contributing

If you want to suggest improvements, report issues, or contribute, create a pull request or open an issue in the project repository.


Note: Make sure the Arduino sketch is uploaded and the device supports HID.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arduino_hid_emulator-0.4.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arduino_hid_emulator-0.4.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file arduino_hid_emulator-0.4.1.tar.gz.

File metadata

  • Download URL: arduino_hid_emulator-0.4.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for arduino_hid_emulator-0.4.1.tar.gz
Algorithm Hash digest
SHA256 756764f8a4dd6e19c4c3645ea89faf3a903756c7b9f34dc9a1cdd892ded01524
MD5 978b174a96526e7c558a626ec12b1ae3
BLAKE2b-256 fef92299ef620c42ba8838ec84e3ea692c6d051c4ac9ece938e87223a46631b7

See more details on using hashes here.

File details

Details for the file arduino_hid_emulator-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for arduino_hid_emulator-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e62389076d0529784b52bf1619f35e6a4a310f6aecf56bd120294895376cb85
MD5 05f1aafdcb93643fffafb7b13328d28f
BLAKE2b-256 ece72efb3f8d6dfc0386923ef7c65f4947002b2eb6f065b88d8cc93c5787cbd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page