From f928edff467b9b493b95c511ffa443a71943e54f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 18 Mar 2022 16:43:24 +0100 Subject: uinput_mng: add the 'clear' control command --- README | 2 ++ uinput_mng | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README b/README index ad4a96b..8f6361f 100644 --- a/README +++ b/README @@ -51,6 +51,8 @@ The commands are: are disconnected. * list Lists all currently bound device paths. +* clear + Remove all currently bound devices. dev_add ------- diff --git a/uinput_mng b/uinput_mng index 9a31dc6..e000b15 100755 --- a/uinput_mng +++ b/uinput_mng @@ -53,6 +53,8 @@ class Controller: elif cmd == 'list': for d in self._in_devices: sys.stderr.write(d + '\n') + elif cmd == 'clear': + self._in_devices.clear() else: self._logger.error('Unknown command: %s', line) @@ -177,9 +179,11 @@ class PhysDevices(dict): def __exit__(self, exc_type, exc_value, traceback): self.close() - def close(self): + def clear(self): for path in list(self.keys()): self.remove(path) + def close(self): + self.clear() def add(self, path): if path in self: -- cgit v1.2.3