-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The scancode returned in KEY_EVENT_RECORD don't match over ssh #5342
Comments
I think I've found the relevant code: https://github.com/microsoft/terminal/blob/master/src/types/convert.cpp#L210 const auto vk = LOBYTE(keyState);
const WORD virtualScanCode = gsl::narrow<WORD>(MapVirtualKeyW(vk, MAPVK_VK_TO_VSC));
KeyEvent keyEvent{ true, 1, LOBYTE(keyState), virtualScanCode, wch, 0 }; Confusingly, that seems correct to me. If I write a test program that does the same Is it possible that code works, but it hasn't reached a release yet? I can't see how what the code does currently in 1909 could possibly match that code 😄 I wrote a debugger script to patch the events to do |
Great find, and thanks for the report! Yeah, we just took some changes to the PTY’s key generator; once I’m at my desk tomorrow I can confirm which Windows release it’s in or would be in (if it’s not in one yet!) |
Alternatively, this could be in InputStateMachineEngine; I’m not sure if it’s using |
Disregard: I just saw the comment about the live patch. 😄 |
You know, the blame for the line you pointed out takes me back to the fix for #2873, #3199. I apparently gave it the very classic and enlightening description, "It was wrong. It is now not wrong.". Judging by the symptom, it looks like these are the same issue. It's fixed in the insider slow train (19041.x right now), and should be out when the 20H1 build of Windows is RTM. In the mean time, if you're feeling adventurous you can replace I should warn you, though, that this comes with no disclaimer or warranty and we have some open issues in PR that fix PTY bugs we introduced in the past, like, week. 😄 Thanks! /dup #2873 |
Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! |
Thanks Dustin, I did build OpenConsole.exe and replaced conhost.exe on my 1909 build. I literally just cloned it, I'm at 37e62da The behaviour does seem better, scancodes match now! It broke some other things, and the console app I was trying to run looks garbled now. It did look correct in the 1909 conhost, it was just input that wasn't working. Oh well, I'll see if I can figure out what changed. |
Ahh, that might explain it, I'll watch the bug and try it again when a fix lands. I also get some extra INPUT_EVENTS from ReadConsoleInput() if I use ssh from within WSL. Regular keys work like 'a', 'b', etc. If I press backspace, I get the expected 0x08 (with correct scan code, yay!), then a 0x7f with LEFT_CTRL. The application doesn't handle that. That feels terminal related (like synthetic escape sequences...?) (Note: I didn't get any extra events with 1909 conhost.exe, just the wrong scancodes) |
Environment
Steps to reproduce
I'm trying to use the console application hiew, it works perfectly in console but behaves differently over ssh, some keys are recognized incorrectly. I wrote a quick test program to dump keyboard events from
ReadConsoleInput()
and found that the only difference is that thewVirtualScanCode
is different.Example pressing the 'a' key locally in cmd:
Over ssh I get this:
I've verified that if I attach to the program in windbg, and patch up the scan code in the
KEY_EVENT_RECORD
structures afterReadConsoleInput()
returns, the program works perfectly.Expected behavior
I think the
wVirtualScanCode
should match locally and over ssh.Actual behavior
The
wVirtualScanCode
are wildly different, and applications that examine them become confused.If there is a setting somewhere that configured this, I wasn't able to find it, I really tried!
The text was updated successfully, but these errors were encountered: