mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Ensure WM_CHAR characters are parsed as UTF16, then translated to UTF8.
This commit is contained in:
parent
1573ee0d35
commit
a4f86a541a
25
src/3rdparty/win32_src/pdcurses/wingui/pdcscrn.c
vendored
25
src/3rdparty/win32_src/pdcurses/wingui/pdcscrn.c
vendored
@ -1903,8 +1903,29 @@ static LRESULT ALIGN_STACK CALLBACK WndProc (const HWND hwnd,
|
|||||||
if( wParam == 3 && !SP->raw_inp) /* Ctrl-C hit */
|
if( wParam == 3 && !SP->raw_inp) /* Ctrl-C hit */
|
||||||
exit( 0);
|
exit( 0);
|
||||||
if( wParam != 9 || !(GetKeyState( VK_SHIFT) & 0x8000))
|
if( wParam != 9 || !(GetKeyState( VK_SHIFT) & 0x8000))
|
||||||
if( !key_already_handled || last_key_handled != (int)wParam )
|
if (!key_already_handled || last_key_handled != (int)wParam) {
|
||||||
add_key_to_queue( (int)wParam );
|
#if _UNICODE
|
||||||
|
/* if we are building against the unicode runtime, key messages
|
||||||
|
received by WM_CHAR will be UTF16 encoded; convert it to a
|
||||||
|
sequence UTF8 bytes and inject them one at a time.
|
||||||
|
see: https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-char */
|
||||||
|
wchar_t utf16[3]; /* may be a surrogate pair */
|
||||||
|
utf16[0] = LOWORD(wParam);
|
||||||
|
utf16[1] = HIWORD(wParam);
|
||||||
|
utf16[2] = 0;
|
||||||
|
unsigned char utf8[4 + 4 + 1];
|
||||||
|
int size = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, 0, 0, 0, 0);
|
||||||
|
if (size > 0 && sizeof(utf8)) {
|
||||||
|
utf8[0] = 0;
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, utf16, -1, utf8, size, 0, 0);
|
||||||
|
for (int i = 0; i < size - 1; i++) {
|
||||||
|
add_key_to_queue((int) utf8[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
add_key_to_queue((int)wParam);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
key_already_handled = FALSE;
|
key_already_handled = FALSE;
|
||||||
last_key_handled = 0;
|
last_key_handled = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user