summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-04-20 21:08:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-04-20 21:08:29 +0300
commit89802865e9e56088c2ecde0d9c71fab46e0abbd8 (patch)
tree11feb00dfdbb5fdc9dba0ddd9d8ecf29e789169d /plugins
parentc9c30e7f8c91d1cf6f6ce7b2178a03ad4faa5d20 (diff)
fixes #2338 (ChangeKeyboardLayout: problem if system have Birman Typography Layout instead of default)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ChangeKeyboardLayout/src/hook_events.cpp8
-rw-r--r--plugins/ChangeKeyboardLayout/src/main.cpp7
-rw-r--r--plugins/ChangeKeyboardLayout/src/stdafx.h5
-rw-r--r--plugins/ChangeKeyboardLayout/src/text_operations.cpp20
4 files changed, 19 insertions, 21 deletions
diff --git a/plugins/ChangeKeyboardLayout/src/hook_events.cpp b/plugins/ChangeKeyboardLayout/src/hook_events.cpp
index b72f16046e..7acb1ce6ef 100644
--- a/plugins/ChangeKeyboardLayout/src/hook_events.cpp
+++ b/plugins/ChangeKeyboardLayout/src/hook_events.cpp
@@ -93,16 +93,12 @@ int OnIconsChanged(WPARAM, LPARAM)
int ModulesLoaded(WPARAM, LPARAM)
{
- LPCTSTR ptszEmptySting = L"";
-
// Заполняем конфигурационные строки из базы. Если их там нет - генерируем.
for (int i = 0; i < bLayNum; i++) {
wchar_t *ptszCurrLayout = GenerateLayoutString(hklLayouts[i]);
LPSTR ptszTemp = GetNameOfLayout(hklLayouts[i]);
- ptrW tszValue(g_plugin.getWStringA(ptszTemp));
- if (tszValue == 0)
- ptszLayStrings[i] = ptszCurrLayout;
- else if (!mir_wstrcmp(tszValue, ptszEmptySting))
+ ptrW tszValue(g_plugin.getWStringA(ptszTemp, ptszCurrLayout));
+ if (!mir_wstrlen(tszValue))
ptszLayStrings[i] = ptszCurrLayout;
else {
ptszLayStrings[i] = tszValue.detach();
diff --git a/plugins/ChangeKeyboardLayout/src/main.cpp b/plugins/ChangeKeyboardLayout/src/main.cpp
index fc27d27f9f..9e7a817e53 100644
--- a/plugins/ChangeKeyboardLayout/src/main.cpp
+++ b/plugins/ChangeKeyboardLayout/src/main.cpp
@@ -10,9 +10,6 @@ HHOOK kbHook_All;
MainOptions moOptions;
PopupOptions poOptions;
-LPCTSTR ptszKeybEng = L"`1234567890- = \\qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?";
-HKL hklEng = (HKL)0x04090409;
-
LPCTSTR ptszSeparators = L" \t\n\r";
HANDLE hOptionsInitialize;
@@ -50,6 +47,10 @@ int CMPlugin::Load()
if (bLayNum < 2)
return 1;
+ for (int i = 0; i < bLayNum; i++)
+ if ((UINT_PTR(hklLayouts[i]) & 0xFFFF) == 0x409)
+ hklEng = hklLayouts[i];
+
HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/ChangeKeyboardLayout/src/stdafx.h b/plugins/ChangeKeyboardLayout/src/stdafx.h
index 37a7317347..ee2cb8bdec 100644
--- a/plugins/ChangeKeyboardLayout/src/stdafx.h
+++ b/plugins/ChangeKeyboardLayout/src/stdafx.h
@@ -31,6 +31,8 @@
struct CMPlugin : public PLUGIN<CMPlugin>
{
+ HKL hklEng = (HKL)0x04090409;
+
CMPlugin();
int Load() override;
@@ -98,9 +100,6 @@ typedef struct
extern HICON hPopupIcon, hCopyIcon;
-extern LPCTSTR ptszKeybEng;
-extern HKL hklEng;
-
extern int bLayNum;
extern HKL hklLayouts[20];
extern wchar_t *ptszLayStrings[20];
diff --git a/plugins/ChangeKeyboardLayout/src/text_operations.cpp b/plugins/ChangeKeyboardLayout/src/text_operations.cpp
index 54c0db8f81..73bfd79160 100644
--- a/plugins/ChangeKeyboardLayout/src/text_operations.cpp
+++ b/plugins/ChangeKeyboardLayout/src/text_operations.cpp
@@ -45,6 +45,7 @@ wchar_t* GeTStringFromStreamData(EditStreamData *esd)
return ptszOutText;
}
+/////////////////////////////////////////////////////////////////////////////////////////
BOOL CopyTextToClipboard(wchar_t *ptszText)
{
@@ -88,27 +89,28 @@ HKL GetNextLayout(HKL hklCurLay)
return nullptr;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static wchar_t ptszKeybEng[] = L"`1234567890- = \\qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?";
+
wchar_t* GenerateLayoutString(HKL hklLayout)
{
- BYTE bState[256] = { 0 };
-
- wchar_t ptszTemp[3]; ptszTemp[0] = 0;
CMStringW res;
- size_t i;
- for (i = 0; i < mir_wstrlen(ptszKeybEng); i++) {
- SHORT shVirtualKey = VkKeyScanEx(ptszKeybEng[i], hklEng);
- UINT iScanCode = MapVirtualKeyEx(shVirtualKey & 0x00FF, 0, hklEng);
+ for (size_t i = 0; i < _countof(ptszKeybEng)-1; i++) {
+ SHORT shVirtualKey = VkKeyScanExW(ptszKeybEng[i], g_plugin.hklEng);
+ UINT iScanCode = MapVirtualKeyExW(shVirtualKey & 0x00FF, 0, g_plugin.hklEng);
- memset(bState, 0, sizeof(bState));
+ BYTE bState[256] = {};
if (shVirtualKey & 0x0100) bState[VK_SHIFT] = 0x80;
if (shVirtualKey & 0x0200) bState[VK_CONTROL] = 0x80;
if (shVirtualKey & 0x0400) bState[VK_MENU] = 0x80;
- shVirtualKey = MapVirtualKeyEx(iScanCode, 1, hklLayout);
+ shVirtualKey = MapVirtualKeyExW(iScanCode, 1, hklLayout);
bState[shVirtualKey & 0x00FF] = 0x80;
+ wchar_t ptszTemp[3]; ptszTemp[0] = 0;
int iRes = ToUnicodeEx(shVirtualKey, iScanCode, bState, ptszTemp, 3, 0, hklLayout);
// Защита от дэд-кеев
if (iRes < 0)