From e078294f935567e8d22f13e386969979a1b170ee Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 1 Dec 2019 21:58:25 +1100 Subject: [PATCH] Add --exclusive flag --- input_over_ssh/client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/input_over_ssh/client.py b/input_over_ssh/client.py index 9be8587..33f70ad 100644 --- a/input_over_ssh/client.py +++ b/input_over_ssh/client.py @@ -21,10 +21,17 @@ import asyncio import evdev import json -async def forward_device(i, device): +async def do_forward_device(i, device): async for event in device.async_read_loop(): print(json.dumps([i, event.type, event.code, event.value])) +async def forward_device(i, device): + if args.exclusive: + with device.grab_context(): + await do_forward_device(i, device) + else: + await do_forward_device(i, device) + def encode_device(device): cap = device.capabilities() del cap[0] # Filter out EV_SYN, otherwise we get OSError 22 Invalid argument @@ -68,6 +75,7 @@ parser = argparse.ArgumentParser(description='input-over-ssh client') parser.add_argument('-L', '--list-devices', dest='action', action='store_const', const=list_devices, help='List available input devices') parser.add_argument('-p', '--device-by-path', action='append', default=[], help='Forward device with the given path') parser.add_argument('-n', '--device-by-name', action='append', default=[], help='Forward device with the given name') +parser.add_argument('-e', '--exclusive', action='store_true', help='Grab the device for exclusive input') args = parser.parse_args() if not args.action: