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

📄 mmiusersymbolinput.c

📁 是一个手机功能的模拟程序
💻 C
字号:
/*
+-----------------------------------------------------------------------+
|                       Restricted Rights Legend                                                                   |
| Copyright(c) 1999-2000 by Synchronization, Inc.                                                      |
| This file is the property of the Synchronization Inc. and it is                                        |
| protected by United States Copyright laws, Internationals laws and                             |
| treaties. It is there by forbidden for any unauthorized use,                                         |
| duplication, distribution or disclosure by any commercial industry                                |
| (public or private), private individual, or by any Government agency                           |
| without a explicit written consent of release from Synchronization.                               |
|....................................................................   |
| PROJECT: Eg730                       $Workfile::   mmiusersymbolinput.c     $               |
| Original Author::zhu guangzhao  $Revision: 1.1.1.1 $                                   |
| CREATED: 04  Jul  2002             $Modtime::     $|
+-----------------------------------------------------------------------+

   PURPOSE  : handle the user's symbol input
   TO DO    :

   $History: mmiusersymbolinput.c                                             $
   
 ** **************  Version 1.1 *****************
 * zgz,2002.7.29
 * 
 * update function ec_editEventKey()
 ** ************** *****************************

   

*/
#define ENTITY_MFW

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

    #include "typedefs.h"
    #include "vsi.h"
    #include "pei.h"
    #include "custom.h"
    #include "gsm.h"

#else

    #include "stddefs.h"
    #include "custom.h"
    #include "gsm.h"
    #include "vsi.h"

#endif
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ss.h"
#include "mfw_icn.h"

#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"
#include "mfw_cm.h"

#include "dspl.h"

#include "ksd.h"
#include "psa.h"


//zgz, 2002.7.8 #include "MmiMain.h"

#include "MmiDummy.h"
//#include "MmiLists.h"
#include "MmiMmi.h"

#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
//GW Removed T9 reference
#include "MmiIdle.h"

#include "MmiEditor.h"
#include "MmiEditor_i.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "mmiicons.h"
#include "mmibookshared.h"
#include "mmismsmenu.h"
#include "mfw_ffs.h"

#include "mmiusersymbolinput.h"


//Note: "ecinput" means "Mobile Innovation input method"

static int cur_ecinput_mode;  // indicate current eastcom symbol input method mode

static MfwHnd myHandle = 0;             /* editors handle           */
static MfwHnd editTim = 0;              /* the editor timer         */


static  UBYTE ec_editControls [KCD_MAX] =      /* edit control keys:       */
{
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '*', '#', ecNone, ecNone, ecUp, ecDown, ecLeft, ecRight,
    ecNone, ecNone, ecEnter, ecNone, ecNone, ecNone,
    ecNone, ecNone, ecEnter
};

static UBYTE editAlphaLevel;               /* alpha level selected     */
static UBYTE editAlphaKey;                 /* alpha mode current key   */
static UBYTE editHiddenMode;              /* zhangxp added for password inputing 2003/4/7 */
static char *tmpBuf; 

static char** l_curCharSet;

const static char * l_editAlphaL[14] =   // lowercase key 0123456789*#
{
    "\'\"/.+-=0", " ,.?!:1", "abc2", "def3",        //key 0,1,2,3
    "ghi4", "jkl5", "mno6", "pqrs7",            //key 4,5,6,7
    "tuv8", "wxyz9", "*#%&@ ", " \'\"/","\0","\0"       //key 8,9,*,#
};      

const static char * l_editAlphaU[14] =   // uppercase key 0123456789*#
{
    "\'\"/.+-=0", " ,.?!:1", "ABC2", "DEF3", 
    "GHI4", "JKL5", "MNO6", "PQRS7", 
    "TUV8", "WXYZ9", "*#%&@ ", " \'\"/","\0","\0"
};

static int editEventTim (MfwEvt e, MfwTim *t);


void set_ecinput_mode(int mode)
{
    cur_ecinput_mode = mode;
}

int  get_ecinput_mode(void)
{
    return cur_ecinput_mode;
}

