⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rthread.c

📁 Windows Mobile平台的日文输入法
💻 C
📖 第 1 页 / 共 2 页
字号:
static WORD vmCJK[] = 
{
	0x0000, 0xff64, 0xff61, 0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3000 - 0x3007
	0x0000, 0x0000, 0x0000,	0x0000, 0xff62, 0xff63, 0x0000, 0x0000,		// 0x3008 - 0x300f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3010 - 0x3017
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3018 - 0x301f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3020 - 0x3027
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3028 - 0x302f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3030 - 0x3037
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3038 - 0x303f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3040 - 0x3047
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3048 - 0x304f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3050 - 0x3057
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3058 - 0x305f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3060 - 0x3067
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3068 - 0x306f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3070 - 0x3077
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3078 - 0x307f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3080 - 0x3087
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3088 - 0x308f
	0x0000, 0x0000, 0x0000,	0x0000, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x3090 - 0x3097
	0x0000, 0x0000, 0x0000, 0xff9e, 0xff9f, 0x0000,	0x0000, 0x0000,		// 0x3098 - 0x309f
	0x0000, 0xff67, 0xff71, 0xff68, 0xff72, 0xff69, 0xff73, 0xff6a,		// 0x30a0 - 0x30a7
	0xff74, 0xff6b, 0xff75, 0xff76, 0xff76, 0xff77, 0xff77, 0xff78,		// 0x30a8 - 0x30af
	0xff78, 0xff79, 0xff79, 0xff7a, 0xff7a, 0xff7b, 0xff7b, 0xff7c,		// 0x30b0 - 0x30b7
	0xff7c, 0xff7d, 0xff7d, 0xff7e, 0xff7e, 0xff7f, 0xff7f, 0xff80,		// 0x30b8 - 0x30bf
	0xff80, 0xff81, 0xff81, 0xff6f, 0xff82, 0xff82, 0xff83, 0xff83,		// 0x30c0 - 0x30c7
	0xff84, 0xff84, 0xff85, 0xff86, 0xff87, 0xff88, 0xff89, 0xff8a,		// 0x30c8 - 0x30cf
	0xff8a, 0xff8a, 0xff8b, 0xff8b, 0xff8b, 0xff8c, 0xff8c, 0xff8c,		// 0x30d0 - 0x30d7
	0xff8d, 0xff8d, 0xff8d, 0xff8e, 0xff8e, 0xff8e, 0xff8f, 0xff90,		// 0x30d8 - 0x30df
	0xff91, 0xff92, 0xff93, 0xff6c, 0xff94, 0xff6d, 0xff95, 0xff6e,		// 0x30e0 - 0x30e7
	0xff96, 0xff97, 0xff98, 0xff99, 0xff9a, 0xff9b, 0x0000, 0xff9c,		// 0x30e8 - 0x30ef
	0x0000, 0x0000, 0xff66, 0xff9d, 0x0000, 0x0000,	0x0000, 0x0000,		// 0x30f0 - 0x30f7
	0x0000, 0x0000, 0x0000, 0xff65, 0xff70, 0x0000,	0x0000, 0x0000		// 0x30f8 - 0x30ff
};

#define	IS_ROMAJI(a)		((pHead->awchAlts[a] & 0xff00) == 0x0000)
#define	IS_KANA(a)			((pHead->awchAlts[a] & 0xff00) == 0x3000)
#define	IS_HALFWIDTH(a)		(vafRoma[pHead->awchAlts[a] & 0x00ff] & HW)
#define	IS_FULLWIDTH(a)		(vafCJK[pHead->awchAlts[a] & 0x00ff] & FW)
#define	HAS_DAKUTEN			(vafCJK[pHead->awchAlts[0] & 0x00ff] & DAKUTEN)
#define	HAS_HANDAKUTEN		(vafCJK[pHead->awchAlts[0] & 0x00ff] & HANDAKUTEN)

void GetCharacters(int iSentAlready, int iReady)
{
	HWXRESULTPRI   *pHead;
	HWXRESULTS	   *pBox;
	int				count = iReady - iSentAlready;
	int				nAccent;
	int i;
	wchar_t dmyAlts;
        pBox = NULL;
        if (count > 0 && INT_MAX / (sizeof(HWXRESULTS) + (HWXPAD_NUM_CANDIDATES - 1) * sizeof(WCHAR)) > count)
        {

            pBox = (HWXRESULTS *) LocalAlloc(LPTR, count * (sizeof(HWXRESULTS) + (HWXPAD_NUM_CANDIDATES - 1) * sizeof(WCHAR)));
        }
	if (pBox)
	{
		HwxGetResults(hrcActive, HWXPAD_NUM_CANDIDATES, iSentAlready, count, pBox);

		pHead = GetCandidates(pBox);

		LocalFree(pBox);

		// Special handling for HALFWIDTH katakana and FULLWIDTH romaji

		if (pHead)
		{
			nAccent = 0;

			if (giHalf && !(IS_ROMAJI(0)) && !(IS_KANA(0)))
			{
				for(i=0 ; i<HWXPAD_NUM_CANDIDATES ; i++){
					if(IS_KANA(i) || IS_ROMAJI(i)){
						dmyAlts = pHead->awchAlts[0];
						pHead->awchAlts[0] = pHead->awchAlts[i];
						pHead->awchAlts[i] = dmyAlts;
						break;
					}
				}
			}

			for(i=0 ; i<HWXPAD_NUM_CANDIDATES ; i++){
				if (!giHalf && IS_ROMAJI(i) && IS_HALFWIDTH(i))
				{
					pHead->awchAlts[i] += 0xfee0;
					nAccent = 0;
				}
			}

			for(i=0 ; i<HWXPAD_NUM_CANDIDATES ; i++){
				if (giHalf && IS_KANA(i) && IS_FULLWIDTH(i))
				{
					if(i == 0){
						if (HAS_DAKUTEN)
							nAccent = 1;
						else if (HAS_HANDAKUTEN)
							nAccent = 2;
						else
							nAccent = 0;
					}
					pHead->awchAlts[i] = vmCJK[pHead->awchAlts[i] & 0x00ff];
				}
			}
		}

	// Call back to the main thread to dispatch the BOXRESULTS

		if (pHead)
		{
			SendAltList(pHead);

		// If a dakuten or handakuten needs to be sent, create a data structure and send it

			if (nAccent)
			{
				HWXRESULTPRI   *phr = (HWXRESULTPRI *) LocalAlloc(LPTR, sizeof(HWXRESULTPRI));

				if (phr != (HWXRESULTPRI *) NULL)
				{
					phr->cbCount = 1;
					phr->awchAlts[0] = nAccent == 1 ? 0xff9e : 0xff9f;
					phr->anScore[0] = 0;

					SendAltList(phr);
				}
			}
		}
	}
}

BOOL HandleThreadMsg(MSG *pMsg)
{
//	STROKEINFO  si;
	STROKE      *pstr;
	int         iIndex;
	int         count;

	switch (pMsg->message)
	{
		case THRDMSG_ADDINK:

			pstr = (STROKE *) pMsg->lParam;

			if (!pstr)
				return TRUE;

			if (hrcActive == NULL)
			{
				giSent = 0;

				hrcActive = HwxCreate(NULL);

				if (hrcActive == NULL)
					return TRUE;

				//RETAILMSG(TRUE, (TEXT("ADDINK HwxCreate called\n")));

				HwxSetGuide(hrcActive, &v_guide);

				// Setup the ALC mask everytime we do recognization

				HwxALCValid(hrcActive, viNumb ? ALC_NUMERIC | ALC_NUMERIC_PUNC | ALC_MONETARY : ALC_JPN_COMMON | ALC_KANJI_RARE);
			}

			//RETAILMSG(TRUE, (TEXT("ADDINK pstr->iBox %d pstr->xLeft %d giSent %d\n"), pstr->iBox, pstr->xLeft, giSent));

			count = (pstr->iBox * BOX_SIZE) * 12;   // Compute the offset for the box logically.

			// The ink is already scaled by 4, so another multiply by 3 will make it ready for prime time.

			for (iIndex = 0; iIndex < pstr->cpt; iIndex++)
			{
				pstr->apt[iIndex].x = ((pstr->apt[iIndex].x - pstr->xLeft) * 3) + count;
				pstr->apt[iIndex].y = (pstr->apt[iIndex].y * 3);
			}

			HwxInput(hrcActive, pstr->apt, pstr->cpt, 0);
			LocalFree(pstr);
			bDirty = TRUE;

			return TRUE;

		case THRDMSG_RECOGNIZE:

			if (hrcActive == NULL)
				return(TRUE);

			count = pMsg->wParam;

			// iIndex = GetTickCount();

			HwxEndInput(hrcActive);
			HwxProcess(hrcActive);

			// iIndex = GetTickCount() - iIndex;

			// RETAILMSG(TRUE, (TEXT("RECOGNIZE time %d\n"), iIndex));

			//
			// We only get back the top 6 candidates.
			//

			//count = pMsg->wParam;               // # of boxes written in is sent here.
			// RETAILMSG(TRUE, (TEXT("RECOGNIZE giSent %d, count %d\n"), giSent, count));

			count = 1;

			if (count > giSent)
			{
				GetCharacters(giSent, count);
				giSent = count;
			}

			HwxDestroy(hrcActive);
			bDirty = FALSE;
			hrcActive = NULL;
			return TRUE;

		case THRDMSG_CLEAR:

			if (hrcActive == NULL)
				return(TRUE);

			HwxEndInput(hrcActive);
			HwxProcess(hrcActive);
			HwxDestroy(hrcActive);
			bDirty = FALSE;
			hrcActive = NULL;
			return TRUE;

		case THRDMSG_CHAR:
			switch (pMsg->wParam)
			{
			case VK_KANA:
				giHalf = pMsg->lParam;
				break;

			case VK_NUMLOCK:
				viNumb = pMsg->lParam;
				break;

			case VK_SPACE:
				SendProperSpace();
				break;

			default:
				SendVKCode(pMsg->wParam);
				break;
			}

			return TRUE;

		case THRDMSG_SETMASK:
			dwMask = pMsg->wParam;
			return TRUE;

		case THRDMSG_SETCONTEXT:
			v_prevChar = (TCHAR) pMsg->wParam;
			return TRUE;

		default:
			return FALSE;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -