/** * <summary> * Registers a callback function that will be invoked each time that the estimated * device orientation has changed. * <para> * The call frequency is typically around 95Hz during a move. * The callback is invoked only during the execution of <c>ySleep</c> or <c>yHandleEvents</c>. * This provides control over the time when the callback is triggered. * For good responsiveness, remember to call one of these two functions periodically. * To unregister a callback, pass a null pointer as argument. * </para> * <para> * </para> * </summary> * <param name="callback"> * the callback function to invoke, or a null pointer. * The callback function should take four arguments: * the YGyro object of the turning device, and the floating * point values of the three angles roll, pitch and heading * in degrees (as floating-point numbers). * @noreturn * </param> */ public virtual int registerAnglesCallback(YAnglesCallback callback) { this._anglesCallback = callback; if (callback != null) { if (this._loadQuaternion() != YAPI.SUCCESS) { return(YAPI.DEVICE_NOT_FOUND); } this._qt_w.set_userData(this); this._qt_x.set_userData(this); this._qt_y.set_userData(this); this._qt_z.set_userData(this); this._qt_w.registerValueCallback(yInternalGyroCallback); this._qt_x.registerValueCallback(yInternalGyroCallback); this._qt_y.registerValueCallback(yInternalGyroCallback); this._qt_z.registerValueCallback(yInternalGyroCallback); } else { if (!(this._quatCallback != null)) { this._qt_w.registerValueCallback((YQt.ValueCallback)null); this._qt_x.registerValueCallback((YQt.ValueCallback)null); this._qt_y.registerValueCallback((YQt.ValueCallback)null); this._qt_z.registerValueCallback((YQt.ValueCallback)null); } } return(0); }
/** * <summary> * Registers a callback function that will be invoked each time that the estimated * device orientation has changed. * <para> * The call frequency is typically around 95Hz during a move. * The callback is invoked only during the execution of <c>ySleep</c> or <c>yHandleEvents</c>. * This provides control over the time when the callback is triggered. * For good responsiveness, remember to call one of these two functions periodically. * To unregister a callback, pass a null pointer as argument. * </para> * <para> * </para> * </summary> * <param name="callback"> * the callback function to invoke, or a null pointer. * The callback function should take four arguments: * the YGyro object of the turning device, and the floating * point values of the three angles roll, pitch and heading * in degrees (as floating-point numbers). * @noreturn * </param> */ public virtual int registerAnglesCallback(YAnglesCallback callback) { this._anglesCallback = callback; if (callback != null) { if (this._loadQuaternion() != YAPI.SUCCESS) { return YAPI.DEVICE_NOT_FOUND; } this._qt_w.set_userData(this); this._qt_x.set_userData(this); this._qt_y.set_userData(this); this._qt_z.set_userData(this); this._qt_w.registerValueCallback(yInternalGyroCallback); this._qt_x.registerValueCallback(yInternalGyroCallback); this._qt_y.registerValueCallback(yInternalGyroCallback); this._qt_z.registerValueCallback(yInternalGyroCallback); } else { if (!(this._quatCallback != null)) { this._qt_w.registerValueCallback((YQt.ValueCallback) null); this._qt_x.registerValueCallback((YQt.ValueCallback) null); this._qt_y.registerValueCallback((YQt.ValueCallback) null); this._qt_z.registerValueCallback((YQt.ValueCallback) null); } } return 0; }