|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
高手請(qǐng)進(jìn):T9輸入法獲取按鍵組合問(wèn)題 |
| 作者:艾森豪威爾 欄目:單片機(jī) |
T9輸入法,得到按鍵組合的程序,符合的鍵值放在PYBuf[][]數(shù)組中。 我拼按下6號(hào)和8號(hào)鍵應(yīng)該能出來(lái)四種組合:mu,nu,nv,ou,但是nv出不來(lái)。 按2號(hào)和4號(hào)鍵,應(yīng)該能出來(lái)ai,bi,ch,ci四種組合,但是ci也出不來(lái)。 請(qǐng)看看我的問(wèn)題出在哪里,怎么解決? code CHAR KeyPY[][5]={{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},{"WXYZ"}}; struct PY_index * GetChnStr(unsigned CHAR * strInput_py_str,unsigned CHAR * PYCount) { //返回值:指向第一個(gè)符合拼音的PY_index結(jié)構(gòu)體 //PYCount:通過(guò)這個(gè)值來(lái)指示共有幾個(gè)PY_index符合要求 struct PY_index *cpHZ,*cpHZedge,*pHZ=NULL; CHAR i,cInputStrLength; cInputStrLength=strlen(strInput_py_str); /*輸入拼音串長(zhǎng)度*/ if(*strInput_py_str=='\0') return NULL; /*如果輸入空字符返回0*/ for(i=0;i<cInputStrLength;i++) *(strInput_py_str+i)|=0x20; /*將字母串轉(zhuǎn)為小寫*/ if(*strInput_py_str=='i') return NULL; /*錯(cuò)誤拼音輸入*/ if(*strInput_py_str=='u') return NULL; if(*strInput_py_str=='v') return NULL; cpHZ=PY_index_headletter[strInput_py_str][0]-'a']; /*查首字母索引*/ cpHZedge=PY_index_headletter[strInput_py_str][0]-'a'+1]; /*設(shè)置指針界限*/ strInput_py_str++; /*指向拼音串第二個(gè)字母*/ while(cpHZ<cpHZedge) /*索引表不超界*/ { for(i=0;i<cInputStrLength;i++) { if (*(strInput_py_str+i)==0) { if (PYCount==NULL) return cpHZ->PY_mb; if (pHZ==NULL) pHZ=cpHZ; (*PYCount)++; } if (*(strInput_py_str+i)!=*((*cpHZ).PY+i)) break; /*發(fā)現(xiàn)字母串不配,退出*/ } cpHZ++; } return pHZ; } //--------------------------------------------------------------------------------------- unsigned CHAR * GetKey(unsigned CHAR Key) { //輸入:0~7 //返回:指向xdata unsigned CHAR PYBuf[8][8]二維數(shù)組首地址的指針 //PYBuf :每行第一個(gè)Byte代表這行內(nèi)有幾個(gè)字母,0代表沒有 unsigned CHAR i,j=0; unsigned CHAR code * pPY; for (i=0;i<8;i++) { if (PYBuf[i][0]!=0) { pPY=KeyPY[Key]; while(*pPY!=0) { PYBuf[i][PYBuf[i][0]+1]=*pPY; PYBuf[i][PYBuf[i][0]+2]=0; if (GetChnStr(PYBuf[i]+1,NULL)) { PYBuf[i][0]++;//nu nv 的情況怎么處理? break; } pPY++; } if (*pPY==0) PYBuf[i][0]=0; } else j++; } if (j==8) //第一次按鍵 { for (i=0,j=0;KeyPY[Key][i]!=0;i++) { if (KeyPY[Key][i]=='i' || KeyPY[Key][i]=='u' || KeyPY[Key][i]=='v') continue; else { PYBuf[j][0]=1; PYBuf[j][1]=KeyPY[Key][i]; j++; } & |
|
|
| 免費(fèi)注冊(cè)為維庫(kù)電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |