Changeset View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| # define VK_SEMICOLON 0xBA | # define VK_SEMICOLON 0xBA | ||||
| #endif // VK_SEMICOLON | #endif // VK_SEMICOLON | ||||
| #ifndef VK_PERIOD | #ifndef VK_PERIOD | ||||
| # define VK_PERIOD 0xBE | # define VK_PERIOD 0xBE | ||||
| #endif // VK_PERIOD | #endif // VK_PERIOD | ||||
| #ifndef VK_COMMA | #ifndef VK_COMMA | ||||
| # define VK_COMMA 0xBC | # define VK_COMMA 0xBC | ||||
| #endif // VK_COMMA | #endif // VK_COMMA | ||||
| #ifndef VK_QUOTE | |||||
| # define VK_QUOTE 0xDE | |||||
| #endif // VK_QUOTE | |||||
| #ifndef VK_BACK_QUOTE | #ifndef VK_BACK_QUOTE | ||||
| # define VK_BACK_QUOTE 0xC0 | # define VK_BACK_QUOTE 0xC0 | ||||
| #endif // VK_BACK_QUOTE | #endif // VK_BACK_QUOTE | ||||
| #ifndef VK_SLASH | #ifndef VK_SLASH | ||||
| # define VK_SLASH 0xBF | # define VK_SLASH 0xBF | ||||
| #endif // VK_SLASH | #endif // VK_SLASH | ||||
| #ifndef VK_BACK_SLASH | #ifndef VK_BACK_SLASH | ||||
| # define VK_BACK_SLASH 0xDC | # define VK_BACK_SLASH 0xDC | ||||
| ▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Lines | |||||
| * \note this function can be extended to include other exotic cases as they arise. | * \note this function can be extended to include other exotic cases as they arise. | ||||
| * | * | ||||
| * This function was added in response to bug T25715. | * This function was added in response to bug T25715. | ||||
| * This is going to be a long list T42426. | * This is going to be a long list T42426. | ||||
| */ | */ | ||||
| GHOST_TKey GHOST_SystemWin32::processSpecialKey(short vKey, short scanCode) const | GHOST_TKey GHOST_SystemWin32::processSpecialKey(short vKey, short scanCode) const | ||||
| { | { | ||||
| GHOST_TKey key = GHOST_kKeyUnknown; | GHOST_TKey key = GHOST_kKeyUnknown; | ||||
| switch (PRIMARYLANGID(m_langId)) { | char ch = (char)MapVirtualKeyA(vKey, MAPVK_VK_TO_CHAR); | ||||
| case LANG_FRENCH: | switch (ch) { | ||||
| if (vKey == VK_OEM_8) | case u'\"': | ||||
| key = GHOST_kKeyF13; // oem key; used purely for shortcuts . | case u'\'': | ||||
| key = GHOST_kKeyQuote; | |||||
| break; | |||||
| case u'/': | |||||
| key = GHOST_kKeySlash; | |||||
| break; | break; | ||||
| case LANG_ENGLISH: | case u'`': | ||||
| if (SUBLANGID(m_langId) == SUBLANG_ENGLISH_UK && vKey == VK_OEM_8) // "`¬" | case u'²': | ||||
| key = GHOST_kKeyAccentGrave; | key = GHOST_kKeyAccentGrave; | ||||
| break; | break; | ||||
| default: | |||||
| if (vKey == VK_OEM_7) { | |||||
| key = GHOST_kKeyQuote; | |||||
| } | |||||
| else if (vKey == VK_OEM_8) { | |||||
| if (PRIMARYLANGID(m_langId) == LANG_FRENCH) { | |||||
| /* oem key; used purely for shortcuts. */ | |||||
| key = GHOST_kKeyF13; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| return key; | return key; | ||||
| } | } | ||||
| GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short extend) const | GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short extend) const | ||||
| { | { | ||||
| GHOST_TKey key; | GHOST_TKey key; | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | switch (vKey) { | ||||
| case VK_OPEN_BRACKET: | case VK_OPEN_BRACKET: | ||||
| key = GHOST_kKeyLeftBracket; | key = GHOST_kKeyLeftBracket; | ||||
| break; | break; | ||||
| case VK_BACK_SLASH: | case VK_BACK_SLASH: | ||||
| key = GHOST_kKeyBackslash; | key = GHOST_kKeyBackslash; | ||||
| break; | break; | ||||
| case VK_CLOSE_BRACKET: | case VK_CLOSE_BRACKET: | ||||
| key = GHOST_kKeyRightBracket; | key = GHOST_kKeyRightBracket; | ||||
| break; | break; | ||||
| case VK_QUOTE: | |||||
| key = GHOST_kKeyQuote; | |||||
| break; | |||||
| case VK_GR_LESS: | case VK_GR_LESS: | ||||
brecht: It was not obvious to me, but apparently `VK_QUOTE == VK_OEM_7`, so the actual functional… | |||||
Done Inline ActionsOh 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. mano-wii: Oh yes, I forgot to explain that.
`VK_QUOTE` does not exist in windows API (`WinUser.h`) and… | |||||
| key = GHOST_kKeyGrLess; | key = GHOST_kKeyGrLess; | ||||
| break; | break; | ||||
| case VK_SHIFT: | case VK_SHIFT: | ||||
| /* Check single shift presses */ | /* Check single shift presses */ | ||||
| if (scanCode == 0x36) { | if (scanCode == 0x36) { | ||||
| key = GHOST_kKeyRightShift; | key = GHOST_kKeyRightShift; | ||||
| } | } | ||||
| Show All 24 Lines | switch (vKey) { | ||||
| key = GHOST_kKeyNumLock; | key = GHOST_kKeyNumLock; | ||||
| break; | break; | ||||
| case VK_SCROLL: | case VK_SCROLL: | ||||
| key = GHOST_kKeyScrollLock; | key = GHOST_kKeyScrollLock; | ||||
| break; | break; | ||||
| case VK_CAPITAL: | case VK_CAPITAL: | ||||
| key = GHOST_kKeyCapsLock; | key = GHOST_kKeyCapsLock; | ||||
| break; | break; | ||||
| case VK_OEM_8: | |||||
| key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode); | |||||
| break; | |||||
| case VK_MEDIA_PLAY_PAUSE: | case VK_MEDIA_PLAY_PAUSE: | ||||
| key = GHOST_kKeyMediaPlay; | key = GHOST_kKeyMediaPlay; | ||||
| break; | break; | ||||
| case VK_MEDIA_STOP: | case VK_MEDIA_STOP: | ||||
| key = GHOST_kKeyMediaStop; | key = GHOST_kKeyMediaStop; | ||||
| break; | break; | ||||
| case VK_MEDIA_PREV_TRACK: | case VK_MEDIA_PREV_TRACK: | ||||
| key = GHOST_kKeyMediaFirst; | key = GHOST_kKeyMediaFirst; | ||||
| break; | break; | ||||
| case VK_MEDIA_NEXT_TRACK: | case VK_MEDIA_NEXT_TRACK: | ||||
| key = GHOST_kKeyMediaLast; | key = GHOST_kKeyMediaLast; | ||||
| break; | break; | ||||
| case VK_OEM_7: | |||||
| case VK_OEM_8: | |||||
| default: | default: | ||||
| key = GHOST_kKeyUnknown; | key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return key; | return key; | ||||
| } | } | ||||
| GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, | GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, | ||||
| ▲ Show 20 Lines • Show All 1,394 Lines • Show Last 20 Lines | |||||
It was not obvious to me, but apparently VK_QUOTE == VK_OEM_7, so the actual functional change is checking the scan code.