71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
#include "4J_Profile.h"
|
|
#include "INP_Keyboard.h"
|
|
|
|
CKeyboard::CKeyboard()
|
|
{
|
|
bActive = false;
|
|
pwchResult = L"";
|
|
}
|
|
|
|
void CKeyboard::Tick(void)
|
|
{
|
|
if (bActive && KeyboardOverlap.InternalLow != ERROR_IO_PENDING)
|
|
{
|
|
if(Func != NULL) Func(lpParam, KeyboardOverlap.dwExtendedError == 0);
|
|
bActive = false;
|
|
}
|
|
}
|
|
|
|
C_4JInput::EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR uiTitle, LPCWSTR uiText, LPCWSTR uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode)
|
|
{
|
|
if (bActive)
|
|
return C_4JInput::EKeyboard_Cancelled;
|
|
|
|
this->iPad = (int)dwPad;
|
|
this->pwchResult = pwchResult;
|
|
this->uiMaxChars = uiMaxChars;
|
|
this->Func = Func;
|
|
this->lpParam = lpParam;
|
|
|
|
int LockedProfile = this->iPad;
|
|
if (LockedProfile == -1)
|
|
{
|
|
LockedProfile = ProfileManager.GetLockedProfile();
|
|
if (LockedProfile == -1)
|
|
{
|
|
LockedProfile = ProfileManager.GetLockedProfile();
|
|
if (LockedProfile == -1)
|
|
return C_4JInput::EKeyboard_Cancelled;
|
|
}
|
|
}
|
|
|
|
ZeroMemory(&KeyboardOverlap, sizeof(XOVERLAPPED));
|
|
|
|
for (;;)
|
|
{
|
|
DWORD result = XShowKeyboardUI(LockedProfile, 0, uiText, uiTitle, uiDesc, this->pwchResult, this->uiMaxChars, &KeyboardOverlap);
|
|
if (result == ERROR_IO_PENDING)
|
|
break;
|
|
if (result != ERROR_ACCESS_DENIED)
|
|
return C_4JInput::EKeyboard_Cancelled;
|
|
Sleep(250);
|
|
}
|
|
|
|
bActive = true;
|
|
return eState;
|
|
}
|
|
|
|
//str1k3r - These 2 only exist cause of iggy
|
|
C_4JInput::EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR uiTitle, LPCWSTR uiText, LPCWSTR uiDesc, DWORD dwPad, UINT uiMaxChars, int(*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode)
|
|
{
|
|
return RequestKeyboard(uiTitle, uiText, uiDesc, dwPad, pwchResult, uiMaxChars, Func, lpParam, eMode);
|
|
}
|
|
|
|
void CKeyboard::GetText(uint16_t *UTF16String)
|
|
{
|
|
//uint16_t *keyString;
|
|
//for (unsigned int index = 0; keyString[index] && index < 0x200; index++)
|
|
//{
|
|
// UTF16String[index] = keyString[index];
|
|
//}
|
|
} |