Introduction
============
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-usb-host-mouse/badge/?version=latest
:target: https://docs.circuitpython.org/projects/usb_host_mouse/en/latest/
:alt: Documentation Status
.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
:target: https://adafru.it/discord
:alt: Discord
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/workflows/Build%20CI/badge.svg
:target: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/actions
:alt: Build Status
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Code Style: Ruff
Helper class that encapsulates the objects needed for user code to interact with a USB mouse, draw a visible cursor, and determine when buttons are pressed.
Dependencies
=============
This driver depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_
or individual libraries can be installed using
`circup <https://github.com/adafruit/circup>`_.
`USB Wired Mouse - Two Buttons plus Wheel <https://www.adafruit.com/product/2025>`_
Installing from PyPI
=====================
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-usb-host-mouse/>`_.
To install for current user:
.. code-block:: shell
pip3 install adafruit-circuitpython-usb-host-mouse
To install system-wide (this may be required in some cases):
.. code-block:: shell
sudo pip3 install adafruit-circuitpython-usb-host-mouse
To install in a virtual environment in your current project:
.. code-block:: shell
mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install adafruit-circuitpython-usb-host-mouse
Installing to a Connected CircuitPython Device with Circup
==========================================================
Make sure that you have ``circup`` installed in your Python environment.
Install it with the following command if necessary:
.. code-block:: shell
pip3 install circup
With ``circup`` installed and your CircuitPython device connected use the
following command to install:
.. code-block:: shell
circup install adafruit_usb_host_mouse
Or the following command to update an existing version:
.. code-block:: shell
circup update
Usage Example
=============
.. code-block:: python
import supervisor
import terminalio
from adafruit_display_text.bitmap_label import Label
from displayio import Group
from adafruit_usb_host_mouse import find_and_init_boot_mouse
display = supervisor.runtime.display
# group to hold visual elements
main_group = Group()
# make the group visible on the display
display.root_group = main_group
mouse = find_and_init_boot_mouse()
if mouse is None:
raise RuntimeError("No mouse found connected to USB Host")
# text label to show the x, y coordinates on the screen
output_lbl = Label(terminalio.FONT, text=f"{mouse.x},{mouse.y}", color=0xFFFFFF, scale=1)
# move it to the upper left corner
output_lbl.anchor_point = (0, 0)
output_lbl.anchored_position = (1, 1)
# add it to the main group
main_group.append(output_lbl)
# add the mouse tile grid to the main group
main_group.append(mouse.tilegrid)
# main loop
while True:
# update mouse
pressed_btns = mouse.update()
# string with updated coordinates for the text label
out_str = f"{mouse.x},{mouse.y}"
# add pressed buttons to out str
if pressed_btns is not None and len(pressed_btns) > 0:
out_str += f" {" ".join(pressed_btns)}"
# update the text label with the new coordinates
# and buttons being pressed
output_lbl.text = out_str
Documentation
=============
API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/usb_host_mouse/en/latest/>`_.
For information on building library documentation, please check out
`this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
Contributing
============
Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/blob/HEAD/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.
Raw data
{
"_id": null,
"home_page": null,
"name": "adafruit-circuitpython-usb-host-mouse",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "adafruit, blinka, circuitpython, micropython, usb_host_mouse, usb, mouse, mice, usbhost, usbmouse, usbmice, host, cursor",
"author": null,
"author_email": "Adafruit Industries <circuitpython@adafruit.com>",
"download_url": "https://files.pythonhosted.org/packages/93/a4/fb31be490347a3a4c5fc77449bcec7865090ac0ab4565cc4b9a22fbef051/adafruit_circuitpython_usb_host_mouse-1.5.1.tar.gz",
"platform": null,
"description": "Introduction\n============\n\n\n.. image:: https://readthedocs.org/projects/adafruit-circuitpython-usb-host-mouse/badge/?version=latest\n :target: https://docs.circuitpython.org/projects/usb_host_mouse/en/latest/\n :alt: Documentation Status\n\n\n.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg\n :target: https://adafru.it/discord\n :alt: Discord\n\n\n.. image:: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/workflows/Build%20CI/badge.svg\n :target: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/actions\n :alt: Build Status\n\n\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n :target: https://github.com/astral-sh/ruff\n :alt: Code Style: Ruff\n\nHelper class that encapsulates the objects needed for user code to interact with a USB mouse, draw a visible cursor, and determine when buttons are pressed.\n\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_\nor individual libraries can be installed using\n`circup <https://github.com/adafruit/circup>`_.\n\n\n`USB Wired Mouse - Two Buttons plus Wheel <https://www.adafruit.com/product/2025>`_\n\nInstalling from PyPI\n=====================\n\nOn supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from\nPyPI <https://pypi.org/project/adafruit-circuitpython-usb-host-mouse/>`_.\nTo install for current user:\n\n.. code-block:: shell\n\n pip3 install adafruit-circuitpython-usb-host-mouse\n\nTo install system-wide (this may be required in some cases):\n\n.. code-block:: shell\n\n sudo pip3 install adafruit-circuitpython-usb-host-mouse\n\nTo install in a virtual environment in your current project:\n\n.. code-block:: shell\n\n mkdir project-name && cd project-name\n python3 -m venv .venv\n source .env/bin/activate\n pip3 install adafruit-circuitpython-usb-host-mouse\n\nInstalling to a Connected CircuitPython Device with Circup\n==========================================================\n\nMake sure that you have ``circup`` installed in your Python environment.\nInstall it with the following command if necessary:\n\n.. code-block:: shell\n\n pip3 install circup\n\nWith ``circup`` installed and your CircuitPython device connected use the\nfollowing command to install:\n\n.. code-block:: shell\n\n circup install adafruit_usb_host_mouse\n\nOr the following command to update an existing version:\n\n.. code-block:: shell\n\n circup update\n\nUsage Example\n=============\n\n.. code-block:: python\n\n import supervisor\n import terminalio\n from adafruit_display_text.bitmap_label import Label\n from displayio import Group\n\n from adafruit_usb_host_mouse import find_and_init_boot_mouse\n\n display = supervisor.runtime.display\n\n # group to hold visual elements\n main_group = Group()\n\n # make the group visible on the display\n display.root_group = main_group\n\n mouse = find_and_init_boot_mouse()\n if mouse is None:\n raise RuntimeError(\"No mouse found connected to USB Host\")\n\n # text label to show the x, y coordinates on the screen\n output_lbl = Label(terminalio.FONT, text=f\"{mouse.x},{mouse.y}\", color=0xFFFFFF, scale=1)\n\n # move it to the upper left corner\n output_lbl.anchor_point = (0, 0)\n output_lbl.anchored_position = (1, 1)\n\n # add it to the main group\n main_group.append(output_lbl)\n\n # add the mouse tile grid to the main group\n main_group.append(mouse.tilegrid)\n\n # main loop\n while True:\n # update mouse\n pressed_btns = mouse.update()\n\n # string with updated coordinates for the text label\n out_str = f\"{mouse.x},{mouse.y}\"\n\n # add pressed buttons to out str\n if pressed_btns is not None and len(pressed_btns) > 0:\n out_str += f\" {\" \".join(pressed_btns)}\"\n\n # update the text label with the new coordinates\n # and buttons being pressed\n output_lbl.text = out_str\n\n\nDocumentation\n=============\nAPI documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/usb_host_mouse/en/latest/>`_.\n\nFor information on building library documentation, please check out\n`this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n<https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse/blob/HEAD/CODE_OF_CONDUCT.md>`_\nbefore contributing to help this project stay welcoming.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Helper class that encapsulates the objects needed for user code to interact with a USB mouse, draw a visible cursor, and determine when buttons are pressed.",
"version": "1.5.1",
"project_urls": {
"Homepage": "https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Mouse"
},
"split_keywords": [
"adafruit",
" blinka",
" circuitpython",
" micropython",
" usb_host_mouse",
" usb",
" mouse",
" mice",
" usbhost",
" usbmouse",
" usbmice",
" host",
" cursor"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "16c4d02de4ae0e7579e2dbcc0827b1e98ac17a5b0ec7bfd1aa69ba8f37e5794d",
"md5": "993245bbfe10504a03daf91a7919430e",
"sha256": "a2c044c87b6e157c1159812ebb8613d36fbffa6d6baa32afe5c92c87e4c6cc69"
},
"downloads": -1,
"filename": "adafruit_circuitpython_usb_host_mouse-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "993245bbfe10504a03daf91a7919430e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8016,
"upload_time": "2025-10-20T20:45:24",
"upload_time_iso_8601": "2025-10-20T20:45:24.831638Z",
"url": "https://files.pythonhosted.org/packages/16/c4/d02de4ae0e7579e2dbcc0827b1e98ac17a5b0ec7bfd1aa69ba8f37e5794d/adafruit_circuitpython_usb_host_mouse-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "93a4fb31be490347a3a4c5fc77449bcec7865090ac0ab4565cc4b9a22fbef051",
"md5": "4ba281115e13854ae3b6f3d73933cf3f",
"sha256": "48ad8aa76ebb6135cbfd41d65d608a113ef9fec85dc23a53c3685cd707594be4"
},
"downloads": -1,
"filename": "adafruit_circuitpython_usb_host_mouse-1.5.1.tar.gz",
"has_sig": false,
"md5_digest": "4ba281115e13854ae3b6f3d73933cf3f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 26176,
"upload_time": "2025-10-20T20:45:26",
"upload_time_iso_8601": "2025-10-20T20:45:26.525569Z",
"url": "https://files.pythonhosted.org/packages/93/a4/fb31be490347a3a4c5fc77449bcec7865090ac0ab4565cc4b9a22fbef051/adafruit_circuitpython_usb_host_mouse-1.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-20 20:45:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adafruit",
"github_project": "Adafruit_CircuitPython_USB_Host_Mouse",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "Adafruit-Blinka",
"specs": []
},
{
"name": "adafruit-circuitpython-usb-host-descriptors",
"specs": []
}
],
"lcname": "adafruit-circuitpython-usb-host-mouse"
}