📄 smi_inp.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-F&D (8411)
| Modul : SMI_INP
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : This Modul defines functions for input processing to
| enter numbers or strings from the keypad.
+-----------------------------------------------------------------------------
*/
#ifndef SMI_INP_C
#define SMI_INP_C
#endif
#define ENTITY_SMI
/*==== INCLUDES ===================================================*/
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
/*==== CONSTANTS ==================================================*/
#define MAX_INPUTS 3
/*==== TYPES ======================================================*/
/*==== EXPORT =====================================================*/
/*==== VARIABLES ==================================================*/
LOCAL T_INPUT inputTable[MAX_INPUTS];
LOCAL USHORT numOfInputs;
/*==== FUNCTIONS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_init |
+--------------------------------------------------------------------+
PURPOSE : Initialize the input module.
*/
GLOBAL void inp_init (void)
{
numOfInputs = MAX_INPUTS;
while (numOfInputs)
inputTable[--numOfInputs].free = TRUE;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_getInput |
+--------------------------------------------------------------------+
PURPOSE : returns the input string of the area referenced
by aHandle.
*/
GLOBAL char *inp_getInput (USHORT aHandle)
{
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_INPUT)
{
T_INPUT *inp = &inputTable[a->func];
if (inp->aktInputIdx > 0)
inp->aktInput[inp->aktInputIdx] = NULL_TERM;
return inp->aktInput;
}
return "";
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_refreshInput |
+--------------------------------------------------------------------+
PURPOSE : refreshs the user input for a given input area a.
*/
LOCAL void inp_refreshInput (T_AREA *a, T_INPUT *inp)
{
char outLine[MAX_INPUT_SIZE+1];
if (inp->aktInputType & IT_ECHO)
{
if (inp->aktInputCol+inp->aktInputIdx > a->dx)
wm_setCursor (a, TRUE,
inp->aktInputRow,
a->dx);
else
wm_setCursor (a, TRUE,
inp->aktInputRow,
(USHORT)(inp->aktInputCol+inp->aktInputIdx));
if (inp->aktInputType & IT_HIDDEN)
{
/*
* build a **** output
*/
memset (outLine, '*', inp->aktInputIdx);
outLine[inp->aktInputIdx] = NULL_TERM;
}
else
{
strncpy (outLine, inp->aktInput, MAX_INPUT_SIZE);
outLine[MAX_INPUT_SIZE] = NULL_TERM;
ksd_getPwdHidden (outLine, '.');
}
if (inp->aktInputCol+inp->aktInputIdx > a->dx)
wm_areaOutput (a, inp->aktInputRow,
inp->aktInputCol,
outLine+((inp->aktInputCol+inp->aktInputIdx)-a->dx));
else
wm_areaOutput (a, inp->aktInputRow, inp->aktInputCol, outLine);
/*
* cleanup the remaining characters in the display
*/
if (inp->aktInputIdx < inp->maxInputLen)
{
char blankLine[MAX_INPUT_SIZE+1];
/*
* build a blank output
*/
memset (blankLine, ' ', inp->maxInputLen-inp->aktInputIdx);
blankLine[inp->maxInputLen-inp->aktInputIdx] = NULL_TERM;
wm_areaOutput (a, inp->aktInputRow,
inp->aktInputCol+inp->aktInputIdx,
blankLine);
}
wm_areaRefresh (a);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_setInput |
+--------------------------------------------------------------------+
PURPOSE : sets the input string for the given input area.
*/
GLOBAL void inp_setInput (USHORT aHandle, char *inpString)
{
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_INPUT)
{
T_INPUT *inp = &inputTable[a->func];
strncpy (inp->aktInput, inpString, inp->maxInputLen);
inp->aktInputIdx = MINIMUM (inp->maxInputLen,
strlen (inpString));
inp->aktInput[inp->aktInputIdx+1] = NULL_TERM;
inp_refreshInput (a, inp);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_charToInput |
+--------------------------------------------------------------------+
PURPOSE : This function adds a character to the input string for
the area referenced by aHandle.
*/
GLOBAL void inp_charToInput (USHORT aHandle, char c)
{
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_INPUT)
{
T_INPUT *inp = &inputTable[a->func];
if (c NEQ NULL_TERM)
{
if (c EQ '\b')
{
/*
*-----------------------------------------------------------
* backspace - delete the last added character
*-----------------------------------------------------------
*/
if (inp->aktInputIdx > 0)
{
/*
*---------------------------------------------------------
* clear the last character in the LCD display and
* in the input string
*---------------------------------------------------------
*/
inp->aktInputIdx--;
inp->aktInput[inp->aktInputIdx] = NULL_TERM;
}
else
/*
*---------------------------------------------------------
* no action -> no refresh
*---------------------------------------------------------
*/
return;
}
else
{
/*
*-----------------------------------------------------------
* when IT_ALPHA is set:
* all characters are valid inputs
*
* when IT_ALPHA is not set and IT_NUMERIC is set:
* only the characters 0 1 2 3 4 5 6 7 8 9 * # + - <SPACE>
* are valid inputs
*
* when neither IT_ALPHA nor IT_NUMERIC is set:
* all characters are invalid inputs
*-----------------------------------------------------------
*/
if (
(
inp->aktInputType & IT_NUMERIC AND
!(inp->aktInputType & IT_ALPHA) AND
(c < '0' OR c > '9') AND
c NEQ '*' AND
c NEQ '#' AND
c NEQ '+' AND
c NEQ '-' AND
c NEQ ' '
)
OR
(
!(
inp->aktInputType & IT_NUMERIC OR
inp->aktInputType & IT_ALPHA
)
)
)
/*
*---------------------------------------------------------
* no action -> no refresh
*---------------------------------------------------------
*/
return;
if (inp->aktInputIdx < inp->maxInputLen)
{
inp->aktInput[inp->aktInputIdx++] = c;
inp->aktInput[inp->aktInputIdx] = NULL_TERM;
}
}
}
inp_refreshInput (a, inp);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_startInput |
+--------------------------------------------------------------------+
PURPOSE : Start the input of a string in the area referenced
by aHandle.
*/
GLOBAL void inp_startInput (USHORT aHandle,
UBYTE row,
UBYTE col,
char *prompt,
UBYTE length,
UBYTE type)
{
USHORT i=0;
T_INPUT *inp;
T_AREA *a = wm_getArea (aHandle);
if (numOfInputs < MAX_INPUTS
AND a NEQ NULL
AND a->funcType EQ FN_NONE)
{
while (i<MAX_INPUTS)
{
if (inputTable[i].free)
{
a->funcType = FN_INPUT;
inp = &inputTable[i];
inp->free = FALSE;
a->func = (UBYTE) i;
numOfInputs++;
break;
}
i++;
}
if (i < MAX_INPUTS)
{
inp->aktInputIdx = 0;
inp->aktInputRow = (int) row;
inp->aktInputCol = (int) col;
inp->aktInputType = type;
inp->maxInputLen = length;
wm_areaOutput (a, inp->aktInputRow,
inp->aktInputCol,
prompt);
inp->aktInputCol += strlen (prompt);
inp->aktInput[0] = NULL_TERM;
inp_charToInput (aHandle, NULL_TERM);
}
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_INP |
| STATE : code ROUTINE : inp_stopInput |
+--------------------------------------------------------------------+
PURPOSE : stops the input editing process for the area referenced
by aHandle.
*/
GLOBAL void inp_stopInput (USHORT aHandle)
{
T_AREA *a = wm_getArea (aHandle);
if (a NEQ NULL AND a->funcType EQ FN_INPUT)
{
a->funcType = FN_NONE;
if (!inputTable[a->func].free)
{
inputTable[a->func].free = TRUE;
numOfInputs--;
a->func = 0;
}
wm_clearArea (aHandle);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -