Skip to main content

Input Method Interface

1. PGOS IME Utility Plugin

No other window could be displayed above the only single main window of the game by default. It's a limitation on Windows, and causes that the window of input method editor is invisible to the end user. PGOS IME Utility Plugin is a solution to fix this IME(TSF)'s visiblity issue in full-screen mode on Windows with an in-game rendered UMG widget.

Sample

Download PGOS IME Utility Plugin from download page

Note: A few modifications on the engine source are required to access the win32 handle encapsulated in the engine and they are marked as private in the original source.

Note: PGOS IME Utility Plugin is a standalone plugin, you can use it without any other third-party dependency.

1.1 Revise UE4 source code

1.1.1 First revision

Source File: Engine/Source/Runtime/ApplicationCore/Private/Windows/WindowsTextInputMethodSystem.cpp

Source code:

// About Line 172
// `TSFProfile.hkl` is always null in most cases, so CurrentAPI will never be assigned to TSF. remove this check
if(SUCCEEDED(TSFInputProcessorProfileManager->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &TSFProfile)) && TSFProfile.hkl && TSFProfile.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR)
{
check(TSFProfile.hkl == KeyboardLayout);
CurrentAPI = EAPI::TSF;
}
else if(::ImmGetIMEFileName(KeyboardLayout, nullptr, 0) > 0)
{
CurrentAPI = EAPI::IMM;
}

Code revised:

if(SUCCEEDED(TSFInputProcessorProfileManager->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &TSFProfile)) && TSFProfile.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR)
{
CurrentAPI = EAPI::TSF;
}
else if(::ImmGetIMEFileName(KeyboardLayout, nullptr, 0) > 0)
{
CurrentAPI = EAPI::IMM;
}

1.1.2 Second revision

Source File: Engine/Source/Runtime/ApplicationCore/Private/Windows/WindowsTextInputMethodSystem.cpp

Source code:

// About Line 425
// By default, it's impossible to use UILess mode of TSF with Activate(). It should be replaced with ActivateEx
Result = TSFThreadManager->Activate(&(TSFClientId));

Code revised:

#if !UE_EDITOR
ITfThreadMgrEx* ThreadMgrEx;
if (SUCCEEDED(TSFThreadManager->QueryInterface(IID_ITfThreadMgrEx, (void**)&ThreadMgrEx)))
{
Result = ThreadMgrEx->ActivateEx(&TSFClientId, TF_TMAE_UIELEMENTENABLEDONLY);
ThreadMgrEx->Release();
}
else
#endif
{
Result = TSFThreadManager->Activate(&(TSFClientId));
}

1.1.3 Third revision

Source File: Engine/Source/Runtime/ApplicationCore/Public/Windows/WindowsTextInputMethodSystem.h

We need to externally access these non-public members:

  1. FWindowsTextInputMethodSystem::ActiveContext
  2. struct FWindowsTextInputMethodSystem::FInternalContext

The simplest way is directly replace private with public for these members.

Source code:

private:

enum class EAPI
{
Unknown,
IMM,
TSF
} CurrentAPI;

// TSF Implementation
TComPtr<ITfInputProcessorProfiles> TSFInputProcessorProfiles;
...

Code revised:

public: 

enum class EAPI
{
Unknown,
IMM,
TSF
} CurrentAPI;

// TSF Implementation
TComPtr<ITfInputProcessorProfiles> TSFInputProcessorProfiles;
...

1.2 Customization

PGOS IME Utility Plugin uses the SWindow as the input method editor interface in non-fullscreen mode by default. The tooltip system will be the default display for the input method editor to ensure that it is displayed as the first priority, since additional interfaces can not be displayed normally in full-screen mode.

Game developers may set the input method editor interface on their own if the default setting above cannot meet the customized requirements for certain games. Developers can disable the default display, configure instances, and set the input method editor interface.

1.2.1 Disable the Default interface

You can disable the default interface by setting USE_DEFAULT_PGOS_COMPOSITION_VIEW to 0 in PgosTextInputSystem.Build.cs.

Note: PgosTextInputSystem is the module name of PGOS IME Utility Plugin

1.2.2 Configure the Instance

The input method interface asset is /PgosTextInputSystem/BlueprintUI/PgosCompositionView_BP, you can create this UserWidget and add as a child of your panel.