gcadapter: Implement auto map feature

Implements the auto map functionality for the GC adapter.
The controls map nicely to the original 3ds controls, with the select button being mapped to the Z button on GC.
The ZL/ZR buttons are not mapped by this feature.
This commit is contained in:
ameerj
2021-03-12 14:32:30 -05:00
parent 161e6a541b
commit a80e566464
7 changed files with 85 additions and 20 deletions

View File

@ -91,16 +91,30 @@ std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left,
return circle_pad_param.Serialize();
}
Common::ParamPackage GetSDLControllerButtonBindByGUID(const std::string& guid, int port,
int button) {
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerButtonBindByGUID(
guid, port, static_cast<Settings::NativeButton::Values>(button));
Common::ParamPackage GetControllerButtonBinds(const Common::ParamPackage& params, int button) {
const auto native_button{static_cast<Settings::NativeButton::Values>(button)};
const auto engine{params.Get("engine", "")};
if (engine == "sdl") {
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerButtonBindByGUID(
params.Get("guid", "0"), params.Get("port", 0), native_button);
}
if (engine == "gcpad") {
return gcbuttons->GetGcTo3DSMappedButton(params.Get("port", 0), native_button);
}
return {};
}
Common::ParamPackage GetSDLControllerAnalogBindByGUID(const std::string& guid, int port,
int analog) {
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerAnalogBindByGUID(
guid, port, static_cast<Settings::NativeAnalog::Values>(analog));
Common::ParamPackage GetControllerAnalogBinds(const Common::ParamPackage& params, int analog) {
const auto native_analog{static_cast<Settings::NativeAnalog::Values>(analog)};
const auto engine{params.Get("engine", "")};
if (engine == "sdl") {
return dynamic_cast<SDL::SDLState*>(sdl.get())->GetSDLControllerAnalogBindByGUID(
params.Get("guid", "0"), params.Get("port", 0), native_analog);
}
if (engine == "gcpad") {
return gcanalog->GetGcTo3DSMappedAnalog(params.Get("port", 0), native_analog);
}
return {};
}
void ReloadInputDevices() {