From c5e257017f6ffb888534af1ebbc34fffd7a35a2e Mon Sep 17 00:00:00 2001 From: german Date: Tue, 1 Sep 2020 18:17:59 -0500 Subject: Add automap feature for GC adapter --- src/input_common/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 062ec66b5..8da829132 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -22,7 +22,7 @@ namespace InputCommon { struct InputSubsystem::Impl { void Initialize() { - auto gcadapter = std::make_shared(); + gcadapter = std::make_shared(); gcbuttons = std::make_shared(gcadapter); Input::RegisterFactory("gcpad", gcbuttons); gcanalog = std::make_shared(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 udpmotion; std::shared_ptr udptouch; std::shared_ptr udp; + std::shared_ptr gcadapter; }; InputSubsystem::InputSubsystem() : impl{std::make_unique()} {} -- cgit v1.2.3