RepeatStopKey: stop repeating a key until it's released
This commit is contained in:
@@ -43,6 +43,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeviceInputList g_CurrentState;
|
DeviceInputList g_CurrentState;
|
||||||
|
set<DeviceInput> g_DisableRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -178,6 +179,9 @@ void InputFilter::CheckButtonChange( ButtonState &bs, DeviceInput di, const Rage
|
|||||||
|
|
||||||
di.ts = bs.m_BeingHeldTime;
|
di.ts = bs.m_BeingHeldTime;
|
||||||
ReportButtonChange( di, bs.m_bLastReportedHeld? IET_FIRST_PRESS:IET_RELEASE );
|
ReportButtonChange( di, bs.m_bLastReportedHeld? IET_FIRST_PRESS:IET_RELEASE );
|
||||||
|
|
||||||
|
if( !bs.m_bLastReportedHeld )
|
||||||
|
g_DisableRepeat.erase( di );
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputFilter::ReportButtonChange( const DeviceInput &di, InputEventType t )
|
void InputFilter::ReportButtonChange( const DeviceInput &di, InputEventType t )
|
||||||
@@ -245,6 +249,10 @@ void InputFilter::Update( float fDeltaTime )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If repeats are disabled for this button, skip. */
|
||||||
|
if( g_DisableRepeat.find(di) != g_DisableRepeat.end() )
|
||||||
|
continue;
|
||||||
|
|
||||||
const float fOldHoldTime = bs.m_fSecsHeld;
|
const float fOldHoldTime = bs.m_fSecsHeld;
|
||||||
bs.m_fSecsHeld += fDeltaTime;
|
bs.m_fSecsHeld += fDeltaTime;
|
||||||
const float fNewHoldTime = bs.m_fSecsHeld;
|
const float fNewHoldTime = bs.m_fSecsHeld;
|
||||||
@@ -320,6 +328,19 @@ void InputFilter::ResetKeyRepeat( const DeviceInput &di )
|
|||||||
GetButtonState( di ).m_fSecsHeld = 0;
|
GetButtonState( di ).m_fSecsHeld = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stop repeating the specified key until released. */
|
||||||
|
void InputFilter::RepeatStopKey( const DeviceInput &di )
|
||||||
|
{
|
||||||
|
LockMut(*queuemutex);
|
||||||
|
|
||||||
|
/* If the button is up, do nothing. */
|
||||||
|
ButtonState &bs = GetButtonState( di );
|
||||||
|
if( !bs.m_bLastReportedHeld )
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_DisableRepeat.insert( di );
|
||||||
|
}
|
||||||
|
|
||||||
void InputFilter::GetInputEvents( vector<InputEvent> &array )
|
void InputFilter::GetInputEvents( vector<InputEvent> &array )
|
||||||
{
|
{
|
||||||
array.clear();
|
array.clear();
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
void SetRepeatRate( float fDelay, float fRepeatRate );
|
void SetRepeatRate( float fDelay, float fRepeatRate );
|
||||||
void ResetRepeatRate();
|
void ResetRepeatRate();
|
||||||
void ResetKeyRepeat( const DeviceInput &di );
|
void ResetKeyRepeat( const DeviceInput &di );
|
||||||
|
void RepeatStopKey( const DeviceInput &di );
|
||||||
|
|
||||||
// If aButtonState is NULL, use the last reported state.
|
// If aButtonState is NULL, use the last reported state.
|
||||||
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
|
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
|
||||||
|
|||||||
@@ -811,6 +811,26 @@ bool InputMapper::IsBeingPressed( const MenuInput &MenuI, PlayerNumber pn )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputMapper::RepeatStopKey( const GameInput &GameI )
|
||||||
|
{
|
||||||
|
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
|
||||||
|
{
|
||||||
|
DeviceInput DeviceI;
|
||||||
|
|
||||||
|
if( GameToDevice( GameI, i, DeviceI ) )
|
||||||
|
INPUTFILTER->RepeatStopKey( DeviceI );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputMapper::RepeatStopKey( MenuButton MenuI, PlayerNumber pn )
|
||||||
|
{
|
||||||
|
GameInput GameI[4];
|
||||||
|
MenuToGame( MenuI, pn, GameI );
|
||||||
|
for( int i=0; i<4; i++ )
|
||||||
|
if( GameI[i].IsValid() )
|
||||||
|
RepeatStopKey( GameI[i] );
|
||||||
|
}
|
||||||
|
|
||||||
float InputMapper::GetSecsHeld( const GameInput &GameI, MultiPlayer mp )
|
float InputMapper::GetSecsHeld( const GameInput &GameI, MultiPlayer mp )
|
||||||
{
|
{
|
||||||
float fMaxSecsHeld = 0;
|
float fMaxSecsHeld = 0;
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ public:
|
|||||||
void ResetKeyRepeat( const GameInput &GameI );
|
void ResetKeyRepeat( const GameInput &GameI );
|
||||||
void ResetKeyRepeat( const MenuInput &MenuI, PlayerNumber pn );
|
void ResetKeyRepeat( const MenuInput &MenuI, PlayerNumber pn );
|
||||||
|
|
||||||
|
void RepeatStopKey( const GameInput &GameI );
|
||||||
|
void RepeatStopKey( MenuButton MenuI, PlayerNumber pn );
|
||||||
|
|
||||||
struct Mapping
|
struct Mapping
|
||||||
{
|
{
|
||||||
bool IsEndMarker() const { return iSlotIndex==-1; }
|
bool IsEndMarker() const { return iSlotIndex==-1; }
|
||||||
|
|||||||
Reference in New Issue
Block a user