代码拉取完成,页面将自动刷新
//========= Copyright ?1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "KeyRepeat.h"
#include "Controls.h"
#include <vgui/ISystem.h>
#include <tier0/dbg.h>
// memdbgon must be the last include file in a .cpp file
#include <tier0/memdbgon.h>
using namespace vgui2;
vgui2::KeyCode g_iCodesForAliases[FM_NUM_KEYREPEAT_ALIASES];
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CKeyRepeatHandler::KeyDown( vgui2::KeyCode code )
{
int iIndex = GetIndexForCode(code);
if ( iIndex == -1 )
return;
if ( m_bAliasDown[ iIndex ] )
return;
Reset();
m_bAliasDown[ iIndex ] = true;
m_flNextKeyRepeat = system()->GetCurrentTime() + 0.4;
m_bHaveKeyDown = true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CKeyRepeatHandler::KeyUp( vgui2::KeyCode code )
{
int iIndex = GetIndexForCode(code);
if ( iIndex == -1 )
return;
m_bAliasDown[ GetIndexForCode(code) ] = false;
m_bHaveKeyDown = false;
for ( int i = 0; i < FM_NUM_KEYREPEAT_ALIASES; i++ )
{
if ( m_bAliasDown[i] )
{
m_bHaveKeyDown = true;
break;
}
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
vgui2::KeyCode CKeyRepeatHandler::KeyRepeated( void )
{
if ( IsPC() )
return BUTTON_CODE_NONE;
if ( !m_bHaveKeyDown )
return BUTTON_CODE_NONE;
if ( m_flNextKeyRepeat < system()->GetCurrentTime() )
{
for ( int i = 0; i < FM_NUM_KEYREPEAT_ALIASES; i++ )
{
if ( m_bAliasDown[i] )
{
m_flNextKeyRepeat = system()->GetCurrentTime() + m_flRepeatTimes[i];
return g_iCodesForAliases[i];
}
}
}
return BUTTON_CODE_NONE;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CKeyRepeatHandler::SetKeyRepeatTime( vgui2::KeyCode code, float flRepeat )
{
int iIndex = GetIndexForCode(code);
Assert( iIndex != -1 );
m_flRepeatTimes[ iIndex ] = flRepeat;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。