Bug 514241

Summary: pipe(|) char can not be input by jp keyboard, because the key between hat(^) and BS does not work.
Product: [Applications] krdc Reporter: H. Matsuura <h-pineinlet.kd1>
Component: RDPAssignee: Urs Wolfer <uwolfer>
Status: RESOLVED FIXED    
Severity: normal CC: ctrlaltca
Priority: NOR    
Version First Reported In: 25.12.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 25.12.2
Sentry Crash Report:

Description H. Matsuura 2026-01-06 19:30:41 UTC
SUMMARY

When jp keyboard is used, the key between hat(^) and BS is not work
The key is the only key that can input the pipe character.
(On jp keyboard, to input pipe(|) char, press the key with the Shift key.)


STEPS TO REPRODUCE

1.  Set keyboard layout to "Japanese (ja)" in KRDC Host Setting - General tab
2.  Connect to Windows 11 using RDP

OBSERVED RESULT

The key between hat(^) and BS does not work.
As a result, pipe characters (typed using the Shift key combination) cannot be input.
Of course, backslash char (which is assigned as the yen symbol in Japan) cannot be entered, but there is an alternative key to input the backslash between slash(/) and right shift.


EXPECTED RESULT
The signal from the key between hat(^) and BS is correctly sent to the host.

SOFTWARE/OS VERSIONS
KRDC: 25.12.0
KDE Frameworks: 6.21.0
Qt: 6.10.1
KDE neon User Edition (Wayland)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.14.0-37-generic
RDP Host : Windows 11 Pro


ADDITIONAL INFORMATION

The Japanese keyboard layout is described in detail on the English Wikipedia.
https://en.wikipedia.org/wiki/Keyboard_layout#Japanese

The keycode of the not working key between hat(^) and BS is 220 (0xDC) on Javascript "onkeydown" event.
The keycode of the working key between slash(/) and right shift is 226 (0xE2) on Javascript "onkeydown" event.

The key between hat(^) and BS does not work in Remmina 1.4.41 (git 3792a0bed) (on neon From Flathub).
The key between hat(^) and BS worked correctly in Remmina 1.4.39 (git n/a)  (on Kubuntu 25.04).
The key between hat(^) and BS does not work in KRDC 25.03.90  (on Kubuntu 25.04).
Comment 1 H. Matsuura 2026-01-12 17:42:28 UTC
When connecting with the following command in FreerRDP version 3.10.3, the key functioned correctly.
xfreerdp3 /v:192.168.2.65
(192.168.2.65 is the target Windows 11 Pro machine)

I noticed the code starting at line 140 in the following FreeRDP code for Japanese keyboards.
https://github.com/FreeRDP/FreeRDP/blob/master/libfreerdp/core/freerdp.c

I cloned KRDC from GitHub and tried modifying line 575 onwards in rdpsession.cpp as follows, but it didn't work.
    
    if (!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardLayout, preferences->rdpKeyboardLayout())) {
        return -1;
    }
    qCInfo(KRDC) << "Keyboard Layout:" << preferences->rdpKeyboardLayout();
    switch ((unsigned int) preferences->rdpKeyboardLayout()) {
    case KBD_JAPANESE:
    case KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002:
        qInfo() << "JAPANESE Keyboard";
        if(!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardType, WINPR_KBD_TYPE_JAPANESE)) {
            return -1;
        }
        if(!freerdp_settings_set_uint32(settings, FreeRDP_KeyboardSubType, 2)) {
            return -1;
        }
        break;
    default:
        break;    
    }

