Added various GameButton_Invalid checks to InputMapper to make its functions give rational results instead of crashing.

This commit is contained in:
Kyzentun Keeslala
2016-03-23 23:10:21 -06:00
parent 6a73cdd1ba
commit 2c54b474bb
+40
View File
@@ -898,6 +898,10 @@ void InputMapper::MenuToGame( GameButton MenuI, PlayerNumber pn, vector<GameInpu
bool InputMapper::IsBeingPressed( const GameInput &GameI, MultiPlayer mp, const DeviceInputList *pButtonState ) const
{
if(GameI.button == GameButton_Invalid)
{
return false;
}
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
{
DeviceInput DeviceI;
@@ -916,6 +920,10 @@ bool InputMapper::IsBeingPressed( const GameInput &GameI, MultiPlayer mp, const
bool InputMapper::IsBeingPressed( GameButton MenuI, PlayerNumber pn ) const
{
if(MenuI == GameButton_Invalid)
{
return false;
}
vector<GameInput> GameI;
MenuToGame( MenuI, pn, GameI );
for( size_t i=0; i<GameI.size(); i++ )
@@ -937,6 +945,10 @@ bool InputMapper::IsBeingPressed(const vector<GameInput>& GameI, MultiPlayer mp,
void InputMapper::RepeatStopKey( const GameInput &GameI )
{
if(GameI.button == GameButton_Invalid)
{
return;
}
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
{
DeviceInput DeviceI;
@@ -948,6 +960,10 @@ void InputMapper::RepeatStopKey( const GameInput &GameI )
void InputMapper::RepeatStopKey( GameButton MenuI, PlayerNumber pn )
{
if(MenuI == GameButton_Invalid)
{
return;
}
vector<GameInput> GameI;
MenuToGame( MenuI, pn, GameI );
for( size_t i=0; i<GameI.size(); i++ )
@@ -956,6 +972,10 @@ void InputMapper::RepeatStopKey( GameButton MenuI, PlayerNumber pn )
float InputMapper::GetSecsHeld( const GameInput &GameI, MultiPlayer mp ) const
{
if(GameI.button == GameButton_Invalid)
{
return 0.f;
}
float fMaxSecsHeld = 0;
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
@@ -974,6 +994,10 @@ float InputMapper::GetSecsHeld( const GameInput &GameI, MultiPlayer mp ) const
float InputMapper::GetSecsHeld( GameButton MenuI, PlayerNumber pn ) const
{
if(MenuI == GameButton_Invalid)
{
return 0.f;
}
float fMaxSecsHeld = 0;
vector<GameInput> GameI;
@@ -986,6 +1010,10 @@ float InputMapper::GetSecsHeld( GameButton MenuI, PlayerNumber pn ) const
void InputMapper::ResetKeyRepeat( const GameInput &GameI )
{
if(GameI.button == GameButton_Invalid)
{
return;
}
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
{
DeviceInput DeviceI;
@@ -996,6 +1024,10 @@ void InputMapper::ResetKeyRepeat( const GameInput &GameI )
void InputMapper::ResetKeyRepeat( GameButton MenuI, PlayerNumber pn )
{
if(MenuI == GameButton_Invalid)
{
return;
}
vector<GameInput> GameI;
MenuToGame( MenuI, pn, GameI );
for( size_t i=0; i<GameI.size(); i++ )
@@ -1004,6 +1036,10 @@ void InputMapper::ResetKeyRepeat( GameButton MenuI, PlayerNumber pn )
float InputMapper::GetLevel( const GameInput &GameI ) const
{
if(GameI.button == GameButton_Invalid)
{
return 0.f;
}
float fLevel = 0;
for( int i=0; i<NUM_GAME_TO_DEVICE_SLOTS; i++ )
{
@@ -1017,6 +1053,10 @@ float InputMapper::GetLevel( const GameInput &GameI ) const
float InputMapper::GetLevel( GameButton MenuI, PlayerNumber pn ) const
{
if(MenuI == GameButton_Invalid)
{
return 0.f;
}
vector<GameInput> GameI;
MenuToGame( MenuI, pn, GameI );