Fork 0

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
1 changed files with 9 additions and 1 deletions

View File

@ -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)
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: