#include "4J_Profile.h" #include "INP_Keyboard.h" CKeyboard::CKeyboard() { bActive = false; pwchResult = L""; } void CKeyboard::Tick(void) { //str1k3r - decomp is (bActive && KeyboardOverlap->InternalLow != ERROR_IO_PENDING) but XHasOverlappedIoCompleted does the same thing... if (bActive && XHasOverlappedIoCompleted(&KeyboardOverlap)) { 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; } } switch (eMode) { //str1k3r - look at xam.h for the modes case C_4JInput::EKeyboardMode_Numeric: keyboardMode = VKBD_LATIN_NUMERIC; break; case C_4JInput::EKeyboardMode_Password: keyboardMode = VKBD_LATIN_PASSWORD; break; //str1k3r - Alphabet and Full need multi lang support case C_4JInput::EKeyboardMode_Alphabet: keyboardMode = VKBD_LATIN_ALPHABET; break; case C_4JInput::EKeyboardMode_Full: keyboardMode = VKBD_LATIN_FULL; break; case C_4JInput::EKeyboardMode_Alphabet_Extended: keyboardMode = VKBD_LATIN_EXTENDED; break; case C_4JInput::EKeyboardMode_IP_Address: keyboardMode = VKBD_LATIN_IP_ADDRESS; break; case C_4JInput::EKeyboardMode_Phone: keyboardMode = VKBD_LATIN_PHONE; break; case C_4JInput::EKeyboardMode_Email: keyboardMode = VKBD_LATIN_EMAIL; break; default: keyboardMode = VKBD_DEFAULT; break; } ZeroMemory(&KeyboardOverlap, sizeof(XOVERLAPPED)); for (;;) { DWORD result = XShowKeyboardUI(LockedProfile, keyboardMode, 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 3 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, L"", uiMaxChars, Func, lpParam, eMode); } //str1k3r - heh i destroyed your keyboard void CKeyboard::DestroyKeyboard() { if (!XHasOverlappedIoCompleted(&KeyboardOverlap)) { XCancelOverlapped(&KeyboardOverlap); bActive = false; } } void CKeyboard::GetText(uint16_t *UTF16String) { wcsncpy_s(reinterpret_cast(UTF16String), 65, pwchResult, 64); }