From b520da26d46269c5af0c8c001f107d4ccd3fb2cb Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 24 Sep 2024 20:56:30 +0200 Subject: [PATCH] Check EnableHexNumpad before enabling it (#17954) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This just adds a quick registry check for `EnableHexNumpad`. Depends on #17774 Closes #17762 (again) ## Validation Steps Performed * Alt + NumpadAdd + 221E doesn't do anything ✅ * Set the `EnableHexNumpad` registry key * Restart * Alt + NumpadAdd + 221E inserts ∞ ✅ --- src/cascadia/TerminalControl/TermControl.cpp | 29 ++++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 565ea02ccf6..e2d8256ce1f 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1631,12 +1631,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation { if (vkey == VK_ADD) { - // Alt '+' is used to input Unicode code points. - // Every time you press + it resets the entire state - // in the original OS implementation as well. - s.encoding = AltNumpadEncoding::Unicode; - s.accumulator = 0; - s.active = true; + static const auto enabled = []() { + wchar_t buffer[4]{}; + DWORD size = sizeof(buffer); + RegGetValueW( + HKEY_CURRENT_USER, + L"Control Panel\\Input Method", + L"EnableHexNumpad", + RRF_RT_REG_SZ, + nullptr, + &buffer[0], + &size); + return size == 4 && memcmp(&buffer[0], L"1", 4) == 0; + }(); + + if (enabled) + { + // Alt '+' is used to input Unicode code points. + // Every time you press + it resets the entire state + // in the original OS implementation as well. + s.encoding = AltNumpadEncoding::Unicode; + s.accumulator = 0; + s.active = true; + } } else if (vkey == VK_NUMPAD0 && s.encoding == AltNumpadEncoding::OEM && s.accumulator == 0) {