thewh1teagle / zero-hid

Raspberry pi virtual HID mouse and keyboard
GNU Lesser General Public License v3.0
69 stars 16 forks source link
hid mouse python raspberry-pi usb

HID python library for emulating mouse and keyboard on PI.

Setup

  1. Install apt dependencies
sudo apt-get update
sudo apt-get install -y git python3-pip
  1. install usb gadget module
  2. Install zero-hid with pip
    pip3 install zero-hid

Usage

Note: You should connect the data usb port (left one) to the raspberry, and NOT the power port

k = Keyboard() k.type('Hello world!')


## Features
- Relative / Absolute mouse movements
- Left / Right / Middle click
- Scrolling
- Typing
- Hot keys
- Drag and Drop
- Easy to setup
- Comprehensive Testing

## Examples
see [examples](examples)

## Tests
| Raspberry Pi Model | Raspbian Version | Kernel Version |
|---------------------|-------------------|----------------|
| Raspberry Pi 4      | Raspbian 12       | 6.1            |
| Raspberry Pi Zero   | Raspbian 5.10     | -              |

## Gotaches

Error when installing with pip
```shell
error: externally-managed-environment

See how-solve-error-externally-managed-environment-when-installing-pip3

Or simply create virtual environment

sudo apt-get update
sudo apt install -y python3-venv
python3 -m venv ~/venv
source ~/venv/bin/activate
pip3 install zero-hid