Fixed Win32 keyboard input.
This commit is contained in:
parent
01a21032a5
commit
6522994a1f
@ -383,7 +383,7 @@ namespace ehs
|
||||
|
||||
rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
|
||||
rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
|
||||
rid[0].dwFlags = RIDEV_INPUTSINK;
|
||||
rid[0].dwFlags = 0;
|
||||
rid[0].hwndTarget = hdl;
|
||||
|
||||
rid[1].usUsagePage = HID_USAGE_PAGE_GENERIC;
|
||||
@ -703,11 +703,118 @@ namespace ehs
|
||||
|
||||
Serializer<UInt_64> Window::GetClipboard()
|
||||
{
|
||||
if (!OpenClipboard(hdl))
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to open Clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
||||
if (!hData)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to get clipboard handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!CloseClipboard())
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Char_8* text = (Char_8 *)GlobalLock(hData);
|
||||
if (!text)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to get clipboard data with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
Serializer<UInt_64> data(Endianness::LE, (Byte *)text, Str_8::Len(text));
|
||||
|
||||
if (!GlobalUnlock(hData))
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to free clipboard data with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
if (!CloseClipboard())
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Window::SetClipboard(Serializer<UInt_64> data)
|
||||
{
|
||||
if (!OpenClipboard(hdl))
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to open Clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EmptyClipboard())
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to empty clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!CloseClipboard())
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, data.Size());
|
||||
if (!hGlob)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to allocate clipboard data with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!CloseClipboard())
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Byte* result = (Byte *)GlobalLock(hGlob);
|
||||
if (!result)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to lock data with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
GlobalFree(hGlob);
|
||||
|
||||
if (!CloseClipboard())
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Util::Copy(result, &data[0], data.Size());
|
||||
|
||||
GlobalUnlock(hGlob);
|
||||
|
||||
HANDLE hData = SetClipboardData(CF_TEXT, hGlob);
|
||||
if (!hData)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to get clipboard handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
GlobalFree(hGlob);
|
||||
|
||||
if (!CloseClipboard())
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CloseClipboard())
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to close clipboard with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
void Window::SetCursorImg(CursorImg img)
|
||||
|
@ -268,23 +268,23 @@ namespace ehs
|
||||
case 71:
|
||||
return Keyboard::F13;
|
||||
case 72:
|
||||
return Keyboard::F14;
|
||||
return Keyboard::Up;
|
||||
case 73:
|
||||
return Keyboard::F15;
|
||||
case 74:
|
||||
return Keyboard::F16;
|
||||
case 75:
|
||||
return Keyboard::F17;
|
||||
return Keyboard::Left;
|
||||
case 76:
|
||||
return Keyboard::F18;
|
||||
case 77:
|
||||
return Keyboard::F19;
|
||||
return Keyboard::Right;
|
||||
case 78:
|
||||
return Keyboard::F20;
|
||||
case 79:
|
||||
return Keyboard::F21;
|
||||
case 80:
|
||||
return Keyboard::F22;
|
||||
return Keyboard::Down;
|
||||
case 81:
|
||||
return Keyboard::F23;
|
||||
case 82:
|
||||
|
Loading…
Reference in New Issue
Block a user