added some kbm stuff
This commit is contained in:
1 parent
40d5709317
commit
3943ffd1f4
4 files changed
+77
No files matched your search
@@ -103,6 +103,55 @@ void CKeyboard::OnChar(wchar_t ch)
|
||||
}
|
||||
}
|
||||
|
||||
int CKeyboard::GetClipboardText(wchar_t *outText, int outCapacity) const
|
||||
{
|
||||
if (!outText || outCapacity <= 0)
|
||||
return 0;
|
||||
outText[0] = 0;
|
||||
if (!OpenClipboard(g_hWnd))
|
||||
return 0;
|
||||
int copied = 0;
|
||||
HANDLE h = GetClipboardData(CF_UNICODETEXT);
|
||||
if (h)
|
||||
{
|
||||
const wchar_t *src = (const wchar_t *)GlobalLock(h);
|
||||
if (src)
|
||||
{
|
||||
while (src[copied] && copied + 1 < outCapacity)
|
||||
{
|
||||
outText[copied] = src[copied];
|
||||
++copied;
|
||||
}
|
||||
outText[copied] = 0;
|
||||
GlobalUnlock(h);
|
||||
}
|
||||
}
|
||||
CloseClipboard();
|
||||
return copied;
|
||||
}
|
||||
|
||||
bool CKeyboard::SetClipboardText(const wchar_t *text) const
|
||||
{
|
||||
if (!text)
|
||||
return false;
|
||||
size_t len = wcslen(text);
|
||||
if (!OpenClipboard(g_hWnd))
|
||||
return false;
|
||||
EmptyClipboard();
|
||||
bool ok = false;
|
||||
HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t));
|
||||
if (h)
|
||||
{
|
||||
memcpy(GlobalLock(h), text, (len + 1) * sizeof(wchar_t));
|
||||
GlobalUnlock(h);
|
||||
ok = (SetClipboardData(CF_UNICODETEXT, h) != NULL);
|
||||
if (!ok)
|
||||
GlobalFree(h);
|
||||
}
|
||||
CloseClipboard();
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool CKeyboard::IsKeyDown(int vkCode) const
|
||||
{
|
||||
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||
@@ -215,6 +264,8 @@ void CKeyboard::SetMouseCaptured(bool grabbed)
|
||||
}
|
||||
else if (!grabbed && g_hWnd)
|
||||
{
|
||||
// Show the system cursor whenever the mouse is free so it can be used as the UI pointer;
|
||||
// the game's flash/custom cursors are hidden on Windows64 while the OS mouse is driving.
|
||||
while (ShowCursor(TRUE) < 0) {}
|
||||
ClipCursor(nullptr);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user