Skip to content

Commit a60c96c

Browse files
committed
Fixed gamepad button assertion failure caused by an action not being bound to a gamepad button
1 parent f208864 commit a60c96c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

GamepadBindingCollection.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ bool GamepadBindingCollection::AddMappingWithButton( SDL_GameControllerButton bu
4141
return false;
4242
} else {
4343
if ( BindAction( action, button, overwrite ) ) {
44+
std::cout << "ddas" << static_cast<int>( action ) << std::endl;
45+
std::cout << "ddasr" << static_cast<int>( m_ActionToButton.size() ) << std::endl;
4446
// Bound button
4547
LogInput( "Bound button \"" + rString( SDL_GameControllerGetStringForButton( button ) ) + "\" to action \"" +
4648
g_KeyBindings.GetDescription( action ) + "\"",
@@ -105,6 +107,8 @@ bool GamepadBindingCollection::BindAction( ActionIdentifier action, SDL_GameCont
105107
}
106108

107109
SDL_GameControllerButton GamepadBindingCollection::GetButtonFromAction( ActionIdentifier action ) const {
108-
assert( static_cast<int>( action ) < m_ActionToButton.size( ) );
110+
if ( static_cast<size_t>( static_cast<int>( action ) ) >= m_ActionToButton.size( ) ) {
111+
return SDL_CONTROLLER_BUTTON_INVALID;
112+
}
109113
return m_ActionToButton.at( static_cast<int>( action ) );
110114
}

0 commit comments

Comments
 (0)