From e0ee3669435655be8c1cd4235187a978b670a86b Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 8 Jun 2012 17:15:51 +0300 Subject: [PATCH 1/2] Virtual keyboard improvement --- .../images/virtual.keyboard/29/capslock.png | Bin 245 -> 227 bytes .../images/virtual.keyboard/29/shift.png | Bin 0 -> 245 bytes .../images/virtual.keyboard/41/capslock.png | Bin 261 -> 233 bytes .../images/virtual.keyboard/41/shift.png | Bin 0 -> 261 bytes resources/sankore.qrc | 2 + src/frameworks/UBPlatformUtils.cpp | 3 +- src/frameworks/UBPlatformUtils.h | 102 +++- src/frameworks/UBPlatformUtils_linux.cpp | 488 +++++++++------- src/frameworks/UBPlatformUtils_mac.mm | 18 +- src/frameworks/UBPlatformUtils_win.cpp | 525 +++++++++--------- src/gui/UBKeyboardPalette.cpp | 121 +++- src/gui/UBKeyboardPalette.h | 33 +- src/gui/UBKeyboardPalette_linux.cpp | 180 ++++-- src/gui/UBKeyboardPalette_mac.cpp | 36 +- src/gui/UBKeyboardPalette_win.cpp | 19 +- 15 files changed, 918 insertions(+), 609 deletions(-) create mode 100644 resources/images/virtual.keyboard/29/shift.png create mode 100644 resources/images/virtual.keyboard/41/shift.png diff --git a/resources/images/virtual.keyboard/29/capslock.png b/resources/images/virtual.keyboard/29/capslock.png index 8390e560849bab4ab3a2b0f2ef935047e9c96da7..61c1a4be4b45fafc35d9fb1513bfee9a241bc443 100644 GIT binary patch delta 197 zcmV;$06PEm0pkH7iBL{Q4GJ0x0000DNk~Le0000E0000D2nGNE0GZrhe~}?5e}zdz zK~#9!lu`i-03irVx%c(hKIpZ$!LF3!ghA%!OtOe*S(q6MmT|lijWHT9BWC_BqzFf# z6k`km=_H2U0k}g=`Cd4!{6Wi{y%OnA?5$!asrP<7myK8x&TGxfm2cf0We3NGUxW=u zLzj(~qaF^r)xS{*O~y-IuYC&r8zI#haSJd28P{^f1m}tb00000NkvXXu0mjfr_W4v delta 215 zcmV;|04V?C0rdePiBL{Q4GJ0x0000DNk~Le0000C0000D2nGNE0G%n1LXjaTf0s!_ zK~#9!gp$n-fG`L~OXCntbR|8S&fv+d{5iTH77K<}Q4*2@?*l>#ag0vevMmk(kVB~J zfQV%x!vlv$szU*gK%Bzly(;$^QOpPYDl*|})mvo3YH}fRA%uxVSnsQ*U*5Idd`Z*k z{( zJaZG%Q-e|yQz{EjrrH1%P4{$h45_%)GU+UDg8_$|_hSLy5>?w-=N_C~`^R#Zf*5yO zSfJ1(ruWQFT!lS;w>RnXF-&k?@w%ZSRp~HuyZb6<#t9B{4n5hc^<6UX4ErA~qlZ~n zqf-uL6)6@ewsg8iykEU6{@&KRHJ+DWJ`wWBw_0j(*!;2P&Uf0onZH^6B#ZJj>kI0G-I->FVdQ&MBb@0F&}wB>(^b literal 0 HcmV?d00001 diff --git a/resources/images/virtual.keyboard/41/capslock.png b/resources/images/virtual.keyboard/41/capslock.png index 10b279d5e98dff287477e25f36e304f9edd5366c..4e1fd582fe729583ddce67a1b7cbc7b1ff4ab4bf 100644 GIT binary patch delta 203 zcmV;+05t!F0_g!EiBL{Q4GJ0x0000DNk~Le0000I0000G2nGNE02>A`T#+Fte~U>( zK~#9!tdfBWz#s@jRr>#5b_*=rt?ULn2vYQErnWlRjiSaF2C*XpxjBE5@rNM z;J${( zJaZG%Q-e|yQz{EjrrH1%E%$VB45_%4)Wgx8;J|)5TrWK#CFKu)ic!+!^dJBK+q1E8 zc6W4aaaywRMDpbWhYts{B{{tOUty}4-N2Y5^)bugI>%=|KVFZv#2XybrcawRuSLHg zfngP&&IGp9Kkj8ryW%GnNO4b?!Ftrdv+cwOkDRzimages/virtual.keyboard/41/right-active.png images/virtual.keyboard/41/backspace.png images/virtual.keyboard/41/capslock.png + images/virtual.keyboard/41/shift.png images/virtual.keyboard/41/tab.png images/virtual.keyboard/29/centre-passive.png images/virtual.keyboard/29/left-passive.png @@ -308,6 +309,7 @@ images/virtual.keyboard/29/right-active.png images/virtual.keyboard/29/backspace.png images/virtual.keyboard/29/capslock.png + images/virtual.keyboard/29/shift.png images/virtual.keyboard/29/tab.png images/toolPalette/cacheTool.png images/libpalette/FlashCategory.svg diff --git a/src/frameworks/UBPlatformUtils.cpp b/src/frameworks/UBPlatformUtils.cpp index 18994890..dae09db6 100644 --- a/src/frameworks/UBPlatformUtils.cpp +++ b/src/frameworks/UBPlatformUtils.cpp @@ -57,4 +57,5 @@ UBKeyboardLocale** UBPlatformUtils::getKeyboardLayouts(int& nCount) { nCount = nKeyboardLayouts; return keyboardLayouts; -} \ No newline at end of file +} + diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h index a4d6d886..6380c850 100644 --- a/src/frameworks/UBPlatformUtils.h +++ b/src/frameworks/UBPlatformUtils.h @@ -23,30 +23,82 @@ class QMainWindow; #define SYMBOL_KEYS_COUNT 47 +struct KEYCODE{ + KEYCODE() + :symbol(0) + ,code(0) + ,modifier(0) + {} + + KEYCODE(int _symbol) + :symbol(_symbol) + ,code(0) + ,modifier(0) + {} + + KEYCODE(int _symbol, + unsigned char _code, + int _modifier) + :symbol(_symbol) + ,code(_code) + ,modifier(_modifier) + {} + + + bool empty() const + { + return symbol == 0; + } + + int symbol; + unsigned char code; + int modifier; +}; + + struct KEYBT { - const QChar symbol1; - const int code1; - const QChar symbol2; - const int code2; - - KEYBT(unsigned int _symbol1, - unsigned int _symbol2): - symbol1(_symbol1), - code1(_symbol1), - symbol2(_symbol2), - code2(_symbol2){} - - - KEYBT(QChar _symbol1, - int _code1, - QChar _symbol2, - int _code2): - symbol1(_symbol1), - code1(_code1), - symbol2(_symbol2), - code2(_code2){} - }; + QChar symbol1; + QChar symbol2; + bool capsLockSwitch; + int modifier1; + int modifier2; + KEYCODE codes[8]; + + KEYBT( QChar _symbol1, + QChar _symbol2, + bool _capsLockSwitch, + int _modifier1, + int _modifier2, + KEYCODE c1 = 0, + KEYCODE c2 = 0, + KEYCODE c3 = 0, + KEYCODE c4 = 0, + KEYCODE c5 = 0, + KEYCODE c6 = 0, + KEYCODE c7 = 0, + KEYCODE c8 = 0) + :symbol1(_symbol1) + ,symbol2(_symbol2) + ,capsLockSwitch(_capsLockSwitch) + ,modifier1(_modifier1) + ,modifier2(_modifier2) + { + codes[0] = c1; + codes[1] = c2; + codes[2] = c3; + codes[3] = c4; + codes[4] = c5; + codes[5] = c6; + codes[6] = c7; + codes[7] = c8; + } + + ~KEYBT() + {} +}; + + class UBKeyboardLocale { @@ -63,7 +115,7 @@ struct KEYBT const QString& _name, const QString& _id, QIcon* _icon, - const KEYBT _symbols[]) + KEYBT _symbols[]) :fullName(_fullName),name(_name), id(_id), icon(_icon), constSymbols(_symbols), varSymbols(NULL) {} @@ -74,12 +126,12 @@ struct KEYBT const QString name; const QString id; QIcon* icon; - const KEYBT* operator[] (int index) const + KEYBT* operator[] (int index) const { return (varSymbols==NULL)? constSymbols + index : varSymbols[index]; } private: - const KEYBT* constSymbols; + KEYBT* constSymbols; KEYBT** varSymbols; }; diff --git a/src/frameworks/UBPlatformUtils_linux.cpp b/src/frameworks/UBPlatformUtils_linux.cpp index 174e3694..68709a6a 100644 --- a/src/frameworks/UBPlatformUtils_linux.cpp +++ b/src/frameworks/UBPlatformUtils_linux.cpp @@ -104,229 +104,295 @@ void UBPlatformUtils::setDesktopMode(bool desktop) Q_UNUSED(desktop); } -const KEYBT ENGLISH_LOCALE[] = { - /* ` ~ */ KEYBT(0x60, 0x7e), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 @ */ KEYBT(0x32, 0x40), - /* 3 # */ KEYBT(0x33, 0x23), - /* 4 $ */ KEYBT(0x34, 0x24), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 ^ */ KEYBT(0x36, 0x88), - /* 7 & */ KEYBT(0x37, 0x26), - /* 8 * */ KEYBT(0x38, 0x2a), - /* 9 ( */ KEYBT(0x39, 0x28), - /* 0 ) */ KEYBT(0x30, 0x29), - /* - _ */ KEYBT(0x2d, 0x5f), - /* = + */ KEYBT(0x3d, 0x2b), - - /* q Q */ KEYBT(0x71, 0x51), - /* w W */ KEYBT(0x77, 0x57), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* y Y */ KEYBT(0x79, 0x59), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* [ { */ KEYBT(0x5b, 0x7b), - /* ] } */ KEYBT(0x5d, 0x7d), - - /* a A */ KEYBT(0x61, 0x41), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* ; : */ KEYBT(0x3b, 0x3a), - /* ' " */ KEYBT(0x27, 0x22), - /* \ | */ KEYBT(0x5c, 0x7c), - - /* z Z */ KEYBT(0x7a, 0x5a), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* m M */ KEYBT(0x6d, 0x4d), - /* , < */ KEYBT(0x2c, 0x3c), - /* . > */ KEYBT(0x2e, 0x3e), - /* / ? */ KEYBT(0x2f, 0x5f)}; - -const KEYBT RUSSIAN_LOCALE [] = +#define KEYBTDECL(s1, s2, clSwitch, code) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(s1, code, 0), KEYCODE(s2, code, 1)) + +#define KEYBTDECLEX1(s1, s2, clSwitch, code, cs1, cs2) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1)) +#define KEYBTDECLEX2(s1, s2, clSwitch, code, cs1, cs2) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 2), KEYCODE(cs2, code, 3)) + +#define KEYBTDECLEX6(s1, s2, clSwitch, code, cs1, cs2, cs3, cs4, cs5, cs6) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1), KEYCODE(cs3, code, 2), KEYCODE(cs4, code, 3), KEYCODE(cs5, code, 4), KEYCODE(cs6, code, 5)) + +#define KEYBTDECLEX8(s1, s2, clSwitch, code, cs1, cs2, cs3, cs4, cs5, cs6, cs7, cs8) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1), KEYCODE(cs3, code, 2), KEYCODE(cs4, code, 3), KEYCODE(cs5, code, 4), KEYCODE(cs6, code, 5), KEYCODE(cs7, code, 6), KEYCODE(cs8, code, 7)) + + +KEYBT ENGLISH_LOCALE[] = { + /* ` ~ */ KEYBTDECL(0x60, 0x7e, false, 41), + /* 1 ! */ KEYBTDECL(0x31, 0x21, false, 2), + /* 2 @ */ KEYBTDECL(0x32, 0x40, false, 3), + /* 3 # */ KEYBTDECL(0x33, 0x23, false, 4), + /* 4 $ */ KEYBTDECL(0x34, 0x24, false, 5), + /* 5 % */ KEYBTDECL(0x35, 0x25, false, 6), + /* 6 ^ */ KEYBTDECL(0x36, 0x88, false, 7), + /* 7 & */ KEYBTDECL(0x37, 0x26, false, 8), + /* 8 * */ KEYBTDECL(0x38, 0x2a, false, 9), + /* 9 ( */ KEYBTDECL(0x39, 0x28, false, 10), + /* 0 ) */ KEYBTDECL(0x30, 0x29, false, 11), + /* - _ */ KEYBTDECL(0x2d, 0x5f, false, 12), + /* = + */ KEYBTDECL(0x3d, 0x2b, false, 13), + + /* q Q */ KEYBTDECL(0x71, 0x51, true, 16), + /* w W */ KEYBTDECL(0x77, 0x57, true, 17), + /* e E */ KEYBTDECL(0x65, 0x45, true, 18), + /* r R */ KEYBTDECL(0x72, 0x52, true, 19), + /* t T */ KEYBTDECL(0x74, 0x54, true, 20), + /* y Y */ KEYBTDECL(0x79, 0x59, true, 21), + /* u U */ KEYBTDECL(0x75, 0x55, true, 22), + /* i I */ KEYBTDECL(0x69, 0x49, true, 23), + /* o O */ KEYBTDECL(0x6f, 0x4f, true, 24), + /* p P */ KEYBTDECL(0x70, 0x50, true, 25), + /* [ { */ KEYBTDECL(0x5b, 0x7b, false, 26), + /* ] } */ KEYBTDECL(0x5d, 0x7d, false, 27), + + /* a A */ KEYBTDECL(0x61, 0x41, true, 30), + /* s S */ KEYBTDECL(0x73, 0x53, true, 31), + /* d D */ KEYBTDECL(0x64, 0x44, true, 32), + /* f F */ KEYBTDECL(0x66, 0x46, true, 33), + /* g G */ KEYBTDECL(0x67, 0x47, true, 34), + /* h H */ KEYBTDECL(0x68, 0x48, true, 35), + /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36), + /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37), + /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38), + /* ; : */ KEYBTDECL(0x3b, 0x3a, false, 39), + /* ' " */ KEYBTDECL(0x27, 0x22, false, 40), + /* \ | */ KEYBTDECL(0x5c, 0x7c, false, 43), + + /* z Z */ KEYBTDECL(0x7a, 0x5a, true, 44), + /* x X */ KEYBTDECL(0x78, 0x58, true, 45), + /* c C */ KEYBTDECL(0x63, 0x43, true, 46), + /* v V */ KEYBTDECL(0x76, 0x56, true, 47), + /* b B */ KEYBTDECL(0x62, 0x42, true, 48), + /* n N */ KEYBTDECL(0x6e, 0x4e, true, 49), + /* m M */ KEYBTDECL(0x6d, 0x4d, true, 50), + /* , < */ KEYBTDECL(0x2c, 0x3c, false, 51), + /* . > */ KEYBTDECL(0x2e, 0x3e, false, 52), + /* / ? */ KEYBTDECL(0x2f, 0x5f, false, 53)}; + +KEYBT RUSSIAN_LOCALE [] = { - /* ё Ё */ KEYBT(0x451, XK_Cyrillic_io, 0x401, XK_Cyrillic_IO), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 " */ KEYBT(0x32, 0x5c), - /* 3 № */ KEYBT(0x33, 0x33, 0x2116, XK_numerosign), - /* 4 ; */ KEYBT(0x34, 0x3b), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 : */ KEYBT(0x36, 0x3a), - /* 7 ? */ KEYBT(0x37, 0x3f), - /* 8 * */ KEYBT(0x38, 0x2a), - /* 9 ( */ KEYBT(0x39, 0x28), - /* 0 ) */ KEYBT(0x30, 0x29), - /* - _ */ KEYBT(0x2d, 0x4f), - /* = + */ KEYBT(0x3d, 0x2b), - - /* й Й */ KEYBT(0x439, XK_Cyrillic_shorti, 0x419, XK_Cyrillic_SHORTI), - /* ц Ц */ KEYBT(0x446, XK_Cyrillic_tse, 0x426, XK_Cyrillic_TSE), - /* у У */ KEYBT(0x443, XK_Cyrillic_u, 0x423, XK_Cyrillic_U), - /* к К */ KEYBT(0x43a, XK_Cyrillic_ka, 0x41a, XK_Cyrillic_KA), - /* е Е */ KEYBT(0x435, XK_Cyrillic_ie, 0x415, XK_Cyrillic_IE), - /* н Н */ KEYBT(0x43d, XK_Cyrillic_en, 0x41d, XK_Cyrillic_EN), - /* г Г */ KEYBT(0x433, XK_Cyrillic_ghe, 0x413, XK_Cyrillic_GHE), - /* ш Ш */ KEYBT(0x448, XK_Cyrillic_sha, 0x428, XK_Cyrillic_SHA), - /* щ Щ */ KEYBT(0x449, XK_Cyrillic_shcha, 0x429, XK_Cyrillic_SHCHA), - /* з З */ KEYBT(0x437, XK_Cyrillic_ze, 0x417, XK_Cyrillic_ZE), - /* х Х */ KEYBT(0x445, XK_Cyrillic_ha, 0x425, XK_Cyrillic_HA), - /* ъ Ъ */ KEYBT(0x44a, XK_Cyrillic_hardsign, 0x42a, XK_Cyrillic_HARDSIGN), - - /* ф Ф */ KEYBT(0x444, XK_Cyrillic_ef, 0x424, XK_Cyrillic_EF), - /* ы Ы */ KEYBT(0x44b, XK_Cyrillic_yeru, 0x42b, XK_Cyrillic_YERU), - /* в В */ KEYBT(0x432, XK_Cyrillic_ve, 0x412, XK_Cyrillic_VE), - /* а А */ KEYBT(0x430, XK_Cyrillic_a, 0x410, XK_Cyrillic_A), - /* п П */ KEYBT(0x43f, XK_Cyrillic_pe, 0x41f, XK_Cyrillic_PE), - /* р Р */ KEYBT(0x440, XK_Cyrillic_er, 0x420, XK_Cyrillic_ER), - /* о О */ KEYBT(0x43e, XK_Cyrillic_o, 0x41e, XK_Cyrillic_O), - /* л Л */ KEYBT(0x43b, XK_Cyrillic_el, 0x41b, XK_Cyrillic_EL), - /* д Д */ KEYBT(0x434, XK_Cyrillic_de, 0x414, XK_Cyrillic_DE), - /* ж Ж */ KEYBT(0x436, XK_Cyrillic_zhe, 0x416, XK_Cyrillic_ZHE), - /* э Э */ KEYBT(0x44d, XK_Cyrillic_e, 0x42d, XK_Cyrillic_E), - /* \ / */ KEYBT(0x5c, 0x2f), - - /* я Я */ KEYBT(0x44f, XK_Cyrillic_ya, 0x42f, XK_Cyrillic_YA), - /* ч Ч */ KEYBT(0x447, XK_Cyrillic_che, 0x427, XK_Cyrillic_CHE), - /* с С */ KEYBT(0x441, XK_Cyrillic_es, 0x421, XK_Cyrillic_ES), - /* м М */ KEYBT(0x43c, XK_Cyrillic_em, 0x41c, XK_Cyrillic_EM), - /* и И */ KEYBT(0x438, XK_Cyrillic_i, 0x418, XK_Cyrillic_I), - /* т Т */ KEYBT(0x442, XK_Cyrillic_te, 0x422, XK_Cyrillic_TE), - /* ь Ь */ KEYBT(0x44c, XK_Cyrillic_softsign, 0x42c, XK_Cyrillic_SOFTSIGN), - /* б Б */ KEYBT(0x431, XK_Cyrillic_be, 0x411, XK_Cyrillic_BE), - /* ю Ю */ KEYBT(0x44e, XK_Cyrillic_yu, 0x42e, XK_Cyrillic_YU), - /* . , */ KEYBT(0x2e, 0x2c)}; - -const KEYBT FRENCH_LOCALE[] = { - /* ? ? */ KEYBT(0xb2, XK_twosuperior, 0xb2, XK_twosuperior), - /* & 1 */ KEYBT(0x26, 0x31), - /* ? 2 */ KEYBT(0xe9, 0x32), - /* " 3 */ KEYBT(0x22, 0x33), - /* ' 4 */ KEYBT(0x27, 0x34), - /* ( 5 */ KEYBT(0x28, 0x35), - /* - 6 */ KEYBT(0x2d, 0x36), - /* ? 7 */ KEYBT(0xe8, XK_egrave, 0x37, 0x37), - /* _ 8 */ KEYBT(0x5f, 0x38), - /* ? 9 */ KEYBT(0xe7, XK_ccedilla, 0x39, 0x39), - /* ? 0 */ KEYBT(0xe0, 0x29), - /* ) ? */ KEYBT(0x29, 0xb0), - /* = + */ KEYBT(0x3d, 0x2b), - - /* a A */ KEYBT(0x61, 0x41), - /* z Z */ KEYBT(0x7a, 0x5a), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* y Y */ KEYBT(0x79, 0x59), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* ^ ? */ KEYBT(0x5e, 0xa8), - /* $ ? } */ KEYBT(0x24, 0xa3), - - /* q Q */ KEYBT(0x71, 0x51), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* m M */ KEYBT(0x6d, 0x4d), - /* ? % */ KEYBT(0xf9, 0x25), - /* * ? */ KEYBT(0x2a, 0xb5), - - /* w W */ KEYBT(0x77, 0x57), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* , ? */ KEYBT(0x2c, 0x3f), - /* ; . */ KEYBT(0x3b, 0x2e), - /* : / */ KEYBT(0x3a, 0x2f), - /* ! ? */ KEYBT(0x21, 0xa7)}; - -const KEYBT GERMAN_LOCALE[] = { - /* ^ ? */ KEYBT(0x5f, 0xb0), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 " */ KEYBT(0x32, 0x22), - /* 3 */ KEYBT(0x33, 0xa7), - /* 4 $ */ KEYBT(0x34, 0x24), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 & */ KEYBT(0x36, 0x26), - /* 7 / */ KEYBT(0x37, 0x2f), - /* 8 ( */ KEYBT(0x38, 0x28), - /* 9 ) */ KEYBT(0x39, 0x29), - /* 0 = */ KEYBT(0x30, 0x3d), - /* ? ? */ KEYBT(0xdf, 0x3f), - /* ` ? */ KEYBT(0x60, 0xb4), - - /* q Q */ KEYBT(0x71, 0x51), - /* w W */ KEYBT(0x77, 0x57), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* z Z */ KEYBT(0x7a, 0x5a), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* ? ? */ KEYBT(0xfc, 0xdc), - /* + * */ KEYBT(0x2b, 0x2a), - - /* a A */ KEYBT(0x61, 0x41), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* ? ? */ KEYBT(0xf6, 0xd6), - /* ? ? */ KEYBT(0xe4, 0xc4), - /* ' # */ KEYBT(0x27, 0x23), - - /* y Y */ KEYBT(0x79, 0x59), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* m M */ KEYBT(0x6d, 0x4d), - /* , ; */ KEYBT(0x2c, 0x3b), - /* . : */ KEYBT(0x2e, 0x3a), - /* _ - */ KEYBT(0x5f, 0x2d)}; + /* ё Ё */ KEYBTDECLEX2(0x451, 0x401, true, 41, XK_Cyrillic_io, XK_Cyrillic_IO), + /* 1 ! */ KEYBTDECL(0x31, 0x21, false, 2), + /* 2 " */ KEYBTDECL(0x32, 0x5c, false, 3), + /* 3 № */ KEYBTDECLEX1(0x33, 0x2116, false, 4, 0x33, XK_numerosign), + /* 4 ; */ KEYBTDECL(0x34, 0x3b, false, 5), + /* 5 % */ KEYBTDECL(0x35, 0x25, false, 6), + /* 6 : */ KEYBTDECL(0x36, 0x3a, false, 7), + /* 7 ? */ KEYBTDECL(0x37, 0x3f, false, 8), + /* 8 * */ KEYBTDECL(0x38, 0x2a, false, 9), + /* 9 ( */ KEYBTDECL(0x39, 0x28, false, 10), + /* 0 ) */ KEYBTDECL(0x30, 0x29, false, 11), + /* - _ */ KEYBTDECL(0x2d, 0x4f, false, 12), + /* = + */ KEYBTDECL(0x3d, 0x2b, false, 13), + + /* й Й */ KEYBTDECLEX2(0x439, 0x419, true, 16, XK_Cyrillic_shorti, XK_Cyrillic_SHORTI), + /* ц Ц */ KEYBTDECLEX2(0x446, 0x426, true, 17, XK_Cyrillic_tse, XK_Cyrillic_TSE), + /* у У */ KEYBTDECLEX2(0x443, 0x423, true, 18, XK_Cyrillic_u, XK_Cyrillic_U), + /* к К */ KEYBTDECLEX2(0x43a, 0x41a, true, 19, XK_Cyrillic_ka, XK_Cyrillic_KA), + /* е Е */ KEYBTDECLEX2(0x435, 0x415, true, 20, XK_Cyrillic_ie, XK_Cyrillic_IE), + /* н Н */ KEYBTDECLEX2(0x43d, 0x41d, true, 21, XK_Cyrillic_en, XK_Cyrillic_EN), + /* г Г */ KEYBTDECLEX2(0x433, 0x413, true, 22, XK_Cyrillic_ghe, XK_Cyrillic_GHE), + /* ш Ш */ KEYBTDECLEX2(0x448, 0x428, true, 23, XK_Cyrillic_sha, XK_Cyrillic_SHA), + /* щ Щ */ KEYBTDECLEX2(0x449, 0x429, true, 24, XK_Cyrillic_shcha, XK_Cyrillic_SHCHA), + /* з З */ KEYBTDECLEX2(0x437, 0x417, true, 25, XK_Cyrillic_ze, XK_Cyrillic_ZE), + /* х Х */ KEYBTDECLEX2(0x445, 0x425, true, 26, XK_Cyrillic_ha, XK_Cyrillic_HA), + /* ъ Ъ */ KEYBTDECLEX2(0x44a, 0x42a, true, 27, XK_Cyrillic_hardsign, XK_Cyrillic_HARDSIGN), + + /* ф Ф */ KEYBTDECLEX2(0x444, 0x424, true, 30, XK_Cyrillic_ef, XK_Cyrillic_EF), + /* ы Ы */ KEYBTDECLEX2(0x44b, 0x42b, true, 31, XK_Cyrillic_yeru, XK_Cyrillic_YERU), + /* в В */ KEYBTDECLEX2(0x432, 0x412, true, 32, XK_Cyrillic_ve, XK_Cyrillic_VE), + /* а А */ KEYBTDECLEX2(0x430, 0x410, true, 33, XK_Cyrillic_a, XK_Cyrillic_A), + /* п П */ KEYBTDECLEX2(0x43f, 0x41f, true, 34, XK_Cyrillic_pe, XK_Cyrillic_PE), + /* р Р */ KEYBTDECLEX2(0x440, 0x420, true, 35, XK_Cyrillic_er, XK_Cyrillic_ER), + /* о О */ KEYBTDECLEX2(0x43e, 0x41e, true, 36, XK_Cyrillic_o, XK_Cyrillic_O), + /* л Л */ KEYBTDECLEX2(0x43b, 0x41b, true, 37, XK_Cyrillic_el, XK_Cyrillic_EL), + /* д Д */ KEYBTDECLEX2(0x434, 0x414, true, 38, XK_Cyrillic_de, XK_Cyrillic_DE), + /* ж Ж */ KEYBTDECLEX2(0x436, 0x416, true, 39, XK_Cyrillic_zhe, XK_Cyrillic_ZHE), + /* э Э */ KEYBTDECLEX2(0x44d, 0x42d, true, 40, XK_Cyrillic_e, XK_Cyrillic_E), + /* \ / */ KEYBTDECL(0x5c, 0x2f, false, 43), + + /* я Я */ KEYBTDECLEX2(0x44f, 0x42f, true, 44, XK_Cyrillic_ya, XK_Cyrillic_YA), + /* ч Ч */ KEYBTDECLEX2(0x447, 0x427, true, 45, XK_Cyrillic_che, XK_Cyrillic_CHE), + /* с С */ KEYBTDECLEX2(0x441, 0x421, true, 46, XK_Cyrillic_es, XK_Cyrillic_ES), + /* м М */ KEYBTDECLEX2(0x43c, 0x41c, true, 47, XK_Cyrillic_em, XK_Cyrillic_EM), + /* и И */ KEYBTDECLEX2(0x438, 0x418, true, 48, XK_Cyrillic_i, XK_Cyrillic_I), + /* т Т */ KEYBTDECLEX2(0x442, 0x422, true, 49, XK_Cyrillic_te, XK_Cyrillic_TE), + /* ь Ь */ KEYBTDECLEX2(0x44c, 0x42c, true, 50, XK_Cyrillic_softsign, XK_Cyrillic_SOFTSIGN), + /* б Б */ KEYBTDECLEX2(0x431, 0x411, true, 51, XK_Cyrillic_be, XK_Cyrillic_BE), + /* ю Ю */ KEYBTDECLEX2(0x44e, 0x42e, true, 52, XK_Cyrillic_yu, XK_Cyrillic_YU), + /* . , */ KEYBTDECL(0x2e, 0x2c, false, 53)}; + +KEYBT GERMAN_LOCALE[] = { + /* ^ ? */ KEYBTDECL(0x5f, 0xb0, false, 41), + /* 1 ! */ KEYBTDECL(0x31, 0x21, true, 2), + /* 2 " */ KEYBTDECL(0x32, 0x22, true, 3), + /* 3 */ KEYBTDECL(0x33, 0xa7, true, 4), + /* 4 $ */ KEYBTDECL(0x34, 0x24, true, 5), + /* 5 % */ KEYBTDECL(0x35, 0x25, true, 6), + /* 6 & */ KEYBTDECL(0x36, 0x26, true, 7), + /* 7 / */ KEYBTDECL(0x37, 0x2f, true, 8), + /* 8 ( */ KEYBTDECL(0x38, 0x28, true, 9), + /* 9 ) */ KEYBTDECL(0x39, 0x29, true, 10), + /* 0 = */ KEYBTDECL(0x30, 0x3d, true, 11), + /* ? ? */ KEYBTDECL(0xdf, 0x3f, true, 12), + /* ` ? */ KEYBTDECL(0x60, 0xb4, true, 13), + + /* q Q */ KEYBTDECL(0x71, 0x51, true, 16), + /* w W */ KEYBTDECL(0x77, 0x57, true, 17), + /* e E */ KEYBTDECL(0x65, 0x45, true, 18), + /* r R */ KEYBTDECL(0x72, 0x52, true, 19), + /* t T */ KEYBTDECL(0x74, 0x54, true, 20), + /* z Z */ KEYBTDECL(0x7a, 0x5a, true, 21), + /* u U */ KEYBTDECL(0x75, 0x55, true, 22), + /* i I */ KEYBTDECL(0x69, 0x49, true, 23), + /* o O */ KEYBTDECL(0x6f, 0x4f, true, 24), + /* p P */ KEYBTDECL(0x70, 0x50, true, 25), + /* ? ? */ KEYBTDECL(0xfc, 0xdc, true, 26), + /* + * */ KEYBTDECL(0x2b, 0x2a, true, 27), + + /* a A */ KEYBTDECL(0x61, 0x41, true, 30), + /* s S */ KEYBTDECL(0x73, 0x53, true, 31), + /* d D */ KEYBTDECL(0x64, 0x44, true, 32), + /* f F */ KEYBTDECL(0x66, 0x46, true, 33), + /* g G */ KEYBTDECL(0x67, 0x47, true, 34), + /* h H */ KEYBTDECL(0x68, 0x48, true, 35), + /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36), + /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37), + /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38), + /* ? ? */ KEYBTDECL(0xf6, 0xd6, true, 39), + /* ? ? */ KEYBTDECL(0xe4, 0xc4, true, 40), + /* ' # */ KEYBTDECL(0x27, 0x23, true, 43), + + /* y Y */ KEYBTDECL(0x79, 0x59, true, 44), + /* x X */ KEYBTDECL(0x78, 0x58, true, 45), + /* c C */ KEYBTDECL(0x63, 0x43, true, 46), + /* v V */ KEYBTDECL(0x76, 0x56, true, 47), + /* b B */ KEYBTDECL(0x62, 0x42, true, 48), + /* n N */ KEYBTDECL(0x6e, 0x4e, true, 49), + /* m M */ KEYBTDECL(0x6d, 0x4d, true, 50), + /* , ; */ KEYBTDECL(0x2c, 0x3b, true, 51), + /* . : */ KEYBTDECL(0x2e, 0x3a, true, 52), + /* _ - */ KEYBTDECL(0x5f, 0x2d, true, 53)}; + +KEYBT FRENCH_LOCALE[] = { + /* ? ? */ KEYBTDECL(0xb2, 0xb2, true, 41), + /* & 1 */ KEYBTDECL(0x26, 0x31, true, 2), + /* ? 2 */ KEYBTDECL(0xe9, 0x32, true, 3), + /* " 3 */ KEYBTDECL(0x22, 0x33, true, 4), + /* ' 4 */ KEYBTDECL(0x27, 0x34, true, 5), + /* ( 5 */ KEYBTDECL(0x28, 0x35, true, 6), + /* - 6 */ KEYBTDECL(0x2d, 0x36, true, 7), + /* ? 7 */ KEYBTDECL(0xe8, 0x37, true, 8), + /* _ 8 */ KEYBTDECL(0x5f, 0x38, true, 9), + /* ? 9 */ KEYBTDECL(0xe7, 0x39, true, 10), + /* ? 0 */ KEYBTDECL(0xe0, 0x29, true, 11), + /* ) ? */ KEYBTDECL(0x29, 0xb0, true, 12), + /* = + */ KEYBTDECL(0x3d, 0x2b, true, 13), + + /* a A */ KEYBTDECLEX6(0x61, 0x41, true, 16, 0x61, 0x41, 0xe0, 0xc0, 0xe4, 0xc4), + /* z Z */ KEYBTDECL(0x7a, 0x5a, true, 17), + /* e E */ KEYBTDECLEX6(0x65, 0x45, true, 18, 0x65, 0x45, 0xe8, 0xc8, 0xeb, 0xcb), + /* r R */ KEYBTDECL(0x72, 0x52, true, 19), + /* t T */ KEYBTDECL(0x74, 0x54, true, 20), + /* y Y */ KEYBTDECLEX6(0x79, 0x59, true, 21, 0x79, 0x59, 0, 0, 0xff, 0), + /* u U */ KEYBTDECLEX6(0x75, 0x55, true, 22, 0x75, 0x55, 0xf9, 0xd9, 0xfc, 0xdc), + /* i I */ KEYBTDECLEX6(0x69, 0x49, true, 23, 0x69, 0x49, 0xec, 0xcc, 0xef, 0xcf), + /* o O */ KEYBTDECLEX6(0x6f, 0x4f, true, 24, 0x6f, 0x4f, 0xf2, 0xd2, 0xf6, 0xd6), + /* p P */ KEYBTDECL(0x70, 0x50, true, 25), + /* ^ ? */ KEYBT(0x5e, 0xa8, true, 1, 2, KEYCODE(0x5e, 26, 0), KEYCODE(0xa8, 26, 1)), + /* $ ? } */ KEYBTDECL(0x24, 0xa3, true, 27), + + /* q Q */ KEYBTDECL(0x71, 0x51, true, 30), + /* s S */ KEYBTDECL(0x73, 0x53, true, 31), + /* d D */ KEYBTDECL(0x64, 0x44, true, 32), + /* f F */ KEYBTDECL(0x66, 0x46, true, 33), + /* g G */ KEYBTDECL(0x67, 0x47, true, 34), + /* h H */ KEYBTDECL(0x68, 0x48, true, 35), + /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36), + /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37), + /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38), + /* m M */ KEYBTDECL(0x6d, 0x4d, true, 39), + /* ? % */ KEYBTDECL(0xf9, 0x25, true, 40), + /* * ? */ KEYBTDECL(0x2a, 0xb5, true, 43), + + /* w W */ KEYBTDECL(0x77, 0x57, true, 44), + /* x X */ KEYBTDECL(0x78, 0x58, true, 45), + /* c C */ KEYBTDECL(0x63, 0x43, true, 46), + /* v V */ KEYBTDECL(0x76, 0x56, true, 47), + /* b B */ KEYBTDECL(0x62, 0x42, true, 48), + /* n N */ KEYBTDECL(0x6e, 0x4e, true, 49), + /* , ? */ KEYBTDECL(0x2c, 0x3f, true, 50), + /* ; . */ KEYBTDECL(0x3b, 0x2e, true, 51), + /* : / */ KEYBTDECL(0x3a, 0x2f, true, 52), + /* ! ? */ KEYBTDECL(0x21, 0xa7, true, 53)}; + + +KEYBT SWISS_FRENCH_LOCALE[] = { + /* § °*/ KEYBTDECL(0xa7, 0xb0, false, 41), + /* 1 +*/ KEYBTDECL(0x31, 0x2b, false, 2), + /* 2 "*/ KEYBTDECL(0x32, 0x22, false, 3), + /* 3 **/ KEYBTDECL(0x33, 0x2a, false, 4), + /* 4 ç*/ KEYBTDECL(0x34, 0xe7, false, 5), + /* 5 %*/ KEYBTDECL(0x35, 0x25, false, 6), + /* 6 &*/ KEYBTDECL(0x36, 0x26, false, 7), + /* 7 /*/ KEYBTDECL(0x37, 0x2f, false, 8), + /* 8 (*/ KEYBTDECL(0x38, 0x28, false, 9), + /* 9 )*/ KEYBTDECL(0x39, 0x29, false, 10), + /* 0 =*/ KEYBTDECL(0x30, 0x3d, false, 11), + /* ' ?*/ KEYBTDECL(0x27, 0x5f, false, 12), + /* ^ `*/ KEYBT(0x5e, 0x60, false, 1, 2, KEYCODE(0x5e, 13, 0), KEYCODE(0x60, 13, 1)), + + /* q Q*/ KEYBTDECL(0x71, 0x51, true, 16), + /* w W*/ KEYBTDECL(0x77, 0x57, true, 17), + /* e E*/ KEYBTDECLEX8(0x65, 0x45, true, 18, 0x65, 0x45, 0xea, 0xca, 0xe8, 0xc8, 0xeb, 0xcb), + /* r R*/ KEYBTDECL(0x72, 0x52, true, 19), + /* t T*/ KEYBTDECL(0x74, 0x54, true, 20), + /* z Z*/ KEYBTDECL(0x7a, 0x5a, true, 21), + /* u U*/ KEYBTDECLEX8(0x75, 0x55, true, 22, 0x75, 0x55, 0xfb, 0xdb, 0xf9, 0xd9, 0xfc, 0xdc), + /* i I*/ KEYBTDECLEX8(0x69, 0x49, true, 23, 0x69, 0x49, 0xee, 0xce, 0xec, 0xcc, 0xef, 0xcf), + /* o O*/ KEYBTDECLEX8(0x6f, 0x4f, true, 24, 0x6f, 0x4f, 0xf4, 0xd4, 0xf2, 0xd2, 0xf6, 0xd6), + /* p P*/ KEYBTDECL(0x70, 0x50, true, 25), + /* è ü*/ KEYBTDECL(0xe8, 0xfa, false, 26), + /* ¨ !*/ KEYBT(0xa8, 0x21, false, 3, 0, KEYCODE(0xa8, 27, 0), KEYCODE(0x21, 27, 1)), + + /* a A*/ KEYBTDECLEX8(0x61, 0x41, true, 30, 0x61, 0x41, 0xe2, 0xc2, 0xe0, 0xc0, 0xe4, 0xc4), + /* s S*/ KEYBTDECL(0x73, 0x53, true, 31), + /* d D*/ KEYBTDECL(0x64, 0x44, true, 32), + /* f F*/ KEYBTDECL(0x66, 0x46, true, 33), + /* g G*/ KEYBTDECL(0x67, 0x47, true, 34), + /* h H*/ KEYBTDECL(0x68, 0x48, true, 35), + /* j J*/ KEYBTDECL(0x6a, 0x4a, true, 36), + /* k K*/ KEYBTDECL(0x6b, 0x4b, true, 37), + /* l L*/ KEYBTDECL(0x6c, 0x4c, true, 38), + /* é ö*/ KEYBTDECL(0xe9, 0xf6, false, 39), + /* à ä*/ KEYBTDECL(0xe0, 0xe4, false, 40), + /* $ £*/ KEYBTDECL(0x24, 0xa3, false, 43), + + /* < >*/ KEYBTDECL(0x3c, 0x3e, false, 44), + /* y Y*/ KEYBTDECLEX8(0x79, 0x59, true, 45, 0x79, 0x59, 0, 0, 0, 0, 0xff, 0), + /* x X*/ KEYBTDECL(0x78, 0x58, true, 46), + /* c C*/ KEYBTDECL(0x63, 0x43, true, 47), + /* v V*/ KEYBTDECL(0x76, 0x56, true, 48), + /* b B*/ KEYBTDECL(0x62, 0x42, true, 49), + /* n N*/ KEYBTDECL(0x6e, 0x4e, true, 50), + /* m M*/ KEYBTDECL(0x6d, 0x4d, true, 51), + /* , ;*/ KEYBTDECL(0x2c, 0x3b, false, 52), + /* . :*/ KEYBTDECL(0x2e, 0x3a, false, 53), + /* - _*/ KEYBTDECL(0x2d, 0x5f, false, 54)}; void UBPlatformUtils::initializeKeyboardLayouts() { - nKeyboardLayouts = 4; + nKeyboardLayouts = 5; keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts]; keyboardLayouts[0] = new UBKeyboardLocale("English", "en", "", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); keyboardLayouts[1] = new UBKeyboardLocale("Russian", "ru", "", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); - keyboardLayouts[2] = new UBKeyboardLocale("French", "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); - keyboardLayouts[3] = new UBKeyboardLocale("German", "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); + keyboardLayouts[2] = new UBKeyboardLocale("German", "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); + keyboardLayouts[3] = new UBKeyboardLocale("French", "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); + keyboardLayouts[4] = new UBKeyboardLocale("Swiss French", "fr", "", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); + } void UBPlatformUtils::destroyKeyboardLayouts() { - for(int i=0; i<4; i++) + for(int i=0; i #import #import + +/* +// commented because Sankore crashes on Java Script. It seems to backends dependencies. #import #import +*/ NSString* bundleShortVersion(NSBundle *bundle) @@ -409,14 +413,15 @@ KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk) UInt32 deadKeyState = 0L; UInt32 kbdType = kKeyboardISO; - UniCharCount cnt1, cnt2; - UniChar unicodeString1[100], unicodeString2[100]; + UniCharCount cnt1, cnt2, cnt3; + UniChar unicodeString1[100], unicodeString2[100], unicodeString3[100]; UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, 0, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt1, unicodeString1); UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (shiftKey >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString2); + UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (alphaLock >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString3); - return new KEYBT(unicodeString1[0], vkk, unicodeString2[0], vkk); -} + return new KEYBT(unicodeString1[0], unicodeString2[0], unicodeString1[0] != unicodeString3[0], 0,0, KEYCODE(0, vkk, 0), KEYCODE(0, vkk, 1)); + } void UBPlatformUtils::initializeKeyboardLayouts() @@ -543,13 +548,14 @@ void UBPlatformUtils::destroyKeyboardLayouts() QString UBPlatformUtils::urlFromClipboard() { QString qsRet; - +/* + // commented because Sankore crashes on Java Script. It seems to backends dependencies. NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"]; WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]]; qsRet = [[[[pArchive mainResource] URL] absoluteString] UTF8String]; [pArchive release]; - +*/ return qsRet; } diff --git a/src/frameworks/UBPlatformUtils_win.cpp b/src/frameworks/UBPlatformUtils_win.cpp index 04f09420..b450cc9a 100644 --- a/src/frameworks/UBPlatformUtils_win.cpp +++ b/src/frameworks/UBPlatformUtils_win.cpp @@ -128,270 +128,271 @@ void UBPlatformUtils::setWindowNonActivableFlag(QWidget* widget, bool nonAcivabl SetWindowLong(widget->winId(), GWL_EXSTYLE, exStyle); } +#define KEYBTDECL(s1, s2, clSwitch) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(s1), KEYCODE(s2)) - -const KEYBT RUSSIAN_LOCALE [] = +KEYBT RUSSIAN_LOCALE [] = { - /* Ј і */ KEYBT(0x451, 0x401), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 " */ KEYBT(0x32, 0x5c), - /* 3 ? */ KEYBT(0x33, 0x2116), - /* 4 ; */ KEYBT(0x34, 0x3b), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 : */ KEYBT(0x36, 0x3a), - /* 7 ? */ KEYBT(0x37, 0x3f), - /* 8 * */ KEYBT(0x38, 0x2a), - /* 9 ( */ KEYBT(0x39, 0x28), - /* 0 ) */ KEYBT(0x30, 0x29), - /* - _ */ KEYBT(0x2d, 0x4f), - /* = + */ KEYBT(0x3d, 0x2b), - - /* К к */ KEYBT(0x439, 0x419), - /* Г г */ KEYBT(0x446, 0x426), - /* Х х */ KEYBT(0x443, 0x423), - /* Л л */ KEYBT(0x43a, 0x41a), - /* Е е */ KEYBT(0x435, 0x415), - /* О о */ KEYBT(0x43d, 0x41d), - /* З з */ KEYBT(0x433, 0x413), - /* Ы ы */ KEYBT(0x448, 0x428), - /* Э э */ KEYBT(0x449, 0x429), - /* Ъ ъ */ KEYBT(0x437, 0x417), - /* И и */ KEYBT(0x445, 0x425), - /* Я я */ KEYBT(0x44a, 0x42a), - - /* Ж ж */ KEYBT(0x444, 0x424), - /* Щ щ */ KEYBT(0x44b, 0x42b), - /* Ч ч */ KEYBT(0x432, 0x412), - /* Б б */ KEYBT(0x430, 0x410), - /* Р р */ KEYBT(0x43f, 0x41f), - /* Т т */ KEYBT(0x440, 0x420), - /* П п */ KEYBT(0x43e, 0x41e), - /* М м */ KEYBT(0x43b, 0x41b), - /* Д д */ KEYBT(0x434, 0x414), - /* Ц ц */ KEYBT(0x436, 0x416), - /* Ь ь */ KEYBT(0x44d, 0x42d), - /* \ / */ KEYBT(0x5c, 0x2f), - - /* С с */ KEYBT(0x44f, 0x42f), - /* Ю ю */ KEYBT(0x447, 0x427), - /* У у */ KEYBT(0x441, 0x421), - /* Н н */ KEYBT(0x43c, 0x41c), - /* Й й */ KEYBT(0x438, 0x418), - /* Ф ф */ KEYBT(0x442, 0x422), - /* Ш ш */ KEYBT(0x44c, 0x42c), - /* В в */ KEYBT(0x431, 0x411), - /* А а */ KEYBT(0x44e, 0x42e), - /* . , */ KEYBT(0x2e, 0x2c)}; - -const KEYBT ENGLISH_LOCALE[] = { - /* ` ~ */ KEYBT(0x60, 0x7e), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 @ */ KEYBT(0x32, 0x40), - /* 3 # */ KEYBT(0x33, 0x23), - /* 4 $ */ KEYBT(0x34, 0x24), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 ^ */ KEYBT(0x36, 0x5e), - /* 7 & */ KEYBT(0x37, 0x26), - /* 8 * */ KEYBT(0x38, 0x2a), - /* 9 ( */ KEYBT(0x39, 0x28), - /* 0 ) */ KEYBT(0x30, 0x29), - /* - _ */ KEYBT(0x2d, 0x5f), - /* = + */ KEYBT(0x3d, 0x2b), - - /* q Q */ KEYBT(0x71, 0x51), - /* w W */ KEYBT(0x77, 0x57), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* y Y */ KEYBT(0x79, 0x59), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* [ { */ KEYBT(0x5b, 0x7b), - /* ] } */ KEYBT(0x5d, 0x7d), - - /* a A */ KEYBT(0x61, 0x41), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* ; : */ KEYBT(0x3b, 0x3a), - /* ' " */ KEYBT(0x27, 0x22), - /* \ | */ KEYBT(0x5c, 0x7c), - - /* z Z */ KEYBT(0x7a, 0x5a), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* m M */ KEYBT(0x6d, 0x4d), - /* , < */ KEYBT(0x2c, 0x3c), - /* . > */ KEYBT(0x2e, 0x3e), - /* / ? */ KEYBT(0x2f, 0x5f)}; - - -const KEYBT FRENCH_LOCALE[] = { - /* ? ? */ KEYBT(0xb2, 0xb2), - /* & 1 */ KEYBT(0x26, 0x31), - /* ? 2 */ KEYBT(0xe9, 0x32), - /* " 3 */ KEYBT(0x22, 0x33), - /* ' 4 */ KEYBT(0x27, 0x34), - /* ( 5 */ KEYBT(0x28, 0x35), - /* - 6 */ KEYBT(0x2d, 0x36), - /* ? 7 */ KEYBT(0xe8, 0x37), - /* _ 8 */ KEYBT(0x5f, 0x38), - /* ? 9 */ KEYBT(0xe7, 0x39), - /* ? 0 */ KEYBT(0xe0, 0x29), - /* ) ? */ KEYBT(0x29, 0xb0), - /* = + */ KEYBT(0x3d, 0x2b), - - /* a A */ KEYBT(0x61, 0x41), - /* z Z */ KEYBT(0x7a, 0x5a), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* y Y */ KEYBT(0x79, 0x59), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* ^ ? */ KEYBT(0x5e, 0xa8), - /* $ ? } */ KEYBT(0x24, 0xa3), - - /* q Q */ KEYBT(0x71, 0x51), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* m M */ KEYBT(0x6d, 0x4d), - /* ? % */ KEYBT(0xf9, 0x25), - /* * ? */ KEYBT(0x2a, 0xb5), - - /* w W */ KEYBT(0x77, 0x57), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* , ? */ KEYBT(0x2c, 0x3f), - /* ; . */ KEYBT(0x3b, 0x2e), - /* : / */ KEYBT(0x3a, 0x2f), - /* ! ? */ KEYBT(0x21, 0xa7)}; - -const KEYBT SWISS_FRENCH_LOCALE[] = { - /* § °*/ KEYBT(0xa7, 0xb0), - /* 1 +*/ KEYBT(0x31, 0x2b), - /* 2 "*/ KEYBT(0x32, 0x22), - /* 3 **/ KEYBT(0x33, 0x2a), - /* 4 ç*/ KEYBT(0x34, 0xe7), - /* 5 %*/ KEYBT(0x35, 0x25), - /* 6 &*/ KEYBT(0x36, 0x26), - /* 7 /*/ KEYBT(0x37, 0x2f), - /* 8 (*/ KEYBT(0x38, 0x28), - /* 9 )*/ KEYBT(0x39, 0x29), - /* 0 =*/ KEYBT(0x30, 0x3d), - /* ' ?*/ KEYBT(0x27, 0x5f), - /* ^ `*/ KEYBT(0x5e, 0x60), - - /* q Q*/ KEYBT(0x71, 0x51), - /* w W*/ KEYBT(0x77, 0x57), - /* e E*/ KEYBT(0x65, 0x45), - /* r R*/ KEYBT(0x72, 0x52), - /* t T*/ KEYBT(0x74, 0x54), - /* z Z*/ KEYBT(0x7a, 0x5a), - /* u U*/ KEYBT(0x75, 0x55), - /* i I*/ KEYBT(0x69, 0x49), - /* o O*/ KEYBT(0x6f, 0x4f), - /* p P*/ KEYBT(0x70, 0x50), - /* è ü*/ KEYBT(0xe8, 0xfa), - /* ¨ !*/ KEYBT(0xa8 ,0x21), - - /* a A*/ KEYBT(0x61, 0x41), - /* s S*/ KEYBT(0x73, 0x53), - /* d D*/ KEYBT(0x64, 0x44), - /* f F*/ KEYBT(0x66, 0x46), - /* g G*/ KEYBT(0x67, 0x47), - /* h H*/ KEYBT(0x68, 0x48), - /* j J*/ KEYBT(0x6a, 0x4a), - /* k K*/ KEYBT(0x6b, 0x4b), - /* l L*/ KEYBT(0x6c, 0x4c), - /* é ö*/ KEYBT(0xe9, 0xf6), - /* à ä*/ KEYBT(0xe0, 0xe4), - /* $ £*/ KEYBT(0x24, 0xa3), - - /* < >*/ KEYBT(0x3c, 0x3e), - /* y Y*/ KEYBT(0x79, 0x59), - /* x X*/ KEYBT(0x78, 0x58), - /* c C*/ KEYBT(0x63, 0x43), - /* v V*/ KEYBT(0x76, 0x56), - /* b B*/ KEYBT(0x62, 0x42), - /* n N*/ KEYBT(0x6e, 0x4e), - /* m M*/ KEYBT(0x6d, 0x4d), - /* , ;*/ KEYBT(0x2c, 0x3b), - /* . :*/ KEYBT(0x2e, 0x3a), - /* - _*/ KEYBT(0x2d, 0x5f)}; - -const KEYBT GERMAN_LOCALE[] = { - /* ^ ? */ KEYBT(0x5f, 0xb0), - /* 1 ! */ KEYBT(0x31, 0x21), - /* 2 " */ KEYBT(0x32, 0x22), - /* 3 § */ KEYBT(0x33, 0xa7), - /* 4 $ */ KEYBT(0x34, 0x24), - /* 5 % */ KEYBT(0x35, 0x25), - /* 6 & */ KEYBT(0x36, 0x26), - /* 7 / */ KEYBT(0x37, 0x2f), - /* 8 ( */ KEYBT(0x38, 0x28), - /* 9 ) */ KEYBT(0x39, 0x29), - /* 0 = */ KEYBT(0x30, 0x3d), - /* ? ? */ KEYBT(0xdf, 0x3f), - /* ` ? */ KEYBT(0x60, 0xb4), - - /* q Q */ KEYBT(0x71, 0x51), - /* w W */ KEYBT(0x77, 0x57), - /* e E */ KEYBT(0x65, 0x45), - /* r R */ KEYBT(0x72, 0x52), - /* t T */ KEYBT(0x74, 0x54), - /* z Z */ KEYBT(0x7a, 0x5a), - /* u U */ KEYBT(0x75, 0x55), - /* i I */ KEYBT(0x69, 0x49), - /* o O */ KEYBT(0x6f, 0x4f), - /* p P */ KEYBT(0x70, 0x50), - /* ? ? */ KEYBT(0xfc, 0xdc), - /* + * */ KEYBT(0x2b, 0x2a), - - /* a A */ KEYBT(0x61, 0x41), - /* s S */ KEYBT(0x73, 0x53), - /* d D */ KEYBT(0x64, 0x44), - /* f F */ KEYBT(0x66, 0x46), - /* g G */ KEYBT(0x67, 0x47), - /* h H */ KEYBT(0x68, 0x48), - /* j J */ KEYBT(0x6a, 0x4a), - /* k K */ KEYBT(0x6b, 0x4b), - /* l L */ KEYBT(0x6c, 0x4c), - /* ? ? */ KEYBT(0xf6, 0xd6), - /* ? ? */ KEYBT(0xe4, 0xc4), - /* ' # */ KEYBT(0x27, 0x23), - - /* y Y */ KEYBT(0x79, 0x59), - /* x X */ KEYBT(0x78, 0x58), - /* c C */ KEYBT(0x63, 0x43), - /* v V */ KEYBT(0x76, 0x56), - /* b B */ KEYBT(0x62, 0x42), - /* n N */ KEYBT(0x6e, 0x4e), - /* m M */ KEYBT(0x6d, 0x4d), - /* , ; */ KEYBT(0x2c, 0x3b), - /* . : */ KEYBT(0x2e, 0x3a), - /* _ - */ KEYBT(0x5f, 0x2d)}; + /* Ј і */ KEYBTDECL(0x451, 0x401, true), + /* 1 ! */ KEYBTDECL(0x31, 0x21, false), + /* 2 " */ KEYBTDECL(0x32, 0x5c, false), + /* 3 ? */ KEYBTDECL(0x33, 0x2116, false), + /* 4 ; */ KEYBTDECL(0x34, 0x3b, false), + /* 5 % */ KEYBTDECL(0x35, 0x25, false), + /* 6 : */ KEYBTDECL(0x36, 0x3a, false), + /* 7 ? */ KEYBTDECL(0x37, 0x3f, false), + /* 8 * */ KEYBTDECL(0x38, 0x2a, false), + /* 9 ( */ KEYBTDECL(0x39, 0x28, false), + /* 0 ) */ KEYBTDECL(0x30, 0x29, false), + /* - _ */ KEYBTDECL(0x2d, 0x4f, false), + /* = + */ KEYBTDECL(0x3d, 0x2b, false), + + /* К к */ KEYBTDECL(0x439, 0x419, true), + /* Г г */ KEYBTDECL(0x446, 0x426, true), + /* Х х */ KEYBTDECL(0x443, 0x423, true), + /* Л л */ KEYBTDECL(0x43a, 0x41a, true), + /* Е е */ KEYBTDECL(0x435, 0x415, true), + /* О о */ KEYBTDECL(0x43d, 0x41d, true), + /* З з */ KEYBTDECL(0x433, 0x413, true), + /* Ы ы */ KEYBTDECL(0x448, 0x428, true), + /* Э э */ KEYBTDECL(0x449, 0x429, true), + /* Ъ ъ */ KEYBTDECL(0x437, 0x417, true), + /* И и */ KEYBTDECL(0x445, 0x425, true), + /* Я я */ KEYBTDECL(0x44a, 0x42a, true), + + /* Ж ж */ KEYBTDECL(0x444, 0x424, true), + /* Щ щ */ KEYBTDECL(0x44b, 0x42b, true), + /* Ч ч */ KEYBTDECL(0x432, 0x412, true), + /* Б б */ KEYBTDECL(0x430, 0x410, true), + /* Р р */ KEYBTDECL(0x43f, 0x41f, true), + /* Т т */ KEYBTDECL(0x440, 0x420, true), + /* П п */ KEYBTDECL(0x43e, 0x41e, true), + /* М м */ KEYBTDECL(0x43b, 0x41b, true), + /* Д д */ KEYBTDECL(0x434, 0x414, true), + /* Ц ц */ KEYBTDECL(0x436, 0x416, true), + /* Ь ь */ KEYBTDECL(0x44d, 0x42d, true), + /* \ / */ KEYBTDECL(0x5c, 0x2f, false), + + /* С с */ KEYBTDECL(0x44f, 0x42f, true), + /* Ю ю */ KEYBTDECL(0x447, 0x427, true), + /* У у */ KEYBTDECL(0x441, 0x421, true), + /* Н н */ KEYBTDECL(0x43c, 0x41c, true), + /* Й й */ KEYBTDECL(0x438, 0x418, true), + /* Ф ф */ KEYBTDECL(0x442, 0x422, true), + /* Ш ш */ KEYBTDECL(0x44c, 0x42c, true), + /* В в */ KEYBTDECL(0x431, 0x411, true), + /* А а */ KEYBTDECL(0x44e, 0x42e, true), + /* . , */ KEYBTDECL(0x2e, 0x2c, false)}; + +KEYBT ENGLISH_LOCALE[] = { + /* ` ~ */ KEYBTDECL(0x60, 0x7e, false), + /* 1 ! */ KEYBTDECL(0x31, 0x21, false), + /* 2 @ */ KEYBTDECL(0x32, 0x40, false), + /* 3 # */ KEYBTDECL(0x33, 0x23, false), + /* 4 $ */ KEYBTDECL(0x34, 0x24, false), + /* 5 % */ KEYBTDECL(0x35, 0x25, false), + /* 6 ^ */ KEYBTDECL(0x36, 0x5e, false), + /* 7 & */ KEYBTDECL(0x37, 0x26, false), + /* 8 * */ KEYBTDECL(0x38, 0x2a, false), + /* 9 ( */ KEYBTDECL(0x39, 0x28, false), + /* 0 ) */ KEYBTDECL(0x30, 0x29, false), + /* - _ */ KEYBTDECL(0x2d, 0x5f, false), + /* = + */ KEYBTDECL(0x3d, 0x2b, false), + + /* q Q */ KEYBTDECL(0x71, 0x51, true), + /* w W */ KEYBTDECL(0x77, 0x57, true), + /* e E */ KEYBTDECL(0x65, 0x45, true), + /* r R */ KEYBTDECL(0x72, 0x52, true), + /* t T */ KEYBTDECL(0x74, 0x54, true), + /* y Y */ KEYBTDECL(0x79, 0x59, true), + /* u U */ KEYBTDECL(0x75, 0x55, true), + /* i I */ KEYBTDECL(0x69, 0x49, true), + /* o O */ KEYBTDECL(0x6f, 0x4f, true), + /* p P */ KEYBTDECL(0x70, 0x50, true), + /* [ { */ KEYBTDECL(0x5b, 0x7b, false), + /* ] } */ KEYBTDECL(0x5d, 0x7d, false), + + /* a A */ KEYBTDECL(0x61, 0x41, true), + /* s S */ KEYBTDECL(0x73, 0x53, true), + /* d D */ KEYBTDECL(0x64, 0x44, true), + /* f F */ KEYBTDECL(0x66, 0x46, true), + /* g G */ KEYBTDECL(0x67, 0x47, true), + /* h H */ KEYBTDECL(0x68, 0x48, true), + /* j J */ KEYBTDECL(0x6a, 0x4a, true), + /* k K */ KEYBTDECL(0x6b, 0x4b, true), + /* l L */ KEYBTDECL(0x6c, 0x4c, true), + /* ; : */ KEYBTDECL(0x3b, 0x3a, false), + /* ' " */ KEYBTDECL(0x27, 0x22, false), + /* \ | */ KEYBTDECL(0x5c, 0x7c, false), + + /* z Z */ KEYBTDECL(0x7a, 0x5a, true), + /* x X */ KEYBTDECL(0x78, 0x58, true), + /* c C */ KEYBTDECL(0x63, 0x43, true), + /* v V */ KEYBTDECL(0x76, 0x56, true), + /* b B */ KEYBTDECL(0x62, 0x42, true), + /* n N */ KEYBTDECL(0x6e, 0x4e, true), + /* m M */ KEYBTDECL(0x6d, 0x4d, true), + /* , < */ KEYBTDECL(0x2c, 0x3c, false), + /* . > */ KEYBTDECL(0x2e, 0x3e, false), + /* / ? */ KEYBTDECL(0x2f, 0x5f, false)}; + + +KEYBT FRENCH_LOCALE[] = { + /* ? ? */ KEYBTDECL(0xb2, 0xb2, true), + /* & 1 */ KEYBTDECL(0x26, 0x31, true), + /* ? 2 */ KEYBTDECL(0xe9, 0x32, true), + /* " 3 */ KEYBTDECL(0x22, 0x33, true), + /* ' 4 */ KEYBTDECL(0x27, 0x34, true), + /* ( 5 */ KEYBTDECL(0x28, 0x35, true), + /* - 6 */ KEYBTDECL(0x2d, 0x36, true), + /* ? 7 */ KEYBTDECL(0xe8, 0x37, true), + /* _ 8 */ KEYBTDECL(0x5f, 0x38, true), + /* ? 9 */ KEYBTDECL(0xe7, 0x39, true), + /* ? 0 */ KEYBTDECL(0xe0, 0x29, true), + /* ) ? */ KEYBTDECL(0x29, 0xb0, true), + /* = + */ KEYBTDECL(0x3d, 0x2b, true), + + /* a A */ KEYBT(0x61, 0x41, true, 0, 0, 0x61, 0x41, 0xe0, 0xc0, 0xe4, 0xc4), + /* z Z */ KEYBTDECL(0x7a, 0x5a, true), + /* e E */ KEYBT(0x65, 0x45, true, 0, 0, 0x65, 0x45, 0xe8, 0xc8, 0xeb, 0xcb), + /* r R */ KEYBTDECL(0x72, 0x52, true), + /* t T */ KEYBTDECL(0x74, 0x54, true), + /* y Y */ KEYBT(0x79, 0x59, true, 0, 0, 0x79, 0x59, 0, 0, 0xff), + /* u U */ KEYBT(0x75, 0x55, true, 0, 0, 0x75, 0x55, 0xf9, 0xd9, 0xfc, 0xdc), + /* i I */ KEYBT(0x69, 0x49, true, 0, 0, 0x69, 0x49, 0xec, 0xcc, 0xef, 0xcf), + /* o O */ KEYBT(0x6f, 0x4f, true, 0, 0, 0x6f, 0x4f, 0xf2, 0xd2, 0xf6, 0xd6), + /* p P */ KEYBTDECL(0x70, 0x50, true), + /* ^ ? */ KEYBT(0x5e, 0xa8, true, 1, 2, 0x5e, 0xa8), + /* $ ? } */ KEYBTDECL(0x24, 0xa3, true), + + /* q Q */ KEYBTDECL(0x71, 0x51, true), + /* s S */ KEYBTDECL(0x73, 0x53, true), + /* d D */ KEYBTDECL(0x64, 0x44, true), + /* f F */ KEYBTDECL(0x66, 0x46, true), + /* g G */ KEYBTDECL(0x67, 0x47, true), + /* h H */ KEYBTDECL(0x68, 0x48, true), + /* j J */ KEYBTDECL(0x6a, 0x4a, true), + /* k K */ KEYBTDECL(0x6b, 0x4b, true), + /* l L */ KEYBTDECL(0x6c, 0x4c, true), + /* m M */ KEYBTDECL(0x6d, 0x4d, true), + /* ? % */ KEYBTDECL(0xf9, 0x25, true), + /* * ? */ KEYBTDECL(0x2a, 0xb5, true), + + /* w W */ KEYBTDECL(0x77, 0x57, true), + /* x X */ KEYBTDECL(0x78, 0x58, true), + /* c C */ KEYBTDECL(0x63, 0x43, true), + /* v V */ KEYBTDECL(0x76, 0x56, true), + /* b B */ KEYBTDECL(0x62, 0x42, true), + /* n N */ KEYBTDECL(0x6e, 0x4e, true), + /* , ? */ KEYBTDECL(0x2c, 0x3f, true), + /* ; . */ KEYBTDECL(0x3b, 0x2e, true), + /* : / */ KEYBTDECL(0x3a, 0x2f, true), + /* ! ? */ KEYBTDECL(0x21, 0xa7, true)}; + +KEYBT SWISS_FRENCH_LOCALE[] = { + /* § °*/ KEYBTDECL(0xa7, 0xb0, false), + /* 1 +*/ KEYBTDECL(0x31, 0x2b, false), + /* 2 "*/ KEYBTDECL(0x32, 0x22, false), + /* 3 **/ KEYBTDECL(0x33, 0x2a, false), + /* 4 ç*/ KEYBTDECL(0x34, 0xe7, false), + /* 5 %*/ KEYBTDECL(0x35, 0x25, false), + /* 6 &*/ KEYBTDECL(0x36, 0x26, false), + /* 7 /*/ KEYBTDECL(0x37, 0x2f, false), + /* 8 (*/ KEYBTDECL(0x38, 0x28, false), + /* 9 )*/ KEYBTDECL(0x39, 0x29, false), + /* 0 =*/ KEYBTDECL(0x30, 0x3d, false), + /* ' ?*/ KEYBTDECL(0x27, 0x5f, false), + /* ^ `*/ KEYBT(0x5e, 0x60, false, 1, 2, 0x5e, 0x60), + + /* q Q*/ KEYBTDECL(0x71, 0x51, true), + /* w W*/ KEYBTDECL(0x77, 0x57, true), + /* e E*/ KEYBT(0x65, 0x45, true, 0, 0, 0x65, 0x45, 0xea, 0xca, 0xe8, 0xc8, 0xeb, 0xcb), + /* r R*/ KEYBTDECL(0x72, 0x52, true), + /* t T*/ KEYBTDECL(0x74, 0x54, true), + /* z Z*/ KEYBTDECL(0x7a, 0x5a, true), + /* u U*/ KEYBT(0x75, 0x55, true, 0, 0, 0x75, 0x55, 0xfb, 0xdb, 0xf9, 0xd9, 0xfc, 0xdc), + /* i I*/ KEYBT(0x69, 0x49, true, 0, 0, 0x69, 0x49, 0xee, 0xce, 0xec, 0xcc, 0xef, 0xcf), + /* o O*/ KEYBT(0x6f, 0x4f, true, 0, 0, 0x6f, 0x4f, 0xf4, 0xd4, 0xf2, 0xd2, 0xf6, 0xd6), + /* p P*/ KEYBTDECL(0x70, 0x50, true), + /* è ü*/ KEYBTDECL(0xe8, 0xfa, false), + /* ¨ !*/ KEYBT(0xa8, 0x21, false, 3, 0, 0xa8, 0x21), + + /* a A*/ KEYBT(0x61, 0x41, true, 0, 0, 0x61, 0x41, 0xe2, 0xc2, 0xe0, 0xc0, 0xe4, 0xc4), + /* s S*/ KEYBTDECL(0x73, 0x53, true), + /* d D*/ KEYBTDECL(0x64, 0x44, true), + /* f F*/ KEYBTDECL(0x66, 0x46, true), + /* g G*/ KEYBTDECL(0x67, 0x47, true), + /* h H*/ KEYBTDECL(0x68, 0x48, true), + /* j J*/ KEYBTDECL(0x6a, 0x4a, true), + /* k K*/ KEYBTDECL(0x6b, 0x4b, true), + /* l L*/ KEYBTDECL(0x6c, 0x4c, true), + /* é ö*/ KEYBTDECL(0xe9, 0xf6, false), + /* à ä*/ KEYBTDECL(0xe0, 0xe4, false), + /* $ £*/ KEYBTDECL(0x24, 0xa3, false), + + /* < >*/ KEYBTDECL(0x3c, 0x3e, false), + /* y Y*/ KEYBT(0x79, 0x59, true, 0, 0, 0x79, 0x59, 0, 0, 0, 0, 0xff), + /* x X*/ KEYBTDECL(0x78, 0x58, true), + /* c C*/ KEYBTDECL(0x63, 0x43, true), + /* v V*/ KEYBTDECL(0x76, 0x56, true), + /* b B*/ KEYBTDECL(0x62, 0x42, true), + /* n N*/ KEYBTDECL(0x6e, 0x4e, true), + /* m M*/ KEYBTDECL(0x6d, 0x4d, true), + /* , ;*/ KEYBTDECL(0x2c, 0x3b, false), + /* . :*/ KEYBTDECL(0x2e, 0x3a, false), + /* - _*/ KEYBTDECL(0x2d, 0x5f, false)}; + + +KEYBT GERMAN_LOCALE[] = { + /* ^ ? */ KEYBTDECL(0x5f, 0xb0, false), + /* 1 ! */ KEYBTDECL(0x31, 0x21, true), + /* 2 " */ KEYBTDECL(0x32, 0x22, true), + /* 3 § */ KEYBTDECL(0x33, 0xa7, true), + /* 4 $ */ KEYBTDECL(0x34, 0x24, true), + /* 5 % */ KEYBTDECL(0x35, 0x25, true), + /* 6 & */ KEYBTDECL(0x36, 0x26, true), + /* 7 / */ KEYBTDECL(0x37, 0x2f, true), + /* 8 ( */ KEYBTDECL(0x38, 0x28, true), + /* 9 ) */ KEYBTDECL(0x39, 0x29, true), + /* 0 = */ KEYBTDECL(0x30, 0x3d, true), + /* ? ? */ KEYBTDECL(0xdf, 0x3f, true), + /* ` ? */ KEYBTDECL(0x60, 0xb4, false), + + /* q Q */ KEYBTDECL(0x71, 0x51, true), + /* w W */ KEYBTDECL(0x77, 0x57, true), + /* e E */ KEYBTDECL(0x65, 0x45, true), + /* r R */ KEYBTDECL(0x72, 0x52, true), + /* t T */ KEYBTDECL(0x74, 0x54, true), + /* z Z */ KEYBTDECL(0x7a, 0x5a, true), + /* u U */ KEYBTDECL(0x75, 0x55, true), + /* i I */ KEYBTDECL(0x69, 0x49, true), + /* o O */ KEYBTDECL(0x6f, 0x4f, true), + /* p P */ KEYBTDECL(0x70, 0x50, true), + /* ? ? */ KEYBTDECL(0xfc, 0xdc, true), + /* + * */ KEYBTDECL(0x2b, 0x2a, true), + + /* a A */ KEYBTDECL(0x61, 0x41, true), + /* s S */ KEYBTDECL(0x73, 0x53, true), + /* d D */ KEYBTDECL(0x64, 0x44, true), + /* f F */ KEYBTDECL(0x66, 0x46, true), + /* g G */ KEYBTDECL(0x67, 0x47, true), + /* h H */ KEYBTDECL(0x68, 0x48, true), + /* j J */ KEYBTDECL(0x6a, 0x4a, true), + /* k K */ KEYBTDECL(0x6b, 0x4b, true), + /* l L */ KEYBTDECL(0x6c, 0x4c, true), + /* ? ? */ KEYBTDECL(0xf6, 0xd6, true), + /* ? ? */ KEYBTDECL(0xe4, 0xc4, true), + /* ' # */ KEYBTDECL(0x27, 0x23, true), + + /* y Y */ KEYBTDECL(0x79, 0x59, true), + /* x X */ KEYBTDECL(0x78, 0x58, true), + /* c C */ KEYBTDECL(0x63, 0x43, true), + /* v V */ KEYBTDECL(0x76, 0x56, true), + /* b B */ KEYBTDECL(0x62, 0x42, true), + /* n N */ KEYBTDECL(0x6e, 0x4e, true), + /* m M */ KEYBTDECL(0x6d, 0x4d, true), + /* , ; */ KEYBTDECL(0x2c, 0x3b, true), + /* . : */ KEYBTDECL(0x2e, 0x3a, true), + /* _ - */ KEYBTDECL(0x5f, 0x2d, false)}; diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp index d537f308..846d9d89 100644 --- a/src/gui/UBKeyboardPalette.cpp +++ b/src/gui/UBKeyboardPalette.cpp @@ -38,11 +38,16 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent) setGrip(false); capsLock = false; + shift = false; languagePopupActive = false; keyboardActive = false; + nSpecialModifierIndex = 0; + specialModifier = 0; btnWidth = btnHeight = 16; strSize = "16x16"; currBtnImages = new BTNImages("16", btnWidth, btnHeight); + storage = NULL; + buttons = new UBKeyButton*[47]; for (int i=0; i<47; i++) @@ -77,7 +82,7 @@ void UBKeyboardPalette::init() //------------------------------// - UBPlatformUtils::setWindowNonActivableFlag(this, true); + UBPlatformUtils::setWindowNonActivableFlag(this, true); } void UBKeyboardPalette::showKeyboard(bool show) @@ -143,6 +148,8 @@ UBKeyboardPalette::~UBKeyboardPalette() delete currBtnImages; currBtnImages = NULL; } + + onActivated(false); } QSize UBKeyboardPalette::sizeHint () const @@ -302,8 +309,10 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event) //------------------- // // Row 3 Stub -// ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth, btnHeight); -// offX += btnWidth; + + // button Enter + ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 1, btnHeight); + offX += btnWidth*1; // buttons [a]..[\] for (int i = 0; i < 12; i++) @@ -313,8 +322,8 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event) } // button Enter - ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 3, btnHeight); - offX += btnWidth*3; + ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 2, btnHeight); + offX += btnWidth*2; //------------------------------------------------ // set geometry (position) for row 4 @@ -353,6 +362,11 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event) //------------------------------------------------ } +void UBKeyboardPalette::onDeactivated() +{ + onActivated(false); +} + //-----------------------------------------------------------------------// // BTNImages Class @@ -415,6 +429,11 @@ UBKeyboardButton::~UBKeyboardButton() } } +bool UBKeyboardButton::isPressed() +{ + return bPressed; +} + void UBKeyboardButton::paintEvent(QPaintEvent*) { @@ -437,7 +456,7 @@ void UBKeyboardButton::paintEvent(QPaintEvent*) //-------------------------- - if (bPressed) + if (isPressed()) { painter.drawImage( 0,0, m_parent->currBtnImages->m_btnLeftActive, 0,0, m_parent->currBtnImages->m_btnLeftActive.width(), m_parent->currBtnImages->m_btnLeftActive.height() ); painter.drawImage( QRect(m_parent->currBtnImages->m_btnLeftActive.width(), 0, width() - m_parent->currBtnImages->m_btnLeftActive.width() - m_parent->currBtnImages->m_btnRightActive.width(), height()), m_parent->currBtnImages->m_btnCenterActive ); @@ -471,7 +490,7 @@ void UBKeyboardButton::leaveEvent ( QEvent*) void UBKeyboardButton::mousePressEvent ( QMouseEvent * event) { - event->accept(); + event->accept(); bPressed = true; update(); this->onPress(); @@ -492,10 +511,55 @@ UBKeyButton::UBKeyButton(UBKeyboardPalette* parent) UBKeyButton::~UBKeyButton() {} +bool UBKeyButton::shifted() +{ + bool b = keyboard->shift; + if (keybt->capsLockSwitch && keyboard->capsLock) + b = !b; + return b; +} + void UBKeyButton::onPress() { if (keybt!=NULL) - sendUnicodeSymbol(keybt->code1, keybt->code2, capsLock()); + { + int codeIndex = keyboard->nSpecialModifierIndex * 2 + shifted(); + + if (keyboard->nSpecialModifierIndex) + { + if (keybt->codes[codeIndex].empty()) + { + sendUnicodeSymbol(keyboard->specialModifier); + sendUnicodeSymbol(keybt->codes[shifted()]); + } + else + { + sendUnicodeSymbol(keybt->codes[codeIndex]); + } + + keyboard->nSpecialModifierIndex = 0; + } + else + { + int nSpecialModifierIndex = shifted()? keybt->modifier2 : keybt->modifier1; + + if (nSpecialModifierIndex) + { + keyboard->nSpecialModifierIndex = nSpecialModifierIndex; + keyboard->specialModifier = keybt->codes[codeIndex]; + } + else + { + sendUnicodeSymbol(keybt->codes[codeIndex]); + } + } + } + + if (keyboard->shift) + { + keyboard->shift = false; + keyboard->update(); + } } void UBKeyButton::onRelease() @@ -505,7 +569,7 @@ void UBKeyButton::paintContent(QPainter& painter) { if (keybt) { - QString text(QChar(capsLock() ? keybt->symbol2 : keybt->symbol1)); + QString text(QChar(shifted() ? keybt->symbol2 : keybt->symbol1)); QRect textRect(rect().x()+2, rect().y()+2, rect().width()-4, rect().height()-4); painter.drawText(textRect, Qt::AlignCenter, text); } @@ -565,6 +629,11 @@ void UBCapsLockButton::onPress() void UBCapsLockButton::onRelease() {} +bool UBCapsLockButton::isPressed() +{ + return keyboard->capsLock; +} + void UBCapsLockButton::paintContent(QPainter& painter) { if(imgContent != NULL) @@ -576,6 +645,40 @@ void UBCapsLockButton::paintContent(QPainter& painter) painter.drawText(rect(), Qt::AlignCenter, "^"); } +UBShiftButton::UBShiftButton(UBKeyboardPalette* parent, const QString _contentImagePath) + :UBKeyboardButton(parent, _contentImagePath) +{} + +UBShiftButton::~UBShiftButton() +{} + +void UBShiftButton::onPress() +{ + keyboard->shift = !keyboard->shift; + keyboard->update(); +} + + +void UBShiftButton::onRelease() +{} + +bool UBShiftButton::isPressed() +{ + return keyboard->shift; +} + +void UBShiftButton::paintContent(QPainter& painter) +{ + if(imgContent != NULL) + { + painter.drawImage(( rect().width() - imgContent->m_btnContent.width() ) / 2, ( rect().height() - imgContent->m_btnContent.height() ) / 2, + imgContent->m_btnContent, 0,0, imgContent->m_btnContent.width(), imgContent->m_btnContent.height()); + } + else + painter.drawText(rect(), Qt::AlignCenter, "^"); +} + + UBLocaleButton::UBLocaleButton(UBKeyboardPalette* parent) :UBKeyboardButton(parent) diff --git a/src/gui/UBKeyboardPalette.h b/src/gui/UBKeyboardPalette.h index c7077fe2..3b717fc8 100644 --- a/src/gui/UBKeyboardPalette.h +++ b/src/gui/UBKeyboardPalette.h @@ -64,7 +64,9 @@ class UBKeyboardPalette : public UBActionPalette friend class UBKeyboardButton; friend class UBCapsLockButton; +friend class UBShiftButton; friend class UBLocaleButton; +friend class UBKeyButton; public: UBKeyboardPalette(QWidget *parent); @@ -97,10 +99,14 @@ private slots: protected: bool capsLock; + bool shift; int nCurrentLocale; int nLocalesCount; UBKeyboardLocale** locales; + int nSpecialModifierIndex; + KEYCODE specialModifier; + QString strSize; int btnWidth; int btnHeight; @@ -113,7 +119,7 @@ protected: virtual void paintEvent(QPaintEvent *event); virtual void moveEvent ( QMoveEvent * event ); - void sendKeyEvent(const KEYBT& keybt); + void sendKeyEvent(KEYCODE keyCode); void setLocale(int nLocale); @@ -170,11 +176,11 @@ protected: virtual void onRelease() = 0; virtual void paintContent(QPainter& painter) = 0; - bool capsLock(){return keyboard->capsLock;} + virtual bool isPressed(); UBKeyboardPalette* keyboard; - void sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift); + void sendUnicodeSymbol(KEYCODE keycode); void sendControlSymbol(int nSymbol); private: @@ -197,6 +203,7 @@ public: virtual void paintContent(QPainter& painter); private: + bool shifted(); const KEYBT* keybt; }; @@ -229,8 +236,28 @@ public: virtual void onPress(); virtual void onRelease(); virtual void paintContent(QPainter& painter); + +protected: + virtual bool isPressed(); +}; + +class UBShiftButton : public UBKeyboardButton +{ + Q_OBJECT + +public: + UBShiftButton(UBKeyboardPalette* parent, const QString _contentImagePath); + ~UBShiftButton(); + + virtual void onPress(); + virtual void onRelease(); + virtual void paintContent(QPainter& painter); + +protected: + virtual bool isPressed(); }; + class UBLocaleButton : public UBKeyboardButton { Q_OBJECT diff --git a/src/gui/UBKeyboardPalette_linux.cpp b/src/gui/UBKeyboardPalette_linux.cpp index dd37d0b9..2febf9f5 100644 --- a/src/gui/UBKeyboardPalette_linux.cpp +++ b/src/gui/UBKeyboardPalette_linux.cpp @@ -70,22 +70,59 @@ void x11SendKey(Display *display, int keyCode, int modifiers) // Send a fake key release event to the window. event = createKeyEvent(display, winFocus, winRoot, false, keyCode, modifiers); XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); + } -void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) +void traceKeyCodes() { - unsigned int nSymbol = shift ? nSymbol2 : nSymbol1; + Display *display = XOpenDisplay(0); + if(display == NULL) + return; + + int min_keycodes, max_keycodes, byte_per_code; + + XDisplayKeycodes(display, &min_keycodes, &max_keycodes); + KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes, + max_keycodes - min_keycodes, &byte_per_code); + + qDebug() << "Codes table, min_keycodes: " << min_keycodes << ", max_keycodes: " + << max_keycodes << ", bytes_per_code:" << byte_per_code; + for(int i=0; imin_keycodes , modifier); } XCloseDisplay(display); @@ -111,16 +148,17 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol) void UBKeyboardPalette::createCtrlButtons() { - ctrlButtons = new UBKeyboardButton*[8]; - - ctrlButtons[0] = new UBCntrlButton(this, "<-", XK_BackSpace); - ctrlButtons[1] = new UBCntrlButton(this, "<->", XK_Tab); - ctrlButtons[2] = new UBCntrlButton(this, tr("Enter"), XK_Return); - ctrlButtons[3] = new UBCapsLockButton(this, "capslock"); - ctrlButtons[4] = new UBCapsLockButton(this, "capslock"); - ctrlButtons[5] = new UBLocaleButton(this); - ctrlButtons[6] = new UBCntrlButton(this, "", XK_space); - ctrlButtons[7] = new UBLocaleButton(this); + ctrlButtons = new UBKeyboardButton*[9]; + + ctrlButtons[0] = new UBCntrlButton(this, XK_BackSpace, "backspace"); + ctrlButtons[1] = new UBCntrlButton(this, XK_Tab, "tab"); + ctrlButtons[2] = new UBCapsLockButton(this, "capslock"); + ctrlButtons[3] = new UBCntrlButton(this, tr("Enter"), XK_Return); + ctrlButtons[4] = new UBShiftButton(this, "shift"); + ctrlButtons[5] = new UBShiftButton(this, "shift"); + ctrlButtons[6] = new UBLocaleButton(this); + ctrlButtons[7] = new UBCntrlButton(this, "", XK_space); + ctrlButtons[8] = new UBLocaleButton(this); } @@ -128,90 +166,114 @@ void UBKeyboardPalette::onActivated(bool activated) { if (activated) { + if (storage) + { + qDebug() << "Keybard already activated...."; + return; + } + Display *display = XOpenDisplay(0); if(display == NULL) return; XDisplayKeycodes(display, &this->min_keycodes, &this->max_keycodes); KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes, - max_keycodes - min_keycodes, &this->byte_per_code); + max_keycodes - min_keycodes, &byte_per_code); storage = keySyms; XCloseDisplay(display); + qDebug() << "------------ ORIGINAL --------------------------------------------------"; + traceKeyCodes(); + onLocaleChanged(locales[nCurrentLocale]); + + qDebug() << "------------ CUSTOM ------------------------------------------------"; + traceKeyCodes(); + qDebug() << "----------------------------------------------------------------------"; + + } else { Display *display = XOpenDisplay(0); if(display == NULL) - return; + { + qDebug() << "Keybard not activated...."; + return; + } KeySym* keySyms = (KeySym*)storage; if (keySyms!=NULL) { + qDebug() << "Default key table restored....."; XChangeKeyboardMapping(display, min_keycodes, byte_per_code, keySyms, max_keycodes - min_keycodes); XFree(keySyms); - } + storage = NULL; + } XCloseDisplay(display); } - } -void UBKeyboardPalette::onDeactivated() + +void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale) { Display *display = XOpenDisplay(0); - if(display == NULL) return; - KeySym* keySyms = (KeySym*)storage; - if (keySyms!=NULL) { - XChangeKeyboardMapping(display, min_keycodes, byte_per_code, - keySyms, max_keycodes - min_keycodes); - } - XCloseDisplay(display); -} + int byte_per_code; + KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes, + max_keycodes - min_keycodes, &byte_per_code); -void setSymbolsFromButton(Display *display, - const UBKeyboardLocale& locale, - int byte_per_code, - int nFromSymbol, - int nFromButton, - int count) -{ - KeySym* keySyms = new KeySym[count * byte_per_code]; - for(int i = 0; i < count; i++) + for(int i=0; icode1; - - keySyms[byte_per_code * i + 1] = - keySyms[byte_per_code * i + 3] = locale[nFromButton + i]->code2; - - for(int j=4; jcodes[j]; + if (!kc.empty()) + { + if (kc.modifier <= 5) + keySyms[kc.code * byte_per_code + kc.modifier] = kc.symbol; + + } + } } - XChangeKeyboardMapping(display, nFromSymbol, byte_per_code, keySyms, count); - delete [] keySyms; -} + //Now look for modifiers > 5 and reassign them to free places + for(int i=0; icodes[j]; + if (!kc.empty()) + { + if (kc.modifier > 5) + { + for(int i1=0; i1 #include -void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) +void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode) { - unsigned int nSymbol = (shift)? nSymbol2 : nSymbol1; - - if (shift) + if (keycode.modifier) CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, true)); - CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, nSymbol, true)); - CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, nSymbol, false)); - if (shift) + CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, keycode.code, true)); + CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, keycode.code, false)); + if (keycode.modifier) CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, false)); } @@ -46,16 +44,17 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol) void UBKeyboardPalette::createCtrlButtons() { - ctrlButtons = new UBKeyboardButton*[7]; + ctrlButtons = new UBKeyboardButton*[9]; - ctrlButtons[0] = new UBCntrlButton(this, "<-", 51); - ctrlButtons[1] = new UBCntrlButton(this, "<->", 48); - ctrlButtons[2] = new UBCntrlButton(this, tr("Enter"), 76); - ctrlButtons[3] = new UBCapsLockButton(this, "capslock"); - ctrlButtons[4] = new UBCapsLockButton(this, "capslock"); - ctrlButtons[5] = new UBLocaleButton(this); - ctrlButtons[6] = new UBCntrlButton(this, "", 49); - ctrlButtons[7] = new UBLocaleButton(this); + ctrlButtons[0] = new UBCntrlButton(this, 51, "backspace"); + ctrlButtons[1] = new UBCntrlButton(this, 48, "tab"); + ctrlButtons[2] = new UBCapsLockButton(this, "capslock"); + ctrlButtons[3] = new UBCntrlButton(this, tr("Enter"), 76); + ctrlButtons[4] = new UBShiftButton(this, "shift"); + ctrlButtons[5] = new UBShiftButton(this, "shift"); + ctrlButtons[6] = new UBLocaleButton(this); + ctrlButtons[7] = new UBCntrlButton(this, "", 49); + ctrlButtons[8] = new UBLocaleButton(this); } void SetMacLocaleByIdentifier(const QString& id) @@ -102,10 +101,7 @@ void UBKeyboardPalette::onActivated(bool activated) SetMacLocaleByIdentifier(activeLocale); } } -void UBKeyboardPalette::onDeactivated() -{ - SetMacLocaleByIdentifier(activeLocale); -} + void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale) { SetMacLocaleByIdentifier(locale->id); diff --git a/src/gui/UBKeyboardPalette_win.cpp b/src/gui/UBKeyboardPalette_win.cpp index e14ec220..495175c8 100644 --- a/src/gui/UBKeyboardPalette_win.cpp +++ b/src/gui/UBKeyboardPalette_win.cpp @@ -8,21 +8,19 @@ #include "core/memcheck.h" -void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) +void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode) { - unsigned int nSymbol = shift? nSymbol2 : nSymbol1; - INPUT input[2]; input[0].type = INPUT_KEYBOARD; input[0].ki.wVk = 0; - input[0].ki.wScan = nSymbol; + input[0].ki.wScan = keycode.symbol; input[0].ki.dwFlags = KEYEVENTF_UNICODE; input[0].ki.time = 0; input[0].ki.dwExtraInfo = 0; input[1].type = INPUT_KEYBOARD; input[1].ki.wVk = 0; - input[1].ki.wScan = nSymbol; + input[1].ki.wScan = keycode.symbol; input[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; input[1].ki.time = 0; input[1].ki.dwExtraInfo = 0; @@ -57,11 +55,10 @@ void UBKeyboardPalette::createCtrlButtons() ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x08, "backspace");// Backspace ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x09, "tab"); // Tab -// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 2 Stub -// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 3 Stub + ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Shift ctrlButtons[ctrlID++] = new UBCntrlButton(this, tr("Enter"), 0x0d); // Enter - ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock - ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock + ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift"); // Shift + ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift"); // Shift ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch ctrlButtons[ctrlID++] = new UBCntrlButton(this, "", 0x20); // Space ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch @@ -69,10 +66,6 @@ void UBKeyboardPalette::createCtrlButtons() void UBKeyboardPalette::onActivated(bool) { -} -void UBKeyboardPalette::onDeactivated() -{ - } void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* ) {} From 95012f47640d8facf8ae4e8cde8b74b3322f6e2f Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 8 Jun 2012 17:44:16 +0300 Subject: [PATCH 2/2] Virtual Keyboard: removed debug messages on linux --- src/gui/UBKeyboardPalette_linux.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/gui/UBKeyboardPalette_linux.cpp b/src/gui/UBKeyboardPalette_linux.cpp index 2febf9f5..7dd1af4d 100644 --- a/src/gui/UBKeyboardPalette_linux.cpp +++ b/src/gui/UBKeyboardPalette_linux.cpp @@ -73,6 +73,7 @@ void x11SendKey(Display *display, int keyCode, int modifiers) } +/* void traceKeyCodes() { Display *display = XOpenDisplay(0); @@ -102,6 +103,7 @@ void traceKeyCodes() XCloseDisplay(display); } +*/ void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode) @@ -184,16 +186,8 @@ void UBKeyboardPalette::onActivated(bool activated) XCloseDisplay(display); - qDebug() << "------------ ORIGINAL --------------------------------------------------"; - traceKeyCodes(); - onLocaleChanged(locales[nCurrentLocale]); - qDebug() << "------------ CUSTOM ------------------------------------------------"; - traceKeyCodes(); - qDebug() << "----------------------------------------------------------------------"; - - } else {