Added debug menu option for resetting key mappings to default. Added sanity checking requirement to ScreenMapControllers.
This commit is contained in:
@@ -661,6 +661,67 @@ void InputMapper::ResetMappingsToDefault()
|
||||
AddDefaultMappingsForCurrentGameIfUnmapped();
|
||||
}
|
||||
|
||||
void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& full_reason, RString const& sub_reason)
|
||||
{
|
||||
vector<GameInput> inputs;
|
||||
bool exists= false;
|
||||
// Only player 1 is checked because the player 2 buttons are rarely
|
||||
// unmapped and do not exist on some keyboard models. -Kyz
|
||||
GetInputScheme()->MenuButtonToGameInputs(menu, PLAYER_1, inputs);
|
||||
if(!inputs.empty())
|
||||
{
|
||||
vector<DeviceInput> device_inputs;
|
||||
FOREACH(GameInput, inputs, inp)
|
||||
{
|
||||
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
|
||||
{
|
||||
device_inputs.push_back(m_mappings.m_GItoDI[inp->controller][inp->button][slot]);
|
||||
}
|
||||
}
|
||||
FOREACH(DeviceInput, device_inputs, inp)
|
||||
{
|
||||
if(!inp->IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int use_count= 0;
|
||||
FOREACH_ENUM(GameController, cont)
|
||||
{
|
||||
FOREACH_GameButtonInScheme(GetInputScheme(), gb)
|
||||
{
|
||||
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
|
||||
{
|
||||
use_count+= ((*inp) == m_mappings.m_GItoDI[cont][gb][slot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the device input is used more than once, it's a case where a
|
||||
// default mapped key was remapped to some other game button. -Kyz
|
||||
if(use_count == 1)
|
||||
{
|
||||
exists= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!exists)
|
||||
{
|
||||
full_reason.push_back(sub_reason);
|
||||
}
|
||||
}
|
||||
|
||||
void InputMapper::SanityCheckMappings(vector<RString>& reason)
|
||||
{
|
||||
// This is just to check whether the current mapping has the minimum
|
||||
// necessary to navigate the menus so the user can reach the config screen.
|
||||
// For this purpose, only the following keys are needed:
|
||||
// MenuLeft, MenuRight, Start, Operator
|
||||
// The InputScheme handles OnlyDedicatedMenuButtons logic. -Kyz
|
||||
CheckButtonAndAddToReason(GAME_BUTTON_MENULEFT, reason, "MenuLeftMissing");
|
||||
CheckButtonAndAddToReason(GAME_BUTTON_MENURIGHT, reason, "MenuRightMissing");
|
||||
CheckButtonAndAddToReason(GAME_BUTTON_START, reason, "StartMissing");
|
||||
CheckButtonAndAddToReason(GAME_BUTTON_OPERATOR, reason, "OperatorMissing");
|
||||
}
|
||||
|
||||
static LocalizedString CONNECTED ( "InputMapper", "Connected" );
|
||||
static LocalizedString DISCONNECTED ( "InputMapper", "Disconnected" );
|
||||
static LocalizedString AUTOMAPPING_ALL_JOYSTICKS ( "InputMapper", "Auto-mapping all joysticks." );
|
||||
|
||||
Reference in New Issue
Block a user