
下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
- (int)keyCodeForCharacter: (Nsstring*)character { if(![character length]) return -1; char code; BOol shift,alt; if(Ascii2Virtual( (char)[character characteratIndex: 0],shift,alt,code)) { return code; } return -1;}BOol Ascii2Virtual(char pcar,BOol *pshift,BOol *palt,char *pkeycode){ KeyboardLayoutRef keyboard; const voID *keyboardData; // keyboard layout data UInt16 nbblocs; char *modblocs,*blocs,*deadkeys; int ix,ifin,numbloc,keycode; BOol shift,alt; // get the current keyboard if(KLGetCurrentKeyboardLayout(&keyboard;)) return NO; // get the description of the current keyboard layout if(KLGetKeyboardLayoutProperty(keyboard,kKLKCHRData,&keyboardData;)) return NO; // get pointer early numbers of blocks for each combination of modifIErs modblocs = ((char *)keyboardData) + 2; // get number of blocks keycode->ascii nbblocs = *((UInt16 *)(keyboardData + 258)); // get pointer early blocks keycode-> ascii blocs = ((char *)keyboardData) + 260; // determining the size of all tables keycode-> ascii a scanner ifin = nbblocs*128; // determining pointer early in the tables of dead keys deadkeys = blocs+ifin; // Now it runs blocks keycode-> ascii to find the car ascii for (ix=0; ix<ifin ; ix++) { if (blocs[ix]==pcar) { // found ascii value: Now we must determine which block it is keycode = ix & 0×7f; // 0111 1111 mask numbloc = ix >> 7; break; } } // not found: bail out (error) if (ix >= ifin) return NO; // from block number,we must find the combination of modifIErs using this block for (ix=0; ix<15; ix++) { // it does not address whether the modifIErs are not "cAPItal" and "option" if (ix&1 || ix&4) continue; // Combining modifIErs found for the block if (modblocs[ix]==numbloc) { shift = (ix&2) ? YES : NO; alt = (ix&8) ? YES : NO; break; } } // combination modifIErs not found: bail if (ix>=15) return NO; // save our parameters *pkeycode=keycode; *pshift=shift; *palt=alt; return YES;} 以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的objective-c 将字符转换为键盘码的代码全部内容,希望文章能够帮你解决objective-c 将字符转换为键盘码的代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)