Merge pull request #83 from TheElixZammuto/fix-stuck-keys

Fix Modifiers stuck on Host On Disconnection
This commit is contained in:
loki-47-6F-64 2021-05-08 13:53:35 +02:00 committed by GitHub
commit 7a93a72710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -402,6 +402,13 @@ void passthrough(std::shared_ptr<input_t> &input, std::vector<std::uint8_t> &&in
task_pool.push(passthrough_helper, input, util::cmove(input_data));
}
void reset(){
for(auto& kp : key_press){
platf::keyboard(platf_input, kp.first & 0x00FF, true);
key_press[kp.first] = false;
}
}
void init() {
platf_input = platf::input();
}

View File

@ -11,6 +11,7 @@ namespace input {
struct input_t;
void print(void *input);
void reset();
void passthrough(std::shared_ptr<input_t> &input, std::vector<std::uint8_t> &&input_data);
void init();

View File

@ -884,7 +884,6 @@ state_e state(session_t &session) {
void stop(session_t &session) {
while_starting_do_nothing(session.state);
auto expected = state_e::RUNNING;
auto already_stopping = !session.state.compare_exchange_strong(expected, state_e::STOPPING);
if(already_stopping) {
@ -901,6 +900,9 @@ void join(session_t &session) {
session.audioThread.join();
BOOST_LOG(debug) << "Waiting for control to end..."sv;
session.controlEnd.view();
//Reset input on session stop to avoid stuck repeated keys
BOOST_LOG(debug) << "Resetting Input..."sv;
input::reset();
BOOST_LOG(debug) << "Session ended"sv;
}