| 24 | } |
| 25 | |
| 26 | Result Insert(std::unique_ptr<IController>&& controllerPtr) |
| 27 | { |
| 28 | std::unique_ptr<SwitchVirtualGamepadHandler> switchHandler; |
| 29 | if (UseAbstractedPad) |
| 30 | { |
| 31 | switchHandler = std::make_unique<SwitchAbstractedPadHandler>(std::move(controllerPtr)); |
| 32 | WriteToLog("Inserting controller as abstracted pad"); |
| 33 | } |
| 34 | else |
| 35 | { |
| 36 | switchHandler = std::make_unique<SwitchHDLHandler>(std::move(controllerPtr)); |
| 37 | WriteToLog("Inserting controller as HDLs"); |
| 38 | } |
| 39 | |
| 40 | Result rc = switchHandler->Initialize(); |
| 41 | if (R_SUCCEEDED(rc)) |
| 42 | { |
| 43 | SwitchUtils::ScopedLock scoped_lock(controllerMutex); |
| 44 | controllerHandlers.push_back(std::move(switchHandler)); |
| 45 | } |
| 46 | |
| 47 | return rc; |
| 48 | } |
| 49 | |
| 50 | std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>>& Get() |
| 51 | { |
no test coverage detected