Skip to content

Commit

Permalink
Fix Control+Space not sent to program running in terminal (#16298)
Browse files Browse the repository at this point in the history
Converts null byte to specific input event, so that it's properly
delivered to the program running in the terminal.

Closes #15939

(cherry picked from commit 8747a39)
Service-Card-Id: 91201444
Service-Version: 1.19
  • Loading branch information
lonnywong authored and DHowett committed Dec 4, 2023
1 parent 3538a9f commit a4ec8ec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/host/inputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,17 @@ void InputBuffer::_HandleTerminalInputCallback(const TerminalInput::StringType&

for (const auto& wch : text)
{
if (wch == UNICODE_NULL)
{
// Convert null byte back to input event with proper control state
const auto zeroKey = OneCoreSafeVkKeyScanW(0);
uint32_t ctrlState = 0;
WI_SetFlagIf(ctrlState, SHIFT_PRESSED, WI_IsFlagSet(zeroKey, 0x100));
WI_SetFlagIf(ctrlState, LEFT_CTRL_PRESSED, WI_IsFlagSet(zeroKey, 0x200));
WI_SetFlagIf(ctrlState, LEFT_ALT_PRESSED, WI_IsFlagSet(zeroKey, 0x400));
_storage.push_back(SynthesizeKeyEvent(true, 1, LOBYTE(zeroKey), 0, wch, ctrlState));
continue;
}
_storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0));
}

Expand Down

0 comments on commit a4ec8ec

Please sign in to comment.