added some kbm stuff
This commit is contained in:
1 parent
40d5709317
commit
b6088fd079
4 files changed
+70
No files matched your search
@@ -254,11 +254,26 @@ bool C_4JInput::HasChar() const
|
|||||||
return InternalKeyboard.HasChar();
|
return InternalKeyboard.HasChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetCharCount() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetCharCount();
|
||||||
|
}
|
||||||
|
|
||||||
wchar_t C_4JInput::GetChar(int index) const
|
wchar_t C_4JInput::GetChar(int index) const
|
||||||
{
|
{
|
||||||
return InternalKeyboard.GetChar(index);
|
return InternalKeyboard.GetChar(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetClipboardText(wchar_t *outText, int outCapacity) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetClipboardText(outText, outCapacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::SetClipboardText(const wchar_t *text) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.SetClipboardText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void C_4JInput::OnMouseMove(int x, int y)
|
void C_4JInput::OnMouseMove(int x, int y)
|
||||||
{
|
{
|
||||||
InternalKeyboard.OnMouseMove(x, y);
|
InternalKeyboard.OnMouseMove(x, y);
|
||||||
|
|||||||
@@ -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
|
bool CKeyboard::IsKeyDown(int vkCode) const
|
||||||
{
|
{
|
||||||
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ public:
|
|||||||
int GetCharCount() const { return m_charCount; }
|
int GetCharCount() const { return m_charCount; }
|
||||||
wchar_t GetChar(int index) const { return (index >= 0 && index < m_charCount) ? m_charBuffer[index] : 0; }
|
wchar_t GetChar(int index) const { return (index >= 0 && index < m_charCount) ? m_charBuffer[index] : 0; }
|
||||||
|
|
||||||
|
int GetClipboardText(wchar_t *outText, int outCapacity) const;
|
||||||
|
bool SetClipboardText(const wchar_t *text) const;
|
||||||
|
|
||||||
void SetMouseCaptured(bool captured);
|
void SetMouseCaptured(bool captured);
|
||||||
void SetWindowFocused(bool focused);
|
void SetWindowFocused(bool focused);
|
||||||
bool IsMouseCaptured() const { return m_mouseCaptured; }
|
bool IsMouseCaptured() const { return m_mouseCaptured; }
|
||||||
|
|||||||
@@ -169,6 +169,9 @@ public:
|
|||||||
int GetCharCount() const;
|
int GetCharCount() const;
|
||||||
wchar_t GetChar(int index) const;
|
wchar_t GetChar(int index) const;
|
||||||
|
|
||||||
|
int GetClipboardText(wchar_t *outText, int outCapacity) const;
|
||||||
|
bool SetClipboardText(const wchar_t *text) const;
|
||||||
|
|
||||||
void SetMouseCaptured(bool captured);
|
void SetMouseCaptured(bool captured);
|
||||||
void SetWindowFocused(bool focused);
|
void SetWindowFocused(bool focused);
|
||||||
bool IsMouseCaptured() const;
|
bool IsMouseCaptured() const;
|
||||||
|
|||||||
Reference in new issue
Block a user