getRemoteControl(uid:removedCallback:) returns directly the remote control, its closure is called when the remote control instance is deinitialized.
The parameter of the closure removedCallback is the remote control UID as String.
getPeripheral(_:observer:) will not call the observer if the reference returned is destroyed, you should keep it.
The working code should be :
// Keep the reference to the peripheral :
private var skyCtrl3Gamepad: Ref<SkyCtrl3Gamepad>?
...
let rc = groundSdk.getRemoteControl(uid: skyUid)
if let rc = rc {
skyCtrl3Gamepad = rc.getPeripheral(Peripherals.skyCtrl3Gamepad) { skyController3 in
skyController3?.axisEventListener = { (event, value) in
print("Event: \(event.description) - Value: \(value)")
}
skyController3?.buttonEventListener = { (event, value) in
print("Event: \(event.description) - Value: \(value.rawValue)")
}
skyController3?.grab(buttons: SkyCtrl3Button.allCases, axes: SkyCtrl3Axis.allCases)
}
}
Furthermore, you can see a sample of “listeners for grabbed events” in the Demo Application (file: SkyCtrl3GamepadCell.swift)