From 06ae55b224a33e8a00eeefe5149aef2a88f3213f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 12 Feb 2020 22:07:03 +0100 Subject: Add a script for producing a device description in JSON. --- inputdev_describe | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 inputdev_describe diff --git a/inputdev_describe b/inputdev_describe new file mode 100755 index 0000000..ed43920 --- /dev/null +++ b/inputdev_describe @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import argparse +import contextlib +import evdev +import json +import sys + +parser = argparse.ArgumentParser() + +parser.add_argument('device') + +args = parser.parse_args(sys.argv[1:]) + +with contextlib.closing(evdev.InputDevice(args.device)) as device: + out = {} + + out['linux-evdev-device-desc'] = 0 + + out['name'] = device.name + + info = {} + info['bustype'] = device.info.bustype + info['vendor'] = device.info.vendor + info['product'] = device.info.product + info['version'] = device.info.version + out['info'] = info + + out['capabilities'] = device.capabilities() + + # TODO: LEDs + + json.dump(out, sys.stdout, indent = 4) -- cgit v1.2.3