input_common: Allow keyboard to be backwards compatible

This commit is contained in:
german77 2021-11-14 10:45:07 -06:00 committed by Narr the Reg
parent b673857d7d
commit bca299e8e0
10 changed files with 115 additions and 48 deletions

View file

@ -28,6 +28,10 @@ void MappingFactory::RegisterInput(const MappingData& data) {
if (!is_enabled) {
return;
}
if (!IsDriverValid(data)) {
return;
}
switch (input_type) {
case Polling::InputType::Button:
RegisterButton(data);
@ -168,4 +172,25 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
input_queue.Push(new_input);
}
bool MappingFactory::IsDriverValid(const MappingData& data) const {
// Only port 0 can be mapped on the keyboard
if (data.engine == "keyboard" && data.pad.port != 0) {
return false;
}
// The following drivers don't need to be mapped
if (data.engine == "tas") {
return false;
}
if (data.engine == "touch") {
return false;
}
if (data.engine == "touch_from_button") {
return false;
}
if (data.engine == "analog_from_button") {
return false;
}
return true;
}
} // namespace InputCommon