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

@ -24,6 +24,7 @@
#include "nel/misc/event_emitter.h" #include "nel/misc/event_emitter.h"
#include "nel/misc/win_event_emitter.h" #include "nel/misc/win_event_emitter.h"
#include "nel/misc/event_server.h" #include "nel/misc/event_server.h"
#include "nel/misc/utf_string_view.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
#include <windowsx.h> #include <windowsx.h>
@ -177,10 +178,28 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA
{ {
//if (wParam < KeyCount) //if (wParam < KeyCount)
//nlinfo("WM_CHAR with %u", wParam); //nlinfo("WM_CHAR with %u", wParam);
#ifndef WM_UNICHAR wchar_t c = (wchar_t)wParam;
// FIXME: Combine UTF-16 pairs if ((c & 0xFC00) == 0xD800)
#endif {
server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); _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; break;
/*case WM_IME_CHAR: /*case WM_IME_CHAR:

Loading…
Cancel
Save