void switch_ecinput_mode(void)
{
    if( cur_ecinput_mode < ONLYREAD_MODE )  // when current mode is not ONLYREAD_MODE, PHONENUMONLY_MODE.  do the follow steps.
    {
        cur_ecinput_mode++;
        if( cur_ecinput_mode > SHUZI_MODE )
            cur_ecinput_mode = TEXTINPUT_MODE;  /* 2003/12/04 sunsj modify */
    }
}
char findprechar(void)
{
    MfwEdt  *edit = ((MfwHdr *) myHandle)->data;
    if( edit->cp == 0 )
        return 0;
    else return((char)edit->attr->text[edit->cp-1]);
}
char findnextchar(void)
{
    MfwEdt  *edit = ((MfwHdr *) myHandle)->data;
    if( edit->cp >= strlen(edit->attr->text) )
        return 0;
    else return((char)edit->attr->text[edit->cp+1]);
}

int ec_editEventKey (MfwEvt e, MfwKbd *k)
{
    MfwEdt *edit = ((MfwHdr *) myHandle)->data;
    char        alphachar;                                                      // SH - Current multi-tap character

    switch( cur_ecinput_mode )
    {
    /* 2003/12/04 sunsj remove */
#if 0
    case UPPERCASE_MODE:
    case LOWERCASE_MODE:

        if( cur_ecinput_mode == UPPERCASE_MODE )
            l_curCharSet = (char **)l_editAlphaU;
        else
            l_curCharSet = (char **)l_editAlphaL;

        TRACE_EVENT("upper, lowercase mode");

        //edtHide(myHandle);yq deleted
        if( (editHiddenMode)&&editAlphaKey != KCD_MAX&&editAlphaKey != k->code )//zhangxp,password inputting for wap,2003/4/8
        {
            timStop(editTim);

            edtSymbol(myHandle,ecDel);
            edtSymbol(myHandle,'*');

            editAlphaLevel = 0; 
            editAlphaKey = KCD_MAX;
        }

        else if( editAlphaKey != KCD_MAX && editAlphaKey != k->code ) //zgz, when the cursor is still not right, we press other key
        {
            timStop(editTim);

            edtSymbol(myHandle,ecRight);

            editAlphaLevel = 0; 
            editAlphaKey = KCD_MAX;
        }
        else if( editAlphaKey != KCD_MAX )     // the cursor is still not right, we press the same key
        {
            editAlphaLevel = (editAlphaLevel + 1) % strlen(l_curCharSet[editAlphaKey]);
        }

        if( k->code <= KCD_HASH )
        {

            // if (editAlphaKey != KCD_MAX)						// the cursor is still not right, insert the symbol on the same key
            //	edtSymbol(myHandle,ecDel);	//zgz,2002.7.24  these two lines be replace by the following 7 lines.  
            //7 lines begin		
            if( editAlphaKey != KCD_MAX )
            {
                edtHide(myHandle);
                //alphachar = (int)' ';
                //edtSymbol(myHandle,alphachar);
                //edtSymbol(myHandle,ecLeft);
                edtSymbol(myHandle,ecDel);
                edtUnhide(myHandle);
            }

            //7 lines end

            editAlphaKey = k->code;
            alphachar = l_curCharSet[editAlphaKey][editAlphaLevel];

            if( (editHiddenMode)&&k->code <=KCD_9 ) //zhangxp added for wap password inputting,2003/4/7
            {
                TRACE_EVENT("zxp in edit hidden mode")
                *(tmpBuf+edit->cp) = alphachar;                   
                if( edtChar(myHandle,alphachar)==MfwResOk )
                {
                    edtSymbol(myHandle, ecLeft);
                    timStart(editTim);
                }

            }
            else if( edtSymbol(myHandle, alphachar)==MfwResOk )
            //	edtUnhide(myHandle);yq deleted
            {
                //	edtSymbol(myHandle,ecRight);
                edtSymbol(myHandle, ecLeft);

                timStart(editTim);
            }
            else
            {
                editAlphaLevel = 0; 
                editAlphaKey = KCD_MAX;
            }
            return 1;
        }
        break;
#endif
    case SHUZI_MODE:
    case PHONENUMONLY_MODE: 
        /* 2004/04/13 sunsj remove */
        /*
        if( (editHiddenMode)&&editAlphaKey != KCD_MAX&&k->code <=KCD_9 )//zhangxp,password inputting for wap,2003/4/8
        {
            TRACE_EVENT("zxp number inputing in hide mode");
            timStop(editTim);

            edtSymbol(myHandle,ecDel);
            edtSymbol(myHandle,'*');            
        }
        */

        if( (editHiddenMode)&&k->code <=KCD_9 )
        {
            editAlphaKey = k->code;
            TRACE_EVENT("zxp in edit hidden mode")
            *(tmpBuf+edit->cp) = ec_editControls[k->code];                    

            /* 2004/04/13 sunsj modify */
            edtSymbol(myHandle,ecDel);
            edtSymbol(myHandle,'*');
            //edtChar(myHandle,ec_editControls[k->code]);
            //edtSymbol(myHandle,ecLeft);
            //timStart(editTim);

        }
        else
        {
            edtSymbol(myHandle,ec_editControls[k->code]);//if()==MfwResOk
        }
        // 	edtSymbol(myHandle,ecRight);
        break;
    case IPADDRESS_MODE:
        if( findnextchar()==0&&strlen(edit->attr->text)<(edit->attr->size-3) )
        {
            TRACE_EVENT("next char is zero");               
            edtSymbol(myHandle,ec_editControls[k->code]);
            if( strlen(edit->attr->text)%4==3 )
                edtSymbol(myHandle,'.');
        }
        else if( findnextchar()!='.' )
        {
            TRACE_EVENT("next char is not '.'");
            edtSymbol(myHandle,ecDel);
            edtSymbol(myHandle,ec_editControls[k->code]);
        }
        else
        {
            TRACE_EVENT("next char is '.'");
            edtSymbol(myHandle,ecDel);
            edtSymbol(myHandle,ec_editControls[k->code]);
            edtSymbol(myHandle,ecRight);
        }

        break;
    default:
        break;
    }       
    return 1;
}

