📄 aphearsaykey.c
字号:
/****************************************************************************/
/* */
/* Copyright (C) 2005 SHENZHEN MEIJIN CO.LTD */
/* */
/* FILE NAME: ApHearSayKey.c */
/* MODULE NAME: AP应用程序 */
/* DESCRIPTION: Hearsya command */
/* */
/* FUNCTIONS: */
/* */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* DennyHan 2006-03-13 V1.00B */
/****************************************************************************/
// 包含必要的头文件
#include "Ap.h"
#include "ApHearSay.h"
#include "ApHearSayHook.h"
//=====================================
// Global
extern RrParam g_RrParam;
//==================================================================
// KeyUp /down/ pageup/pagedon
INT HearSayEvent_KeyUp ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
INT nRet;
nRet=0;
if ( (!(g_RrParam.wRptMode&RR_MODE_NOMST)) )
{ // if MST
if (!(g_RrParam.wRptMode & RR_MODE_AUTOMATIC ) )
{ // if A-B mode
#if 0
GraphDisableRefresh();
HearSayBrowserProc(pGui,uEvent,uParam);
ApHsSetTextOffset();
DrawCurrentAp();
GraphEnableRefresh();
#endif
}
else
{ // Auto Mode
if (!g_RrParam.bMarkFlag)
{ // if auto mode and not in mark mode
// Disable the key
#ifdef APHS_AUTO_KEY_VIEW_DIS
nRet = 1;
#endif
}
}
}
return nRet;
}
//=========================================================================
// Left and right key
INT HearSayEvent_KeyLeftRight ( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
UINT uParam2;
if (g_RrParam.bMarkFlag)
{
return 0;
}
uParam2=READKB_VALUE(uParam);
if ( (READKB_SHIFTMASK(uParam)) )
{ // Mark to mark
return HearSayEvent_C4 (pGui, uEvent,uParam );
}
if ( (g_RrParam.wSndMode&APHS_SOUND_REC)
||(g_RrParam.wSndMode&APHS_SOUND_PLAYREC) )
{ // if sound is play
//nRet=1;
ApHsHint((const char *)APHS_CUROP_INVALID);
}
else
{
UINT16 xStep;
UINT16 xDiff;
if ((g_RrParam.wRptMode&RR_MODE_NOMST))
{
xStep=ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
xDiff=2*g_RrParam.aPlay[0].wTotalStep/100;
if (!xDiff)
{
xDiff++;
}
if (uParam2==MVK_RIGHT)
{
xStep +=xDiff;
}
else
{
xStep -=xDiff;
}
g_RrParam.aPlay[0].dwPlayTm = ApHSGetTmFromStep(xStep);
}
else
{
// Here xStep is Node
xStep=ApHsGetTextTimeNode();
if (uParam2==MVK_RIGHT)
{
xStep +=1;
}
else
{
if (xStep>0)
xStep--;
}
g_RrParam.aPlay[0].dwPlayTm = ApHsGetTextNodeTime(xStep);
}
// Skip 0.1s Display refresh current
ApHSDisableTimerRefreshMst();
ApHsSetPlayTm(0); // Set the current Time
if ( (!(g_RrParam.wRptMode&RR_MODE_NOMST)) )
//if (g_RrParam.wRptMode& RR_MODE_AUTOMATIC)
{
ApHsSetTextOffset();
}
if ( g_RrParam.wSndMode &APHS_REPEAT)
{
return HearSayEvent_KeyAB(pGui, EVENT_KEY,'B');
}
DrawCurrentAp();
}
return 1;
}
//==========================================================================
// Key Set AB time
static BOOL HearSayEvent_KeyABSet(UINT uParam,BOOL bKeyA)
{
BOOL bRet;
//UINT16 xStep;
bRet = FALSE;
// Set AB Point
if ( uParam == 'A')
{ // if A
g_RrParam.wTmABSetFlag |= APHS_TMA_SET;
if ( !(g_RrParam.wSndMode &APHS_REPEAT) )
{ // if not repeat play mode
if (bKeyA)
{ // if one Key A, Clear b
g_RrParam.wTmABSetFlag &= (~APHS_TMB_SET);
// Cancel backup AB
ApHsClrBakABPlay();
}
//xStep = ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
//ApHSSetTmAStep(xStep);
g_RrParam.dwTmA = g_RrParam.aPlay[0].dwPlayTm;
}
else
{
if ( (g_RrParam.wTmABSetFlag &APHS_TMB_SET)
&&(g_RrParam.aPlay[0].dwPlayTm > g_RrParam.dwTmB) )
{ // AB Switch Position
//xStep=ApHSGetTmXStep(g_RrParam.dwTmB);
//ApHSSetTmAStep(xStep);
g_RrParam.dwTmA = g_RrParam.dwTmB;
//xStep=ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
//ApHSSetTmBStep(xStep);
g_RrParam.dwTmB = g_RrParam.aPlay[0].dwPlayTm;
}
else
{
//xStep=ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
//ApHSSetTmAStep(xStep);
g_RrParam.dwTmA = g_RrParam.aPlay[0].dwPlayTm;
}
}
bRet = TRUE;
if (bKeyA)
{
g_RrParam.wTmABSetFlag |= APHS_TMA_KEY_SET;
}
}
else
{ // if B
if (g_RrParam.aPlay[0].dwPlayTm != g_RrParam.dwTmA)
{
if (g_RrParam.aPlay[0].dwPlayTm > g_RrParam.dwTmA)
{ // B
//xStep=ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
//ApHSSetTmBStep(xStep);
g_RrParam.dwTmB = g_RrParam.aPlay[0].dwPlayTm;
}
else
{ // Error for setting B>A
// Hint B<A
//xStep=ApHSGetTmXStep(g_RrParam.dwTmA);
//ApHSSetTmBStep(xStep);
g_RrParam.dwTmB = g_RrParam.dwTmA;
//xStep=ApHSGetTmXStep(g_RrParam.aPlay[0].dwPlayTm);
//ApHSSetTmAStep(xStep);
g_RrParam.dwTmA = g_RrParam.aPlay[0].dwPlayTm;
}
g_RrParam.wTmABSetFlag |= APHS_TMB_SET;
bRet = TRUE;
}
}
return bRet;
}
//--------------------------
INT HearSayEvent_KeyAB( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
BOOL bKeyA;
UINT uParam2;
BOOL bSetValid;
if (g_RrParam.wRptMode& RR_MODE_MANUAL)
{
if ( !(g_RrParam.wSndMode&(APHS_SOUND_REC|APHS_SOUND_PLAYREC)) )
{ // if not record or play record
uParam2=READKB_VALUE(uParam);
bSetValid = FALSE;
ApHsGetPlayTm(0); // Get the current Time
bKeyA = TRUE;
if (uParam2==APHS_KEY_A_EXP)
{
uParam2 = 'A';
bKeyA = FALSE;
}
// To Upper Case
uParam2 = toupper(uParam2);
if ( !(g_RrParam.wSndMode&APHS_SOUND_PLAY) )
{ // if Stop Status
if ( ( uParam2=='B')
&& (!(g_RrParam.wTmABSetFlag &APHS_TMA_KEY_SET) ) )
{ // if stop and no AB
ApHsHint((const char *)APHS_CUROP_A_NEEDED);
return 1;
}
// Set AB Point
bSetValid = HearSayEvent_KeyABSet(uParam2,bKeyA);
if ( (uParam2=='B')
&& (bSetValid ) )
{
return HearSayEvent_C2(pGui, EVENT_COMMAND, HEARSAY_BTN2_CMD);
}
}
else if (g_RrParam.wSndMode &APHS_REPEAT)
{ // if Repeat Play mode
bSetValid = HearSayEvent_KeyABSet(uParam2,bKeyA);
if ( bSetValid )
{
return HearSayEvent_C2(pGui, EVENT_COMMAND, HEARSAY_BTN2_CMD);
}
}
else
{ // if normal play mode
bSetValid = HearSayEvent_KeyABSet(uParam2,bKeyA);
if ( uParam2 == 'A' )
{
ApHsClrBakABPlay();
}
else
{
if ( bSetValid )
{
return HearSayEvent_C2(pGui, EVENT_COMMAND, HEARSAY_BTN2_CMD);
}
}
}
DrawCurrentAp();
}
}
return 1;
}
//======================================================================
// Set param
INT HearSayEvent_KeySet( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
return HearSayEvent_C5(pGui,EVENT_COMMAND,HEARSAY_BTN5_CMD);
}
//===========================================================================
// Set param
// DICT_RETURN_DICTLIST
// DICT_RETURN_DVIEWER
// DICT_RETURN_ERROR
//--------------------------------------------
#include "..\\..\\..\\ApDict\\Dict.h"
extern INT DictSkipWord( UINT8* pString, INT* pRet);
#define ApHSJump(r,p) DictSkipWord(p,r)
//
//-----------------------------------------
//
INT HearSayEvent_KeyEnter( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
INT nJumpRet;
INT nRet;
UINT8 *pBuf;
UINT8 *pSt,*pEnd;
if (!(g_RrParam.bMarkFlag))
{
if (ApHsSndIsBusy())
{// Stop
return HearSayEvent_CStop(pGui,EVENT_COMMAND,HEARSAY_BTN7_CMD);
}
else
{//play
return HearSayEvent_CPlay(pGui,EVENT_COMMAND,HEARSAY_BTN1_CMD);
}
}
else
{
//
if (!BrowserGetMarkPos( (MBrowser*) g_RrParam.pBwrGui,&pSt,&pEnd))
{
return 1;
}
pBuf=g_RrParam.pTBuf;
memmove(pBuf,pSt,(INT)(pEnd-pSt));
pBuf[(INT)(pEnd-pSt)] = '\0';
//==============================
ApHsGetPlayTm(0);
ApHsClosePlay(0);
//==============================
nRet=ApHSJump(&nJumpRet,pBuf);
//==============================
ApHsOpenPlay(0);
ApHsSetPlayTm(0);
//==============================
//APHsStopMark();
if (nJumpRet!=DICT_RETURN_DICTLIST)
{
DrawCurrentAp();
//ExitAp(nRet);
}
else
{
if ( (nRet != EXIT_CODE_NORMAL)
&&(nRet != EXIT_CODE_ERROR) )
{
ExitAp(EXIT_CODE_NORMAL);
}
else
{
// if no Jump Seek
DrawCurrentAp();
}
}
}
return 1;
}
//======================================================================
// KeyEsc param
// Only used for mark and Record
//-----------------
INT HearSayEvent_KeyEsc( APGUI_STRUCT *pGui, UINT uEvent, UINT uParam )
{
if (g_RrParam.bMarkFlag)
{
APHsStopMark();
return 1;
}
if (g_RrParam.wSndMode&APHS_SOUND_REC)
{
return HearSayEvent_C3(pGui, EVENT_COMMAND,CMD_HS_FOLLOW_RECEND);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -