Fix UTF-16 character input pair events

develop
kaetemi 4 years ago
parent be60cf8978
commit 91bceae902

@ -36,7 +36,7 @@ namespace NLMISC {
class CWinEventEmitter : public IEventEmitter
{
public:
CWinEventEmitter () : _MouseEventsEnabled(true), _KeyboardEventsEnabled(true), _IMEEventsEnabled(true)
CWinEventEmitter () : _Utf16Pair(0), _MouseEventsEnabled(true), _KeyboardEventsEnabled(true), _IMEEventsEnabled(true)
{
_HWnd=NULL;
resetButtonFlagState ();
@ -106,6 +106,7 @@ public:
private:
CWinEventServer _InternalServer;
HWND _HWnd;
wchar_t _Utf16Pair;
public:
// private: may need to be in sync with direct input flags however...
bool _CtrlButton;

@ -24,6 +24,7 @@
#include "nel/misc/event_emitter.h"
#include "nel/misc/win_event_emitter.h"
#include "nel/misc/event_server.h"
#include "nel/misc/utf_string_view.h"
#ifdef NL_OS_WINDOWS
#include <windowsx.h>
@ -177,10 +178,28 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA
{
//if (wParam < KeyCount)
//nlinfo("WM_CHAR with %u", wParam);
#ifndef WM_UNICHAR
// FIXME: Combine UTF-16 pairs
#endif
server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
wchar_t c = (wchar_t)wParam;
if ((c & 0xFC00) == 0xD800)
{
_Utf16Pair = c;
}
else if (_Utf16Pair && (c & 0xFC00) == 0xDC00)
{
wchar_t cc[] = { _Utf16Pair, c, 0 };
_Utf16Pair = 0;
CUtfStringView cv = CUtfStringView(cc);
for (CUtfStringView::iterator it(cv.begin()), end(cv.end()); it != end; ++it)
server->postEvent(new CEventChar(*it, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
}
else
{
if (_Utf16Pair)
{
server->postEvent(new CEventChar(_Utf16Pair, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
_Utf16Pair = 0;
}
server->postEvent(new CEventChar(c, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
}
}
break;
/*case WM_IME_CHAR:

Loading…
Cancel
Save