Windmill-City / IngameIME

Enable IME in FullScreen games

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IngameIME

Enable IME in FullScreen games

Move:https://github.com/Windmill-City/IngameIME-Common

Example

Change IME State Handle Composition String FullScreen Mode Alpha Mode

How to use

Get an api instance first

//IMM32
IngameIME::BaseIME* api = new IngameIME::IMM();
//TextServiceFramework(Only works in STA Thread)
//Dont call methods out of your Initialize Thread, or you will result in crash
//Call Initialize() at your UI Thread
IngameIME::BaseIME* api = new IngameIME::TSF();

Set up callbacks

void CALLBACK onCandidateList(libtf::CandidateList* list) {
	textBox->m_lPageCount = list->m_lPageSize;
	textBox->m_pCandidates = list->m_pCandidates;
}

void CALLBACK onComposition(libtf::CompositionEventArgs* args) {
	switch (args->m_state)
	{
	case libtf::CompositionState::StartComposition:
	case libtf::CompositionState::EndComposition:
		textBox->m_wstrComposition.clear();
		textBox->m_lCaretPos = 0;
		break;
	case libtf::CompositionState::Commit:
		textBox->m_wstrTextContent += args->m_strCommit;
		break;
	case libtf::CompositionState::Composing:
		textBox->m_wstrComposition = args->m_strComposition;
		textBox->m_lCaretPos = args->m_lCaretPos;
		break;
	default:
		break;
	}
}

void CALLBACK onGetTextExt(PRECT prect) {
	textBox->GetCompExt(prect);//Pos the CandidateList window, should return a bounding box of the composition string
}

void CALLBACK onAlphaMode(BOOL isAlphaMode) {
	//notify if ime in Alphanumeric input mode
	InvalidateRect(hWnd, NULL, NULL);
}

Register in the api

	api->m_sigAlphaMode = onAlphaMode;
	api->m_sigComposition = onComposition;
	api->m_sigCandidateList = onCandidateList;
	api->m_sigGetTextExt = onGetTextExt;

Then init by passing a HWND ptr

   api->Initialize(hWnd);

Change IME State

api->setState(TRUE/FALSE);
api->setFullScreen(TRUE/FALSE);

About

Enable IME in FullScreen games


Languages

Language:C++ 87.8%Language:C 12.2%