All Projects → adafruit → Adafruit_circuitpython_hid

adafruit / Adafruit_circuitpython_hid

Licence: mit
USB Human Interface Device drivers.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Adafruit circuitpython hid

Uhubctl
uhubctl - USB hub per-port power control
Stars: ✭ 1,036 (+1493.85%)
Mutual labels:  usb
Node Hid
Access USB & Bluetooth HID devices through Node.js
Stars: ✭ 1,064 (+1536.92%)
Mutual labels:  usb
Captionjs
An open-source jQuery plugin to easily and semantically add captions to images.
Stars: ✭ 60 (-7.69%)
Mutual labels:  accessibility
Wheelmap
♿️ Source code of classic wheelmap.org (deprecated)
Stars: ✭ 47 (-27.69%)
Mutual labels:  accessibility
Android Wechat Tool
a wechat tool for android
Stars: ✭ 51 (-21.54%)
Mutual labels:  accessibility
Hint.css
A CSS only tooltip library for your lovely websites.
Stars: ✭ 8,158 (+12450.77%)
Mutual labels:  accessibility
Website
Website and documentation for Radix.
Stars: ✭ 45 (-30.77%)
Mutual labels:  accessibility
Vue A11y Dialog
Vue.js component for a11y-dialog
Stars: ✭ 65 (+0%)
Mutual labels:  accessibility
Paragon
💎 Accessible components done right.
Stars: ✭ 52 (-20%)
Mutual labels:  accessibility
Apple Family
A simple framework that brings Apple devices together - like a family
Stars: ✭ 59 (-9.23%)
Mutual labels:  usb
Multibootusb
Create multiboot live Linux on a USB disk...
Stars: ✭ 1,042 (+1503.08%)
Mutual labels:  usb
Asciidoctor Html5s
Semantic HTML5 converter (backend) for Asciidoctor
Stars: ✭ 50 (-23.08%)
Mutual labels:  accessibility
Mathjax
Beautiful and accessible math in all browsers
Stars: ✭ 8,551 (+13055.38%)
Mutual labels:  accessibility
Usb4java Javax
javax.usb extension for usb4java
Stars: ✭ 47 (-27.69%)
Mutual labels:  usb
Nvda
NVDA, the free and open source Screen Reader for Microsoft Windows
Stars: ✭ 1,118 (+1620%)
Mutual labels:  accessibility
16soundsusb
16 Synchronized Inputs USB (UAC2) Sound Card Based on XMOS xCORE-200
Stars: ✭ 45 (-30.77%)
Mutual labels:  usb
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+1586.15%)
Mutual labels:  accessibility
Toboot
Bootloader for the EFM32HG Tomu Board
Stars: ✭ 65 (+0%)
Mutual labels:  usb
On Screen Keyboard
A jQuery plug-in which provides users with a fluid-width on-screen keyboard.
Stars: ✭ 63 (-3.08%)
Mutual labels:  accessibility
Van11y Accessible Tab Panel Aria
ES2015 accessible tabs panel system, using ARIA
Stars: ✭ 58 (-10.77%)
Mutual labels:  accessibility

Introduction

.. image:: https://readthedocs.org/projects/adafruit-circuitpython-hid/badge/?version=latest :target: https://circuitpython.readthedocs.io/projects/hid/en/latest/ :alt: Documentation Status

.. image :: https://img.shields.io/discord/327254708534116352.svg :target: https://adafru.it/discord :alt: Discord

.. image:: https://github.com/adafruit/Adafruit_CircuitPython_HID/workflows/Build%20CI/badge.svg :target: https://github.com/adafruit/Adafruit_CircuitPython_HID/actions/ :alt: Build Status

This driver simulates USB HID devices. Currently keyboard and mouse are implemented.

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://github.com/adafruit/Adafruit_CircuitPython_Bundle>_.

Usage Example

The Keyboard class sends keypress reports for a USB keyboard device to the host.

The Keycode class defines USB HID keycodes to send using Keyboard.

.. code-block:: python

import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

# Set up a keyboard device.
kbd = Keyboard(usb_hid.devices)

# Type lowercase 'a'. Presses the 'a' key and releases it.
kbd.send(Keycode.A)

# Type capital 'A'.
kbd.send(Keycode.SHIFT, Keycode.A)

# Type control-x.
kbd.send(Keycode.CONTROL, Keycode.X)

# You can also control press and release actions separately.
kbd.press(Keycode.CONTROL, Keycode.X)
kbd.release_all()

# Press and hold the shifted '1' key to get '!' (exclamation mark).
kbd.press(Keycode.SHIFT, Keycode.ONE)
# Release the ONE key and send another report.
kbd.release(Keycode.ONE)
# Press shifted '2' to get '@'.
kbd.press(Keycode.TWO)
# Release all keys.
kbd.release_all()

The KeyboardLayoutUS sends ASCII characters using keypresses. It assumes the host is set to accept keypresses from a US keyboard.

If the host is expecting a non-US keyboard, the character to key mapping provided by KeyboardLayoutUS will not always be correct. Different keypresses will be needed in some cases. For instance, to type an 'A' on a French keyboard (AZERTY instead of QWERTY), Keycode.Q should be pressed.

Currently this package provides only KeyboardLayoutUS. More KeyboardLayout classes could be added to handle non-US keyboards and the different input methods provided by various operating systems.

.. code-block:: python

import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS

kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(kbd)

# Type 'abc' followed by Enter (a newline).
layout.write('abc\n')

# Get the keycodes needed to type a '$'.
# The method will return (Keycode.SHIFT, Keycode.FOUR).
keycodes = layout.keycodes('$')

The Mouse class simulates a three-button mouse with a scroll wheel.

.. code-block:: python

import usb_hid
from adafruit_hid.mouse import Mouse

m = Mouse(usb_hid.devices)

# Click the left mouse button.
m.click(Mouse.LEFT_BUTTON)

# Move the mouse diagonally to the upper left.
m.move(-100, -100, 0)

# Roll the mouse wheel away from the user one unit.
# Amount scrolled depends on the host.
m.move(0, 0, -1)

# Keyword arguments may also be used. Omitted arguments default to 0.
m.move(x=-100, y=-100)
m.move(wheel=-1)

# Move the mouse while holding down the left button. (click-drag).
m.press(Mouse.LEFT_BUTTON)
m.move(x=50, y=20)
m.release_all()       # or m.release(Mouse.LEFT_BUTTON)

The ConsumerControl class emulates consumer control devices such as remote controls, or the multimedia keys on certain keyboards.

New in CircuitPython 3.0.

.. code-block:: python

import usb_hid
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode

cc = ConsumerControl(usb_hid.devices)

# Raise volume.
cc.send(ConsumerControlCode.VOLUME_INCREMENT)

# Pause or resume playback.
cc.send(ConsumerControlCode.PLAY_PAUSE)

The Gamepad class emulates a two-joystick gamepad with 16 buttons.

New in CircuitPython 3.0.

.. code-block:: python

import usb_hid
from adafruit_hid.gamepad import Gamepad

gp = Gamepad(usb_hid.devices)

# Click gamepad buttons.
gp.click_buttons(1, 7)

# Move joysticks.
gp.move_joysticks(x=2, y=0, z=-20)

Contributing

Contributions are welcome! Please read our Code of Conduct <https://github.com/adafruit/Adafruit_CircuitPython_hid/blob/master/CODE_OF_CONDUCT.md>_ before contributing to help this project stay welcoming.

Documentation

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>_.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].