Add --exclusive flag

This commit is contained in:
RunasSudo 2019-12-01 21:58:25 +11:00
parent 63ed05387e
commit e078294f93
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -21,10 +21,17 @@ import asyncio
import evdev import evdev
import json import json
async def forward_device(i, device): async def do_forward_device(i, device):
async for event in device.async_read_loop(): async for event in device.async_read_loop():
print(json.dumps([i, event.type, event.code, event.value])) 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): def encode_device(device):
cap = device.capabilities() cap = device.capabilities()
del cap[0] # Filter out EV_SYN, otherwise we get OSError 22 Invalid argument 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('-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('-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('-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() args = parser.parse_args()
if not args.action: if not args.action: