diff options
author | PMR <pmr@pmr-lander> | 2021-04-21 16:20:06 +0000 |
---|---|---|
committer | PMR <pmr@pmr-lander> | 2021-04-21 16:20:06 +0000 |
commit | 23a0216417fbc902ac5b60b0643d0d3be3fa7fea (patch) | |
tree | 89fa631712a50645d5856d272b93ed09dc7bc069 /bin | |
parent | eee7195696b25316e86a4b6d91542bc48abc2538 (diff) | |
parent | 6b43c1b2041ad546ef2416d056def0dd4f36024d (diff) |
Merge #401277 from ~kchsieh/plainbox-provider-checkbox/+git/plainbox-provider-checkbox:i2c
Fix: Retrieve device on i2c bus only
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/touchpad_confidence_bit.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/bin/touchpad_confidence_bit.py b/bin/touchpad_confidence_bit.py new file mode 100755 index 0000000..5f94bb9 --- /dev/null +++ b/bin/touchpad_confidence_bit.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import sys +from subprocess import check_output, CalledProcessError +from checkbox_support.parsers.udevadm import UdevadmParser + + +class TouchpadDevices: + + def __init__(self): + self.devices = {} + self._collect_devices() + + def _collect_devices(self): + cmd = ['udevadm', 'info', '--export-db'] + try: + output = check_output(cmd).decode(sys.stdout.encoding) + except CalledProcessError as err: + sys.stderr.write(err) + return + udev = UdevadmParser(output) + udev.run(self) + + def addDevice(self, device): + if getattr(device, 'category') == 'TOUCHPAD': + self.devices[getattr(device, 'product_slug') + ] = getattr(device, 'path') + + +def main(): + if len(sys.argv) != 2: + raise SystemExit('ERROR: expected a product slug') + product_slug = sys.argv[1] + + path = TouchpadDevices().devices[product_slug] + abs_path = "/sys" + path + "/capabilities/abs" + + f = open(abs_path, "r") + abs_cap_str = f.readline() + f.close() + support = (int(abs_cap_str[-15], 16) & 8) >> 3 + + if support == 0: + modalias_path = "/sys" + path + "/modalias" + f = open(modalias_path, "r") + modalias_str = f.readline() + f.close() + print("Touchpad modalias: {}".format(modalias_str[0:-2])) + print("Touchpad EV_ABS capabilities: {}".format(abs_cap_str[0:-2])) + sys.exit(1) + + return 0 + + +if __name__ == "__main__": + main() |