vJoyInterfaceWrap.vJoy.FfbRegisterGenCB C# (CSharp) Method

FfbRegisterGenCB() public method

public FfbRegisterGenCB ( FfbCbFunc cb, object data ) : void
cb FfbCbFunc
data object
return void
        public void FfbRegisterGenCB(FfbCbFunc cb, object data)
        {
            // Free existing GCHandle (if exists)
            if (hFfbUserData.IsAllocated && hFfbUserData.Target != null)
                hFfbUserData.Free();

            // Convert object to pointer
            hFfbUserData = GCHandle.Alloc(data);

            // Apply the user-defined CB function          
            UserFfbCB = new FfbCbFunc(cb);
            wf = new WrapFfbCbFunc(WrapperFfbCB);

            _FfbRegisterGenCB(wf, (IntPtr)hFfbUserData);
        }

Same methods

vJoy::FfbRegisterGenCB ( WrapFfbCbFunc cb, IntPtr data ) : void

Usage Example

Ejemplo n.º 1
0
        public FfbInterface(TesterForm dialog)
        {
            dlg = dialog;
            joystick = dialog.joystick;
            // FFB
            #if false
            #pragma warning disable 0618
            if (!joystick.FfbStart(id))
                throw new Exception(String.Format("Failed to start Forcefeedback on device {0}", id));
            #pragma warning restore 0618

            // Convert Form to pointer and pass it as user data to the callback function
            GCHandle h = GCHandle.Alloc(dialog);
            IntPtr parameter = (IntPtr)h;
            // joystick.FfbRegisterGenCB(OnEffect, parameter);
            joystick.FfbRegisterGenCB(OnEffectObj, dialog);
             #endif
        }