Skip to main content

Python API for HID-IO HID Layouts Repository

Project description

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

Travis Status

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))

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
layouts-0.4.7-py3-none-any.whl (22.5 kB) Copy SHA256 hash SHA256 Wheel py3
layouts-0.4.7.tar.gz (10.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page