void ec_editActivate (MfwHnd e,int AlphaMode)
{
    TRACE_EVENT("editActivate");

    myHandle = e;
    if( !editTim )
        TIMCREATE_SETFLLAG(editTim = timCreate(0,750,(MfwCb) editEventTim);)
        cur_ecinput_mode = AlphaMode;
    editHiddenMode = 0;

    editAlphaLevel = 0; 
    editAlphaKey = KCD_MAX;

}
void ec_editHiddenActivate (char *buffer)
{
    TRACE_EVENT("ec_editHiddenActivate");
    tmpBuf = buffer;
    editHiddenMode = 1;
    return;
}

MfwHnd getactiveEditor(void)
{
    return myHandle;
}

void ec_editDeactivate (void)
{
    myHandle = 0;

    if( editTim )
    {
        timStop(editTim);
        timDelete(editTim);
    }
    editTim = 0;

}


/*******************************************************************************

 $Function:  editEventTim

 $Description:   executes the timer event from the edit component

 $Returns:    none.

 $Arguments:

*******************************************************************************/
static int editEventTim (MfwEvt e, MfwTim *t)
{


    UBYTE old_mode;
    TRACE_EVENT("editEventTim");
    old_mode=dspl_Enable(0);
    if( cur_ecinput_mode == TEXTINPUT_MODE )  // it may cause problem	/* 2003/12/04 sunsj modify */
    {
        dspl_Enable(old_mode);
        return 1;
    }
    if( editHiddenMode )
    {
        TRACE_EVENT("zxp in the timer");
        edtChar(myHandle,ecDel);
        edtChar(myHandle,'*');
    }
    else edtSymbol(myHandle,ecRight);

    editAlphaLevel = 0; 
    editAlphaKey = KCD_MAX;
    dspl_Enable(old_mode);
    return 1;
}

⌨️ 快捷键说明

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