Page MenuHome

Fix T93051: Some shortcuts dont work with french keyboard layout
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Feb 18 2022, 6:01 PM.

Details

Summary

This fixes T93051, T76405 and maybe others.

Characters like '²', '<' are not recognized in Blender's shortcut keys.

And sometimes simple buttons like . and / on the Windows
keyboard, although the symbol is "known", Blender also doesn't
detect for shortcuts.

For Windows, some of the symbols represented in the VK_OEM_[1-8] values,
depending on the language, are not mapped by Blender.
See https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes.

On Mac there is a fallback reading the "actual character value of the
'remappable' keys". Sometimes the character is not mapped either.

On Windows, the solution now mimics the Mac and tries to read the button's
character as a fallback.

For unmapped characters ('²', '<', '\''), now another value is chosen as a
substitute.

Ref T93051

Diff Detail

Repository
rB Blender

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Feb 18 2022, 6:01 PM
Germano Cavalcante (mano-wii) created this revision.
Brecht Van Lommel (brecht) added inline comments.
intern/ghost/intern/GHOST_SystemWin32.cpp
805–806

It was not obvious to me, but apparently VK_QUOTE == VK_OEM_7, so the actual functional change is checking the scan code.

This revision is now accepted and ready to land.Feb 21 2022, 5:06 PM
Germano Cavalcante (mano-wii) marked an inline comment as done.Feb 21 2022, 7:26 PM
Germano Cavalcante (mano-wii) added inline comments.
intern/ghost/intern/GHOST_SystemWin32.cpp
805–806

Oh yes, I forgot to explain that.

VK_QUOTE does not exist in windows API (WinUser.h) and also does not necessarily represent the symbol of "Quote".

As seen in https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes, the name given to the value 0xDE is VK_OEM_7 and can represent different symbols depending on the layout used.

Basically what this code does is: If the "virtual-key code" is VK_OEM_7 but the key position is the equivalent position of the {key } key on the US keyboard, then Blender will read it as the {key } otherwise it will read as ".

Maybe we could just check the scanCode for some keys and forget about the layout used. But as there are so many layouts I preferred a less drastic change.

Remembering that ` is not really the symbol that appears on the keyboard of these layouts, but for greater compatibility and ergonomy, it might be better to use this symbol and forget that ² and < could exist in events e keymaps.

Germano Cavalcante (mano-wii) planned changes to this revision.Feb 21 2022, 10:23 PM
Germano Cavalcante (mano-wii) marked an inline comment as done.

I found that the processSpecialKey function is a more convenient place to process these "exotic" cases.

  • Test keyboard language instead of the "input language" (The function must work with the keyboard language not the system language)
  • Fix by checking the layout used in processSpecialKey
  • LOWORD and HIWORD do simple bitwise operations, no need to store detailed m_keylayout values in the ghost system.
This revision is now accepted and ready to land.Feb 22 2022, 12:50 AM
Germano Cavalcante (mano-wii) planned changes to this revision.Feb 24 2022, 3:07 PM
  • Fix nonsense use of PRIMARYLANGID in keyboard handle

Use MapVirtualKeyA to detect character in different languages

This revision is now accepted and ready to land.Feb 24 2022, 8:13 PM