Add automap feature for GC adapter

This commit is contained in:
german 2020-09-01 18:17:59 -05:00
parent 540c05072e
commit 9f70da1a9b
3 changed files with 103 additions and 1 deletions

View file

@ -22,7 +22,7 @@ namespace InputCommon {
struct InputSubsystem::Impl {
void Initialize() {
auto gcadapter = std::make_shared<GCAdapter::Adapter>();
gcadapter = std::make_shared<GCAdapter::Adapter>();
gcbuttons = std::make_shared<GCButtonFactory>(gcadapter);
Input::RegisterFactory<Input::ButtonDevice>("gcpad", gcbuttons);
gcanalog = std::make_shared<GCAnalogFactory>(gcadapter);
@ -82,6 +82,8 @@ struct InputSubsystem::Impl {
#endif
auto udp_devices = udp->GetInputDevices();
devices.insert(devices.end(), udp_devices.begin(), udp_devices.end());
auto gcpad_devices = gcadapter->GetInputDevices();
devices.insert(devices.end(), gcpad_devices.begin(), gcpad_devices.end());
return devices;
}
@ -94,6 +96,9 @@ struct InputSubsystem::Impl {
// TODO consider returning the SDL key codes for the default keybindings
return {};
}
if (params.Get("class", "") == "gcpad") {
return gcadapter->GetAnalogMappingForDevice(params);
}
#ifdef HAVE_SDL2
if (params.Get("class", "") == "sdl") {
return sdl->GetAnalogMappingForDevice(params);
@ -111,6 +116,9 @@ struct InputSubsystem::Impl {
// TODO consider returning the SDL key codes for the default keybindings
return {};
}
if (params.Get("class", "") == "gcpad") {
return gcadapter->GetButtonMappingForDevice(params);
}
#ifdef HAVE_SDL2
if (params.Get("class", "") == "sdl") {
return sdl->GetButtonMappingForDevice(params);
@ -141,6 +149,7 @@ struct InputSubsystem::Impl {
std::shared_ptr<UDPMotionFactory> udpmotion;
std::shared_ptr<UDPTouchFactory> udptouch;
std::shared_ptr<CemuhookUDP::Client> udp;
std::shared_ptr<GCAdapter::Adapter> gcadapter;
};
InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}