Skip to main content

HID-IO layouts Python API

This is the Python API for the HID-IO layouts repository. By default, the API will download the latest version of the layouts git repository to use that as a cache.

The purpose of this API is to acquire and merge the JSON HID layouts. With some additional helpers to deal with string composition.

layouts is also available on PyPi.

pip install layouts

GitHub Action Status PyPI version

Visit our IRC channel

Usage

Some basic usage examples.

List Layouts

GitHub Cache

import layouts

mgr = layouts.Layouts()
print(mgr.list_layouts()

Local Cache

import layouts

layout_dir = "/tmp/mylayouts/layouts"
mgr = layouts.Layouts(layout_path=layout_dir)
print(mgr.list_layouts()

Retrieve Layout

import layouts

mgr = layouts.Layouts()
layout = mgr.get_layout('default')

print(layout.name()) # Name of merged layout
print(layout.json()) # Fully merged JSON dict
print(layout.locale()) # Tuple (<USB HID locale code>, <name>)

Composition Example

import layouts

mgr = layouts.Layouts()
layout = mgr.get_layout('default')

input_str = "Hello World!"
print(layout.compose(input_str))

# Only use code clears when necessary (blank USB packet)
print(layout.compose(input_str, minimal_clears=True))

Codes for C-Style Defines

import layouts
import layouts.emitter

mgr = layouts.Layouts()
layout = mgr.get_layout('default')

# Returns a list of list of tuples
# Each type of code has a pre-defined (configurable) prefix
# [<keyboard codes>, <led codes>, <system control codes>, <consumer codes>]
# (<name>, <code>)
# Useful for:
# #define KEY_A 0x04
print(layouts.emitter.basic_c_defines(layout))

Metadata

Release files for layouts 0.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for layouts 0.4.10
File Size Uploaded Provenance Actions
layouts-0.4.10.tar.gz 11.8 kB Without provenance Details for layouts-0.4.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for layouts 0.4.10
File Interpreter ABI Platform Actions
layouts-0.4.10-py3-none-any.whl Python 3 none any Details for layouts-0.4.10-py3-none-any.whl

Total release size: 21.4 kB

Release files / layouts-0.4.10.tar.gz

Download URL layouts-0.4.10.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c20488550b887c5685480fa52cd9bd91305d73d36808307a23ef6607ade344b5
BLAKE2b-256 checksum
How to use checksums
2f9c09e0bf37684be29bafa710f2abcca6b7891bbaca0d836e7cc8f3a7f8a077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Release files / layouts-0.4.10-py3-none-any.whl

Download URL layouts-0.4.10-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78f44c43ed43bb80b45c311c603aa4aa554545d0215c29a74a56bbc86c11e74e
BLAKE2b-256 checksum
How to use checksums
2e5c75218896bef96ec432e157fa10bd6f32326e2bbfaff5916d07c9eabc6634
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Security for layouts 0.4.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page