mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
rawinput: use UTF-8 for device descriptor (#422)
## Link to GitHub Issue, if one exists n/a ## Description of change For HID device descriptor, use the "W" version of Windows API, and make sure UTF-8 is being used throughout since that's the only format IMGUI supports. Before this change, non-Latin characters would have shown up as `HID ??? ?????` for a mouse, for example. Due to the way ImGui loads fonts, only the following languages are supported: * Simplified Chinese * Cyrillic * Japanese * Korean * Thai * Vietnamese ## Testing Tested various combination of Windows UI language and non-Unicode language.
This commit is contained in:
@@ -339,4 +339,14 @@ static inline bool parse_width_height(const std::string wh, std::pair<uint32_t,
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline std::string wchar_to_u8(const wchar_t* wstr) {
|
||||
int size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
|
||||
if (size <= 1) {
|
||||
return "";
|
||||
}
|
||||
std::string out(size - 1, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, out.data(), size - 1, nullptr, nullptr);
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user