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

📄 tkeybd.c.svn-base

📁 最新火热的CX32 源代码
💻 SVN-BASE
字号:
/**
 *  This code and information is part of Trident DPTV API (TDAPI)
 *
 *  Copyright (C) Trident Multimedia Technologies (Shanghai) Co., Ltd.
 *         2002  All rights reserved.
 *
 *  This file provides functions for TV or demoboard keyboard.
 *
 *  Revision:
 *  08/01/2002     Created by Rick, York and Archie
 *
 */
#include "tdefs.h"
#include "tio.h"
#include "tvkey.h"
#include "ram.h"
#include "tvglobal.h"
#include "sysstate.h"
#include "source.h"

Gdata KeyboardDataStruct t_KeyboardData;

/**
 *
 *  Gets ADC Key code.
 *
 *  @param None.
 *  @return Virtual Key Code.
 *
 *  @see tdKeyboardScan
 *  @see c_aucKeyboardCommand
 *  @see c_aucKeyboardLevel
 *  @see c_KeyBoardLine
 */
Byte tdGetADCKeyCode(Void)
{
#ifndef _KEY_USEPORT_
    IByte uc;
#ifndef	_2Hdmi_3Scart_
    for (uc = 0; uc < _KEYBOARDLINE_NUM_; uc++)
#else
	uc = 1;
#endif
    {
        IByte uc2;
        IByte ucKeyBoardScan = tdGetADCValue(c_KeyBoardLine[uc]);
        for (uc2 = 0; uc2 < _KEYBOARDLEVEL_NUM_; uc2++)
            if (ucKeyBoardScan < c_aucKeyboardLevel[uc2])
            	{
//--------YYM 06/08/30 15:22 added for[]
        if( tv_Data.ucKeyLock && 
            (/*g_Data.ucSysState == SYSSTATE_STANDBY || */g_Data.ucSysState == SYSSTATE_NORMAL))
            		return _VK_KeyLock_;
//added end
                return c_aucKeyboardCommand[uc][uc2];
            	}
    }

    return _VK_NONE_;
#else
    return tdGetPortKeyValue();
#endif
}

/**
 *  Scans Keyboard, if there is a key pressed, adds the virtual key to key buffer.
 *
 *  @param  None.
 *  @return _TURE_    key pressed
 *  @return _FALSE_   no key pressed
 *
 *  @see tdGetADCKeyCode
 */
#ifdef NC30
// Remote simulator
#pragma ADDRESS s_ucRemoteKey 0400h
Byte s_ucRemoteKey;
#endif
Bool tdKeyboardScan(Void)//(Bool bLock)//C2_version
{
    IByte ucVirtualKey = tdGetADCKeyCode();
#ifdef NC30
    if( !ucVirtualKey )
        ucVirtualKey = s_ucRemoteKey;
#endif
    if ( ucVirtualKey )
    {
        if ( ucVirtualKey == t_KeyboardData.ucLastKey )
        {
            if ( t_KeyboardData.wFirstDelay &&
                //tdGetTickCount() - t_KeyboardData.dwLastTick > t_KeyboardData.wFirstDelay )
                tdCompareTickCount(t_KeyboardData.dwLastTick, t_KeyboardData.wFirstDelay))
            {
                if ( tdTestValBitTrue( t_DebugFlag, _BIT0_ ))
                    tdClearValBit( t_DebugFlag, _BIT0_ );
                else
                {
#ifdef _NEW_REPEATKEY_FUNC_
                    if(g_KeyInfo.bFastRepeatKeyEnable||g_KeyInfo.bSlowRepeatKeyEnable)
            	    {
            	        tdAddVirtualKey(ucVirtualKey);
                        g_KeyInfo.bRepeatKeyDown = _TRUE_;
                    }
#else
                    tdAddVirtualKey( ucVirtualKey /*| _VK_STATUS_DOWN_*/ );
#endif
                    //set g_KeyInfo.bKeyboardDown flag
                    g_KeyInfo.bKeyboardDown = _TRUE_;
                }

                if(g_KeyInfo.bSlowRepeatKeyEnable)
                    t_KeyboardData.dwLastTick = tdGetTickCount() - t_KeyboardData.wFirstDelay
                                                + t_KeyboardData.wRepeatDelay*4;
                else
                    t_KeyboardData.dwLastTick = tdGetTickCount() - t_KeyboardData.wFirstDelay
                                                + t_KeyboardData.wRepeatDelay;
            }
        }
        else
        {
            if ( tdTestValBitTrue( t_DebugFlag, _BIT0_ ))
                tdClearValBit( t_DebugFlag, _BIT0_ );
            else
            {
#ifdef _NEW_REPEATKEY_FUNC_
                g_KeyInfo.bFastRepeatKeyEnable = _FALSE_;
                g_KeyInfo.bSlowRepeatKeyEnable = _FALSE_;
                g_KeyInfo.bRepeatKeyDown = _FALSE_;
#endif
                tdSetKeyStatusUpFlag(_FALSE_);
                tdAddVirtualKey( ucVirtualKey );

                //set g_KeyInfo.bKeyboardDown flag
                g_KeyInfo.bKeyboardDown = _TRUE_;
            }

            t_KeyboardData.ucLastKey = ucVirtualKey;
            t_KeyboardData.dwLastTick = tdGetTickCount();
        }
        return _TRUE_;
    }
    else
    {
        if (g_KeyInfo.bKeyboardDown)
        {
            if (g_KeyInfo.bRepeatKeyDown)       //clear repeat key in fifo
                tdClearKeyInFIFO((FifoHandle)t_VirtualKeyBuffer, t_KeyboardData.ucLastKey);
            
            g_KeyInfo.bKeyboardDown = _FALSE_;
            g_KeyInfo.bRepeatKeyDown = _FALSE_;
            if (g_KeyInfo.bKeyStatusUpEnable)
                tdAddVirtualKey(t_KeyboardData.ucLastKey | _VK_STATUS_UP_);
        }
        
        t_KeyboardData.ucLastKey = 0;
        return _FALSE_;
    }
}

⌨️ 快捷键说明

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