fix bug that DEL key is incorrect in key_press/key_release(#259)

This commit is contained in:
cnjinhao
2017-09-22 15:47:12 +08:00
parent f14fc9bf6d
commit bb47cdc6c9
4 changed files with 22 additions and 7 deletions

View File

@@ -775,6 +775,19 @@ namespace detail
if (thrd) thrd->event_window = prev_event_wd;
}
//Translate OS Virtual-Key into ASCII code
wchar_t translate_virtual_key(WPARAM vkey)
{
switch (vkey)
{
case VK_DELETE:
return 127;
case VK_DECIMAL:
return 46;
}
return static_cast<wchar_t>(vkey);
}
LRESULT CALLBACK Bedrock_WIN32_WindowProc(HWND root_window, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT window_proc_value = 0;
@@ -1436,7 +1449,7 @@ namespace detail
arg.evt_code = event_code::key_press;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.ignore = false;
arg.key = static_cast<wchar_t>(wParam);
arg.key = translate_virtual_key(wParam);
brock.get_key_state(arg);
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
@@ -1522,7 +1535,7 @@ namespace detail
arg_keyboard arg;
arg.evt_code = event_code::key_release;
arg.window_handle = reinterpret_cast<window>(msgwnd);
arg.key = static_cast<wchar_t>(wParam);
arg.key = translate_virtual_key(wParam);
brock.get_key_state(arg);
arg.ignore = false;
brock.emit(event_code::key_release, msgwnd, arg, true, &context);