From 6f428eb316310501dcd5f5e08500a2b10b968eef Mon Sep 17 00:00:00 2001 From: loki Date: Sun, 9 May 2021 11:56:53 +0200 Subject: [PATCH] Ensure no input remains in the task_pool before resetting --- sunshine/input.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sunshine/input.cpp b/sunshine/input.cpp index 402d4ce3..9a41dd03 100644 --- a/sunshine/input.cpp +++ b/sunshine/input.cpp @@ -402,11 +402,18 @@ void passthrough(std::shared_ptr &input, std::vector &&in task_pool.push(passthrough_helper, input, util::cmove(input_data)); } -void reset(){ - for(auto& kp : key_press){ +void reset() { + if(task_id) { + task_pool.cancel(task_id); + } + + // Ensure input is synchronous + task_pool.push([]() { + for(auto& kp : key_press) { platf::keyboard(platf_input, kp.first & 0x00FF, true); key_press[kp.first] = false; } + }); } void init() {