Input
>w## Notice
> * please include the header file "mmi_input.h" first when you want to use input module
`#include "mmi_input.h"`
>i## data structure
```
/**
* @brief input method
*/
typedef enum MMI_INPUT_METHOD_
{
InputMethod_digital = 1, /*!< digital input*/
InputMethod_lower_abc = 2, /*!< lowercase input*/
InputMethod_caps_abc = 4, /*!< capital input*/
InputMethod_hex = 8 /*!< hex input*/
} InputMethod;
typedef struct
{
unsigned char eventType; /*!< drv event type */
unsigned int displayLine; /*!< display lines */
unsigned char displayColumn; /*!< horizontal alignment*/
unsigned char defInputMethod; /*!< default input method */
unsigned char inputMethodGroup; /*!< input method group */
unsigned int waitTimeout; /*!< wait timeout */
//format string
unsigned char formatChar;
unsigned char openScan; /*!< open scan */
unsigned char isShowScanData; /*!< is show scan data (true/false) */
}tsInputMethodParam;
typedef struct
{
unsigned char integerUnit;
unsigned char *currencySymbol;
unsigned long *amount;
int fontColor;
int (*enterKey)(void);
int (*funcKey)(void);
int (*menuKey)(void);
}tsInputAmtParam;
/**
* @brief key value macro
*/
#define KEY_NONE (0x00) ///< No Key
#define KEY_ASCII1 (0x31) ///< Key "1"
#define KEY_ASCII2 (0x32) ///< Key "2"
#define KEY_ASCII3 (0x33) ///< Key "3"
#define KEY_ASCII4 (0x34) ///< Key "4"
#define KEY_ASCII5 (0x35) ///< Key "5"
#define KEY_ASCII6 (0x36) ///< Key "6"
#define KEY_ASCII7 (0x37) ///< Key "7"
#define KEY_ASCII8 (0x38) ///< Key "8"
#define KEY_ASCII9 (0x39) ///< Key "9"
#define KEY_ASCII0 (0x30) ///< Key "0"
#define KEY_ALPHA (0x04) ///< Key "ZiMu"
#define KEY_FUNC (0x05) ///< Key "FUNC"
#define KEY_CANCEL (0x1B) ///< Key "CANCEL"
#define KEY_CLEAR (0x03) ///< Key "CLEAR"
#define KEY_ENTER (0x0D) ///< Key "ENTER"
#define KEY_SCAN (0x0B) ///< Key "SCAN"
#define KEY_UP (0x26) ///< Key "UP"
#define KEY_DOWN (0x28) ///< Key "DOWN"
#define KEY_00 (0x08) ///< Key "00"
#define KEY_MENU (0x02) ///< Key "MENU"
#define KEY_DIV (0x2F) ///< Key "÷"
#define KEY_MUL (0x2A) ///< Key "x"
#define KEY_ADD (0x2B) ///< Key "+"
#define KEY_SUB (0x2D) ///< Key "-"
#define KEY_REPLAY (0x12) ///< Key "REPLAY"
#define KEY_REFUND (0x13) ///< Key "REFUND"
#define KEY_COLLECTION (0x14) ///< Key "COLLECTION"
#define KEY_DOT (0x2E) ///< Key "."
#define KEY_F1 (0x41) ///< Key "F1"
#define KEY_F2 (0x42) ///< Key "F2"
#define KEY_F3 (0x43) ///< Key "F3"
/**
* @brief input event type
*/
//(1<<0)
#define EVENT_NULL 0
#define EVENT_KEY_DRV 1
#define EVENT_MAG_DRV 2
#define EVENT_ICC_DRV 4
#define EVENT_MFR_DRV 8
#define EVENT_SCAN_DRV 16
#define EVENT_MANUAL_DRV 32
```
>i## mmi_inputWaitKeypress
### Prototype
`int mmi_inputWaitKeypress(unsigned int timeout);`
### Function
* wait key input until timeout
### Parameter
|Name|Type|description|
|-|-|-|
|timeout|unsigned int|wait key input time, timeout = 0:block until get key|
### Retval
|Value|Type|Description|
|-|-|-|
|key value|int|key value macro|
|KEY_NONE|int|timeout|
>i## mmi_inputDigital
### Prototype
`int mmi_inputDigital(unsigned int dispLine, unsigned int column, unsigned char *pBuff, int buffSize, unsigned long minValue, unsigned long maxValue, unsigned int timeout);`
### Function
* input number
### Parameter
|Name|Type|description|
|-|-|-|
|dispLine|unsigned int|value of DISP_VAlign|
|column|unsigned int|horizon position in line|
|pBuff|unsigned char *|getting input buffer|
|buffSize|int|getting input buffer size|
|minValue|unsigned long|minimum input value|
|maxValue|unsigned long|maximum input value|
|timeout|unsigned int|waiting for the input time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_TIMEOUT|int|timeout|
|ERR_PARAM|int|parameter error|
|ERR_CANCEL|int|cancel|
>i## mmi_inputString
### Prototype
`int mmi_inputString(unsigned int dispLine, unsigned int inputType, unsigned char *pBuff, int minLen, int maxLen, char *pucMask, unsigned int timeout);`
### Function
* input text
### Parameter
|Name|Type|description|
|-|-|-|
|dispLine|unsigned int|value of DISP_VAlign|
|inputType|unsigned int|allowed input string type|
|pBuff|unsigned char *|getting input buffer|
|minLen|int|minimum input length|
|maxLen|int|maximum input length|
|pucMask|char *|allowed input char value|
|timeout|unsigned int|waiting for the input time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_TIMEOUT|int|timeout|
|ERR_PARAM|int|parameter error|
|ERR_CANCEL|int|cancel|
>i## mmi_InputPasswd
### Prototype
`int mmi_InputPasswd(unsigned int dispLine, unsigned int column, unsigned int inputType, unsigned char *pwdData, unsigned int minLen, unsigned int maxLen, unsigned int timeout);`
### Function
* input password
### Parameter
|Name|Type|description|
|-|-|-|
|dispLine|unsigned int|value of DISP_VAlign|
|column|unsigned int|horizon position in line|
|inputType|unsigned int|allowed input string type|
|pwdData|unsigned char *|getting input password buffer|
|minLen|unsigned int|minimum input length|
|maxLen|unsigned int|maximum input length|
|timeout|unsigned int|waiting for the input time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_TIMEOUT|int|timeout|
|ERR_PARAM|int|parameter error|
|ERR_CANCEL|int|cancel|
>i## mmi_InputAmount
### Prototype
`int mmi_InputAmount(unsigned int dispLine, int column, unsigned char inputType, unsigned long *pAmount, int minAmount, int maxAmount, unsigned int timeout);`
### Function
* input amount
### Parameter
|Name|Type|description|
|-|-|-|
|dispLine|unsigned int|value of DISP_VAlign|
|column|int|horizon position in line|
|inputType|unsigned int|allowed input string type|
|pAmount|unsigned long *|getting input amount buffer|
|minAmount|int|minimum input amount|
|maxAmount|int|maximum input amount|
|timeout|unsigned int|waiting for the input time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_TIMEOUT|int|timeout|
|ERR_PARAM|int|parameter error|
|ERR_CANCEL|int|cancel|
>i## mmi_InputIPV4Addr
### Prototype
`int mmi_InputIPV4Addr(unsigned int DispLine, unsigned char *pucBuf, int timeOut);`
### Function
* input IP
### Parameter
|Name|Type|description|
|-|-|-|
|dispLine|unsigned int|value of DISP_VAlign|
|pucBuf|unsigned char *|getting input IP buffer|
|timeout|unsigned int|waiting for the input time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_TIMEOUT|int|timeout|
|ERR_PARAM|int|parameter error|
|ERR_CANCEL|int|cancel|
>i## mmi_EventOpen
### Prototype
`int mmi_EventOpen(unsigned int event);`
### Function
* open event of getting key, scan, ic card, rf card and so on
### Parameter
|Name|Type|description|
|-|-|-|
|event|unsigned int|EVENT_KEY_DRV, EVENT_MAG_DRV ...|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_MIF_DRV|int|open RF device fail|
|ERR_ICC_DRV|int|open IC device fail|
|ERR_MAG_DRV|int|open MAG device fail|
|ERR_SCAN_DRV|int|open SCAN device fail|
>i## mmi_EventWait
### Prototype
`int mmi_EventWait(unsigned int *pEvent, unsigned char *pDrvData, unsigned int *pDrvDataLen, unsigned int timeout);`
### Function
* waiting event trigger to get data
### Parameter
|Name|Type|description|
|-|-|-|
|pEvent|unsigned int *|return the trigger event, like EVENT_KEY_DRV, EVENT_MAG_DRV ...|
|pDrvData|unsigned char *|return data of the event|
|pDrvDataLen|unsigned int *|return data length|
|timeout|unsigned int|waiting for the event trigger time|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|ERR_PARAM|int|input parameters error|
|ERR_TIMEOUT|int|wait timeout|
>i## mmi_EventClose
### Prototype
`int mmi_EventClose(unsigned int event);`
### Function
* close event
### Parameter
|Name|Type|description|
|-|-|-|
|event|unsigned int|opened events by mmi_EventOpen|
### Retval
|Value|Type|Description|
|-|-|-|
|SUCCESS|int|success|
|-1|int|fail|
>s## Example
```
///<wait key pressed in 5 seconds or timeout
int iKey = 0;
iKey = mmi_inputWaitKeypress(5);
if (KEY_NONE == iKey) {
return ERR_TIMEOUT;
}
///<input six integers in 60 seconds
int iRet = 0;
unsigned char buff[8] = {0};
iRet = mmi_inputDigital(DISP_Line3, DISP_Left, buff, sizeof(buff), 6, 6, 60);
///<input six text in 60 seconds
int iRet = 0;
unsigned char buff[8] = {0};
unsigned int inputType = mmi_setInputType(InputMethod_lower_abc, InputMethod_digital | InputMethod_lower_abc | InputMethod_caps_abc);
iRet = mmi_inputString(DISP_Line3, inputType, buff, 6, 6, NULL, 60);
///<input six password in 60 seconds
int iRet = 0;
unsigned char buff[8] = {0};
unsigned int inputType = mmi_setInputType(InputMethod_digital, InputMethod_digital | InputMethod_lower_abc | InputMethod_caps_abc);
iRet = mmi_InputPasswd(DISP_Line3, DISP_Left, inputType, buff, 6, 6, 60);
///<input amount(0.01 - 100.00) in 60 seconds
int iRet = 0;
unsigned long amt = 0;
iRet = mmi_inputAmount(DISP_Line3, DISP_Left, 0, &amt, 1, 10000, 60);
///<input IP in 60 seconds
int iRet = 0;
unsigned char buff[16] = {0};
iRet = mmi_InputIPV4Addr(DISP_Line3, buff, 60);
///<open key, mag card and ic card event
int iRet = 0;
unsigned int uiEvent = EVENT_KEY_DRV | EVENT_MAG_DRV | EVENT_ICC_DRV;
iRet = mmi_EventOpen(uiEvent);
///<open key, mag card and ic card event
int iRet = 0;
unsigned int uiEvent = EVENT_KEY_DRV | EVENT_MAG_DRV | EVENT_ICC_DRV;
unsigned char buff[128] = {0};
unsigned int uiLen = 0;
iRet = mmi_EventOpen(uiEvent);
if (SUCCESS == iRet) {
iRet = mmi_EventWait(&uiEvent, buff, &uiLen, 60);
}
///<close event
int iRet = 0;
unsigned int uiEvent = EVENT_KEY_DRV | EVENT_MAG_DRV | EVENT_ICC_DRV;
if (SUCCESS == (iRet = mmi_EventOpen(uiEvent))) {
mmi_EventClose(uiEvent);
}
```