From: Peter Hutterer Date: Thu, 19 Dec 2024 01:48:49 +0000 (+1000) Subject: tools/libinput-replay: interrupt only the ongoing event sequence with ctrl+c X-Git-Tag: 1.27.1~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=193aacf61a8932d6ac872f7e42230e1b9ca68e91;p=platform%2Fupstream%2Flibinput.git tools/libinput-replay: interrupt only the ongoing event sequence with ctrl+c If libinput replay is currently replaying events, stop that sequence and go back to the start if the user presses Ctrl+C. Only on the second Ctrl+C do we fully exit. This helps debugging long recordings where we don't want to keep producing events after some initial event sequence. Closes #1064 Part-of: --- diff --git a/tools/libinput-replay.py b/tools/libinput-replay.py index 25a4a381..67ef28f8 100755 --- a/tools/libinput-replay.py +++ b/tools/libinput-replay.py @@ -277,21 +277,25 @@ def loop(args, recording): else: input("Hit enter to start replaying") - processes = [] - for d in devices: - p = multiprocessing.Process(target=wrap, args=(replay, d, args.verbose)) - processes.append(p) + try: + processes = [] + for d in devices: + p = multiprocessing.Process(target=wrap, args=(replay, d, args.verbose)) + processes.append(p) - for p in processes: - p.start() + for p in processes: + p.start() - for p in processes: - p.join() + for p in processes: + p.join() - del processes + del processes - if args.once: - break + if args.once: + break + except KeyboardInterrupt: + print("Event replay interrupted, press Ctrl+C again to exit.") + print("Note that the device may not be in a neutral state now.") def create_device_quirk(device):