diff --git a/src/hook/hooks.cpp b/src/hook/hooks.cpp index b0fe7d1..6ff68df 100644 --- a/src/hook/hooks.cpp +++ b/src/hook/hooks.cpp @@ -378,10 +378,8 @@ namespace Hooks { // main handler for input from keyboard SETUP_ORIG_FUNC(standardstringentry); int __fastcall HOOK(standardstringentry)(std::string& str, int maxlen, unsigned int flag, - std::set& events, __int64 a5) + std::set& events, uint16_t* utf) { - return ORIGINAL(standardstringentry)(str, maxlen, flag, events, a5); - char entry = char(1); const auto shift = Config::Keybinding::shift; @@ -434,6 +432,14 @@ namespace Hooks { } } + // patch after 50.09 with sdl2 + // change only if utf code is in cyrillic zone, latin have small codes + if (*utf > 127 && entry != 0) { + if (cyrillic_utf8_to_cp1251.find(*utf) != cyrillic_utf8_to_cp1251.end()) { + entry = char(cyrillic_utf8_to_cp1251.at(*utf)); + } + } + if (entry != 1) { if (entry == 0) { if (str.size() > 0) { @@ -461,12 +467,6 @@ namespace Hooks { } return 0; - - logger::debug("entry str {} maxlen {} flag {} events size {} a5 {}", str, maxlen, flag, events.size(), a5); - logger::debug("entry {}", entry); - for (auto event : events) { - logger::debug("event {}", event); - } } SETUP_ORIG_FUNC(simplify_string); diff --git a/src/hook/hooks.h b/src/hook/hooks.h index 4a4e1e8..3f7199b 100644 --- a/src/hook/hooks.h +++ b/src/hook/hooks.h @@ -169,7 +169,7 @@ namespace Hooks { // search typedef int(__fastcall* standardstringentry)(std::string& str, int maxlen, unsigned int flag, - std::set& events, __int64 a5); + std::set& events, uint16_t* utf); typedef void(__fastcall* upper_case_string)(std::string& str); typedef void(__fastcall* simplify_string)(std::string& str); typedef void(__fastcall* lower_case_string)(std::string& str); diff --git a/src/hook/keybindings.h b/src/hook/keybindings.h index 3900eba..fb7bc8e 100644 --- a/src/hook/keybindings.h +++ b/src/hook/keybindings.h @@ -268,3 +268,17 @@ enum InterfaceKeyType INTERFACEKEY_KEYBINDING_COMPLETE, INTERFACEKEYNUM, }; + +static std::map cyrillic_utf8_to_cp1251{ + { 37072, 192 }, { 37328, 193 }, { 37584, 194 }, { 37840, 195 }, { 38096, 196 }, { 38352, 197 }, { 38608, 198 }, + { 38864, 199 }, { 39120, 200 }, { 39376, 201 }, { 39632, 202 }, { 39888, 203 }, { 40144, 204 }, { 40400, 205 }, + { 40656, 206 }, { 40912, 207 }, { 41168, 208 }, { 41424, 209 }, { 41680, 210 }, { 41936, 211 }, { 42192, 212 }, + { 42448, 213 }, { 42704, 214 }, { 42960, 215 }, { 43216, 216 }, { 43472, 217 }, { 43728, 218 }, { 43984, 219 }, + { 44240, 220 }, { 44496, 221 }, { 44752, 222 }, { 45008, 223 }, { 45264, 224 }, { 45520, 225 }, { 45776, 226 }, + { 46032, 227 }, { 46288, 228 }, { 46544, 229 }, { 46800, 230 }, { 47056, 231 }, { 47312, 232 }, { 47568, 233 }, + { 47824, 234 }, { 48080, 235 }, { 48336, 236 }, { 48592, 237 }, { 48848, 238 }, { 49104, 239 }, { 32977, 240 }, + { 33233, 241 }, { 33489, 242 }, { 33745, 243 }, { 34001, 244 }, { 34257, 245 }, { 34513, 246 }, { 34769, 247 }, + { 35025, 248 }, { 35281, 249 }, { 35537, 250 }, { 35793, 251 }, { 36049, 252 }, { 36305, 253 }, { 36561, 254 }, + { 36817, 255 }, { 33232, 168 }, { 37329, 184 }, { 34000, 170 }, { 38097, 186 }, { 34768, 175 }, { 38865, 191 }, + { 34512, 178 }, { 38609, 179 }, { 37074, 165 }, { 37330, 180 }, { 36560, 161 }, { 40657, 162 } +}; \ No newline at end of file