// Keyboard Menu for iSMART TU800X480C // Updated 01-March-2011 // ------------------------------------------------------------------------------ // iSMART Keyboard Page // ------------------------------------------------------------------------------ ////////// //Fiiles// ///////// LIB(libkeys, "SDHC/keys.bmp"); //load the button keys LIB(libucase, "SDHC/ucase.bmp?back=\\ffffff"); //load the upper case keys + transparency LIB(liblcase, "SDHC/lcase.bmp?back=\\ffffff"); //load the lower case keys + transparency LIB(libasc, "SDHC/asc_32eu.fnt"); //load the asc32 font /////////// //Styles// /////////// STYLE(stPage, Page){image=libkeys;} //create a page style for the main page and set background image to libkeys STYLE(StartImgStyle, Image){curRel = CC;} //create a style to be used for the images with the cursor placement set to CC STYLE(BlueText32, Text){font="libasc"; col=blue; maxLen=23; maxRows=1; curRel=CL;} //set the TEXT style to specific attributes and the font source to be "libasc" /////////////// //Variables// ////////////// VAR(TextData, "", TXT); //create a text variable to hold the resultant text VAR(KeyData, "", TXT); //create a text variable to hold the current character input by the user VAR(Cap, 0, U8); //create an unsigned 8 bit variable to define the state of the CAP (Caps lock) key VAR(Shift, 0, U8); //create an unsigned 8 bit variable to define the state of the Shift key VAR(InsK, 0, U8); //create an unsigned 8 bit variable to define the state of the INS(Insert) key VAR(enkey,"\\FF",TXT); //create a text variable to store the character pressed, with a starting value of hex \\FF LOAD(KeyData,"\\04",TextData); //adds a visible underline cursor for easier user interface ////////// //Page// ////////// PAGE( keys, stPage ) //create the main page for the keyboard and set its contents { POSN(8, 16); TEXT (TextLine, KeyData, BlueText32); //set the position and create a "textbox" on the screen POSN(239, 135); Img (lc, liblcase, 480, 272, StartImgStyle); //set the position of the lowercase letter image POSN(239, 135); Img (uc, libucase, 480, 272, StartImgStyle); //set the position of the upercase letter image //from line 37 to 99 sets the touch(KEY) events for the keyboard keys and set appropriate function to be called //when touch area is pressed, determine if CAP has been pressed if so load the approriate character to enkey, if not load the alternative character //the position has a "+" before the x and y coordinates,this adds the specified value to the position stated before the line POSN(24, 61); KEY(plusKey, [IF(Cap=0?[LOAD(enkey,"+");]:[LOAD(enkey,"_");]);], 40, 30, TOUCH ); //CAP=0 load "+", CAP=1 load "_" POSN(+48, +0); KEY(minusKey, [IF(Cap=0?[LOAD(enkey,"-");]:[LOAD(enkey,"\\7B");]);], 40, 30, TOUCH ); //CAP=0 load "-", CAP=1 load "\\7B" POSN(+48, +0); KEY(fwdslashKey,[IF(Cap=0?[LOAD(enkey,"/");]:[LOAD(enkey,"\\7D");]);], 40, 30, TOUCH ); //CAP=0 load "/", CAP=1 load "\\7D" POSN(+48, +0); KEY(equalKey, [IF(Cap=0?[LOAD(enkey,"=");]:[LOAD(enkey,":");]);], 40, 30, TOUCH ); //CAP=0 load "=", CAP=1 load ":" POSN(+48, +0); KEY(asterixKey, [IF(Cap=0?[LOAD(enkey,"*");]:[LOAD(enkey,";");]);], 40, 30, TOUCH ); //CAP=0 load "+", CAP=1 load "_" POSN(+48, +0); KEY(greatKey, [IF(Cap=0?[LOAD(enkey,">");]:[LOAD(enkey,"'");]);], 40, 30, TOUCH ); //CAP=0 load ">", CAP=1 load "'" POSN(+48, +0); KEY(lessKey, [IF(Cap=0?[LOAD(enkey,"<");]:[LOAD(enkey,"@");]);], 40, 30, TOUCH ); //CAP=0 load "<", CAP=1 load "@" POSN(+48, +0); KEY(approxKey, [IF(Cap=0?[LOAD(enkey,"~");]:[LOAD(enkey,"\\5C");]);], 40, 30, TOUCH ); //CAP=0 load "~", CAP=1 load "\\5C" POSN(+48, +0); KEY(SquBracKey, [IF(Cap=0?[LOAD(enkey,"[");]:[LOAD(enkey,"|");]);], 40, 30, TOUCH ); //CAP=0 load "[", CAP=1 load "|" POSN(+48, +0); KEY(SquBrac2Key, [IF(Cap=0?[LOAD(enkey,"]");]:[LOAD(enkey,"?");]);], 40, 30, TOUCH ); //CAP=0 load "<", CAP=1 load "@" POSN(24, +38); KEY(oneKey, [IF(Cap=0?[LOAD(enkey,"1");]:[LOAD(enkey,"!");]);], 40, 30, TOUCH ); //CAP=0 load "1", CAP=1 load "!" POSN(+48, +0); KEY(twoKey, [IF(Cap=0?[LOAD(enkey,"2");]:[LOAD(enkey,"\\22");]);], 40, 30, TOUCH ); //CAP=0 load "2", CAP=1 load "\\22" POSN(+48, +0); KEY(threeKey, [IF(Cap=0?[LOAD(enkey,"3");]:[LOAD(enkey,"\\A3");]);], 40, 30, TOUCH ); //CAP=0 load "3", CAP=1 load "\\A3" POSN(+48, +0); KEY(fourKey, [IF(Cap=0?[LOAD(enkey,"4");]:[LOAD(enkey,"$");]);], 40, 30, TOUCH ); //CAP=0 load "4", CAP=1 load "$" POSN(+48, +0); KEY(fiveKey, [IF(Cap=0?[LOAD(enkey,"5");]:[LOAD(enkey,"%");]);], 40, 30, TOUCH ); //CAP=0 load "5", CAP=1 load "%" POSN(+48, +0); KEY(sixKey, [IF(Cap=0?[LOAD(enkey,"6");]:[LOAD(enkey,"^");]);], 40, 30, TOUCH ); //CAP=0 load "6", CAP=1 load "^" POSN(+48, +0); KEY(sevenKey, [IF(Cap=0?[LOAD(enkey,"7");]:[LOAD(enkey,"&");]);], 40, 30, TOUCH ); //CAP=0 load "7", CAP=1 load "&" POSN(+48, +0); KEY(eightKey, [IF(Cap=0?[LOAD(enkey,"8");]:[LOAD(enkey,"`");]);], 40, 30, TOUCH ); //CAP=0 load "8", CAP=1 load "'" POSN(+48, +0); KEY(nineKey, [IF(Cap=0?[LOAD(enkey,"9");]:[LOAD(enkey,"(");]);], 40, 30, TOUCH ); //CAP=0 load "9", CAP=1 load "(" POSN(+48, +0); KEY(zeroKey, [IF(Cap=0?[LOAD(enkey,"0");]:[LOAD(enkey,")");]);], 40, 30, TOUCH ); //CAP=0 load "0", CAP=1 load ")" POSN(24, +38); KEY(QKey, [IF(Cap=0?[LOAD(enkey,"Q");]:[LOAD(enkey,"q");]);], 40, 30, TOUCH ); //CAP=0 load "Q", CAP=1 load "q" POSN(+48, +0); KEY(WKey, [IF(Cap=0?[LOAD(enkey,"W");]:[LOAD(enkey,"w");]);], 40, 30, TOUCH ); //CAP=0 load "W", CAP=1 load "w" POSN(+48, +0); KEY(EKey, [IF(Cap=0?[LOAD(enkey,"E");]:[LOAD(enkey,"e");]);], 40, 30, TOUCH ); //CAP=0 load "E", CAP=1 load "e" POSN(+48, +0); KEY(RKey, [IF(Cap=0?[LOAD(enkey,"R");]:[LOAD(enkey,"r");]);], 40, 30, TOUCH ); //CAP=0 load "R", CAP=1 load "r" POSN(+48, +0); KEY(TKey, [IF(Cap=0?[LOAD(enkey,"T");]:[LOAD(enkey,"t");]);], 40, 30, TOUCH ); //CAP=0 load "T", CAP=1 load "t" POSN(+48, +0); KEY(YKey, [IF(Cap=0?[LOAD(enkey,"Y");]:[LOAD(enkey,"y");]);], 40, 30, TOUCH ); //CAP=0 load "Y", CAP=1 load "y" POSN(+48, +0); KEY(UKey, [IF(Cap=0?[LOAD(enkey,"U");]:[LOAD(enkey,"u");]);], 40, 30, TOUCH ); //CAP=0 load "U", CAP=1 load "u" POSN(+48, +0); KEY(IKey, [IF(Cap=0?[LOAD(enkey,"I");]:[LOAD(enkey,"i");]);], 40, 30, TOUCH ); //CAP=0 load "I", CAP=1 load "i" POSN(+48, +0); KEY(OKey, [IF(Cap=0?[LOAD(enkey,"O");]:[LOAD(enkey,"o");]);], 40, 30, TOUCH ); //CAP=0 load "O", CAP=1 load "o" POSN(+48, +0); KEY(PKey, [IF(Cap=0?[LOAD(enkey,"P");]:[LOAD(enkey,"p");]);], 40, 30, TOUCH ); //CAP=0 load "P", CAP=1 load "p" POSN(48, +39); KEY(AKey, [IF(Cap=0?[LOAD(enkey,"A");]:[LOAD(enkey,"a");]);], 40, 30, TOUCH ); //CAP=0 load "A", CAP=1 load "a" POSN(+48, +0); KEY(SKey, [IF(Cap=0?[LOAD(enkey,"S");]:[LOAD(enkey,"s");]);], 40, 30, TOUCH ); //CAP=0 load "S", CAP=1 load "s" POSN(+48, +0); KEY(DKey, [IF(Cap=0?[LOAD(enkey,"D");]:[LOAD(enkey,"d");]);], 40, 30, TOUCH ); //CAP=0 load "D", CAP=1 load "d" POSN(+48, +0); KEY(FKey, [IF(Cap=0?[LOAD(enkey,"F");]:[LOAD(enkey,"f");]);], 40, 30, TOUCH ); //CAP=0 load "F", CAP=1 load "f" POSN(+48, +0); KEY(GKey, [IF(Cap=0?[LOAD(enkey,"G");]:[LOAD(enkey,"g");]);], 40, 30, TOUCH ); //CAP=0 load "G", CAP=1 load "g" POSN(+48, +0); KEY(HKey, [IF(Cap=0?[LOAD(enkey,"H");]:[LOAD(enkey,"h");]);], 40, 30, TOUCH ); //CAP=0 load "H", CAP=1 load "h" POSN(+48, +0); KEY(JKey, [IF(Cap=0?[LOAD(enkey,"J");]:[LOAD(enkey,"j");]);], 40, 30, TOUCH ); //CAP=0 load "J", CAP=1 load "j" POSN(+48, +0); KEY(KKey, [IF(Cap=0?[LOAD(enkey,"K");]:[LOAD(enkey,"k");]);], 40, 30, TOUCH ); //CAP=0 load "K", CAP=1 load "k" POSN(+48, +0); KEY(LKey, [IF(Cap=0?[LOAD(enkey,"L");]:[LOAD(enkey,"l");]);], 40, 30, TOUCH ); //CAP=0 load "L", CAP=1 load "l" POSN(24, +38); KEY(shftKey, [RUN(fncshiftkey);LOAD(Shift,1);], 40, 30, TOUCH ); //"shift" key, call the function fncshiftkey and load 1 to Shift POSN(+48, +0); KEY(ZKey, [IF(Cap=0?[LOAD(enkey,"Z");]:[LOAD(enkey,"z");]);], 40, 30, TOUCH ); //CAP=0 load "Z", CAP=1 load "z" POSN(+48, +0); KEY(XKey, [IF(Cap=0?[LOAD(enkey,"X");]:[LOAD(enkey,"x");]);], 40, 30, TOUCH ); //CAP=0 load "X", CAP=1 load "x" POSN(+48, +0); KEY(CKey, [IF(Cap=0?[LOAD(enkey,"C");]:[LOAD(enkey,"c");]);], 40, 30, TOUCH ); //CAP=0 load "C", CAP=1 load "c" POSN(+48, +0); KEY(VKey, [IF(Cap=0?[LOAD(enkey,"V");]:[LOAD(enkey,"v");]);], 40, 30, TOUCH ); //CAP=0 load "V", CAP=1 load "v" POSN(+48, +0); KEY(BKey, [IF(Cap=0?[LOAD(enkey,"B");]:[LOAD(enkey,"b");]);], 40, 30, TOUCH ); //CAP=0 load "B", CAP=1 load "b" POSN(+48, +0); KEY(NKey, [IF(Cap=0?[LOAD(enkey,"N");]:[LOAD(enkey,"n");]);], 40, 30, TOUCH ); //CAP=0 load "N", CAP=1 load "n" POSN(+48, +0); KEY(MKey, [IF(Cap=0?[LOAD(enkey,"M");]:[LOAD(enkey,"m");]);], 40, 30, TOUCH ); //CAP=0 load "M", CAP=1 load "m" POSN(+48, +0); KEY(bsKey, fncbskey, 40, 30, TOUCH ); //"backspace" key, call the function fncbskey POSN(+48, +0); KEY(delKey, fncdelkey, 40, 30, TOUCH ); //"delete" key, call the function fncdelkey POSN(24, +38); KEY(capKey, fnccapkey, 40, 30, TOUCH ); //"caps lock" key, call the function fnccapkey POSN(+48, +0); KEY(insKey, fncinskey, 40, 30, TOUCH ); //"insert" key, call the function fncinskey POSN(+48, +0); KEY(hashKey, [IF(Cap=0?[LOAD(enkey,"#");]:[LOAD(enkey,"\\A0");]);], 40, 30, TOUCH ); //CAP=0 load "#", CAP=1 load "\\A0" POSN(+48, +0); KEY(commaKey, [LOAD(enkey,",");], 40, 30, TOUCH ); //"," key POSN(+72, +0); KEY(spaceKey, [LOAD(enkey," ");], 86, 30, TOUCH ); //" " key POSN(+72, +0); KEY(fstopKey, [LOAD(enkey,".");], 40, 30, TOUCH ); //"." key POSN(+48, +0); Key(leftKey, fncleftkey, 40, 30, TOUCH ); //"left" key, call the function fncleftkey POSN(+48, +0); Key(rightKey, fncrightkey, 40, 30, TOUCH ); //"right" key, call the function fncrightkey POSN(+48, +0); Key(entKey, fncentkey, 40, 30, TOUCH ); //"enter" key, call the function fncentkey LOOP(enkeyloop,forever) //set up a loop for when a key has been pressed { IF(enkey<>"\\FF"?fncenkey); //if the key value isn't(<>) blank/empty then add the character to the text } } /////////////// //Functions// ////////////// FUNC(fncenkey) //store the character and increment the cursor for the next character { CALC(KeyData,KeyData,enkey,"INS"); //add character at cursor when the key is pressed and increment cursor TEXT(TextLine,KeyData); //store the new character to the variable Keydata and display it on the screen LOAD(enkey,"\\FF"); //restore the default value of the variable that holds entered character by the user IF(Shift=1?[RUN(fncshiftkey);LOAD(Shift,0);]);; //if the "shift" key has been pressed then run the fncshiftkey function once then set the variable Shift value to 0 again } FUNC(fncshiftkey) { IF(Cap=0? [HIDE(uc); SHOW(lc);LOAD(Cap,1);]:[SHOW(uc); HIDE(lc); LOAD(Cap,0);]);; //if the "shift" key hasn't been pressed (Cap=0) then hide the image uc and show lc, else(:) do the opposite } FUNC(fncbskey) { CALC(KeyData,KeyData,-1,"DEL"); //if the "backspace" key has been pressed delete one character to the left and move the cursor by one to the left TEXT(TextLine,KeyData);; //load the new KeyData value to TextLine which displays it to the screen } FUNC(fncdelkey) { CALC(KeyData,KeyData,1,"DEL"); //if the "delete" key has been pressed delete one character to the right TEXT(TextLine,KeyData);; //load the new KeyData value to TextLine which displays it to the screen } FUNC(fnccapkey) { IF(Cap=0? [HIDE(uc); SHOW(lc); LOAD(Cap,1);]:[SHOW(uc); HIDE(lc); LOAD(Cap,0);]);; //if the "caps lock" key hasn't been pressed (Cap=0) then hide the image uc and show lc, else(:) do the opposite } FUNC(fncleftkey) { CALC(KeyData,KeyData,-1,"REL"); //move the cursor by one to the left TEXT(TextLine,KeyData);; //load the new value of KeyData to TextLine } FUNC(fncrightkey) { CALC(KeyData,KeyData,+1,"REL"); //move the cursor by one to the right TEXT(TextLine,KeyData);; //load the new value of KeyData to TextLine } FUNC(fncinskey) //this function is called when the insert key has been pressed { IF(InsK=0? [LOAD(InsK,1);CALC(KeyData,KeyData,"\\07","CUR");]:[LOAD(InsK,0);CALC(KeyData,KeyData,"\\04","CUR");]); //if the insert key is set to 0 change cursor type and set insK to 1, else(:) do the opposite TEXT(TextLine,KeyData);; //load the new value of KeyData to TextLine } FUNC(fncentkey) { //use this function when there is a destination for the entered text by the user, which is stored in the variable TextData //CALC(TextData,KeyData,"\\02\\03\\04\\05\\06\\07","REM"); //remove all the cursor types and put KeyData to TextData //SHOW(prev_page); //use if called from another page } HIDE(lc); //hide lower case overlay SHOW(keys); //show the keys page or put on another page to call this keyboard application