Please let me know if there's anything else I should check.
Comment 2 H. Matsuura 2026-01-12 20:27:31 UTC
In addition to the previous fix, modifying the start of the RdpSession::sendEvent function in the rdpsession.cpp file as follows enable the key to work.
(Other keys that previously didn't work, such as “Muhenkan” and “Henkan”, now function.)

However, I'm not sure that this approach—get the key type with freerdp_settings_get_uint32 every time this event occurs—is optimal.
If it seems acceptable, I'll clean up the code and submit a merge request.

bool RdpSession::sendEvent(QEvent *event, QWidget *source)
{
    auto input = m_context.rdp->input;
    auto settings = m_context.rdp->settings;
    auto keytype = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardType);
    switch (event->type()) {
    case QEvent::KeyPress:
    case QEvent::KeyRelease: {
        if (m_needKeyStateSync) {
            m_needKeyStateSync = false;
            syncKeyState();
        }
        auto keyEvent = static_cast<QKeyEvent *>(event);
        const DWORD vc = GetVirtualKeyCodeFromKeycode(keyEvent->nativeScanCode(), WINPR_KEYCODE_TYPE_XKB);
        //const DWORD code = GetVirtualScanCodeFromVirtualKeyCode(vc, WINPR_KBD_TYPE_IBM_ENHANCED);
        const DWORD code = GetVirtualScanCodeFromVirtualKeyCode(vc, keytype);
        freerdp_input_send_keyboard_event_ex(input, keyEvent->type() == QEvent::KeyPress, keyEvent->isAutoRepeat(), code);
        return true;
    }
    case QEvent::MouseButtonPress:

(the rest is omitted.)
Comment 3 Bug Janitor Service 2026-01-13 09:46:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/krdc/-/merge_requests/221
Comment 4 Fabio 2026-01-13 09:57:56 UTC
Thank you Mr. Matsuura for debugging this issue!
Otherway it would have been really hard for me, not owning a japanese keyboard.

Your patch has been submitted as MR https://invent.kde.org/network/krdc/-/merge_requests/221

Please note that it only includes the second patch from Comment 2 (https://bugs.kde.org/show_bug.cgi?id=514241#c2) , since the patch from Comment 1 (https://bugs.kde.org/show_bug.cgi?id=514241#c1) is already available upstream: https://github.com/FreeRDP/FreeRDP/blob/c120c768254e807db17145184568b9c4b96f0611/libfreerdp/core/freerdp.c#L140

From my tests it doesn't break anything on western layouts (I tested it_IT, en_US and fr_FR) and the additional call to freerdp_settings_get_uint32() causes no additional overhead.
Comment 5 H. Matsuura 2026-01-13 15:41:02 UTC
Thank you for submitting the merge request.
Also, as you mentioned, I've confirmed that it works correctly even without the patch in Comment 1, so I wanted to let you know.
Comment 6 Fabio 2026-01-13 15:53:52 UTC
Git commit 9cbf7050569570347928604f2887e270545b0f17 by Fabio Bas.
Committed on 13/01/2026 at 09:44.
Pushed by ctrlaltca into branch 'master'.

Rdp: set the correct keyboardType; fix local input of some chars on japanese keyboards.

M  +2    -1    rdp/rdpsession.cpp

https://invent.kde.org/network/krdc/-/commit/9cbf7050569570347928604f2887e270545b0f17
Comment 7 Fabio 2026-01-13 16:02:30 UTC
Thank you for the confirmation, I've merged the patch and backported to the stable branch so that it will be available on next version 25.12.2 (released on February 2)
Comment 8 Fabio 2026-01-13 16:12:16 UTC
Git commit d44f24e1f5114d307a16148878274d9e9456a80c by Fabio Bas.
Committed on 13/01/2026 at 15:54.
Pushed by ctrlaltca into branch 'release/25.12'.

Rdp: set the correct keyboardType; fix local input of some chars on japanese keyboards.


(cherry picked from commit 9cbf7050569570347928604f2887e270545b0f17)

Co-authored-by: Fabio Bas <ctrlaltca@gmail.com>

M  +2    -1    rdp/rdpsession.cpp

https://invent.kde.org/network/krdc/-/commit/d44f24e1f5114d307a16148878274d9e9456a80c