Refactored the input display menu to allow for dynamic changing of row displays. Remove controller specific keybinding menu, integrating with initial keyboard menu.

This commit is contained in:
2024-02-07 17:58:29 -06:00
parent 2da6c455b6
commit 3fff17417e
14 changed files with 59 additions and 73 deletions
+27
View File
@@ -554,4 +554,31 @@ void InputGroup::AddPrimaryKeybind(Input key){
void InputGroup::SetNewPrimaryKeybind(Input key){
RemovePrimaryKeybind(key.GetType());
AddPrimaryKeybind(key);
}
void InputListener::Update(){
#pragma region New controller input binding listener
using A=Attribute;
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]&&!Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //We are requesting a brand new controller input.
if(InputGroup::menuNamesToInputGroups.count(Menu::menus[NEW_INPUT]->S(A::KEYBIND))){
for(GamePad*gamepad:GamePad::getGamepads()){
for(size_t button=0;bool hasButton:gamepad->availableButtons){
GPButtons releasedButton=olc::GPButtons(button);
if(hasButton&&gamepad->getButton(releasedButton).bReleased){
if(releasedButton==GPButtons::SELECT){ //If we hit select we don't bother with setting the input and leave immediately.
Menu::CloseMenu();
return;
}
InputGroup::menuNamesToInputGroups[Menu::menus[NEW_INPUT]->S(A::KEYBIND)]->SetNewPrimaryKeybind(Input{CONTROLLER,int(button)});
Menu::alreadyClicked=true;
Menu::CloseMenu();
return;
}
button++;
}
}
}
}
#pragma endregion
}