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
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())
print(layout.json())
print(layout.locale())
Composition Example
import layouts
mgr = layouts.Layouts()
layout = mgr.get_layout('default')
input_str = "Hello World!"
print(layout.compose(input_str))
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')
print(layouts.emitter.basic_c_defines(layout))