DeclareCallBackMBS issue?

I thought I posted this last week, but I can’t find it now. If I am being redundant, I apologize in advance.

Im using the MBS DeclareCallback function as the call back with regular declares in XOJO causes a crash.
MBS seems to work, but it only works once.

I setup the call back and it should fire every time there is a significant event on connected hardware (like a button press). After I invoke, the callback fires one time (as expected) and doesn’t crash (yay), but then seems to switch off, or ignore reoccurring events.

I don’t know if I’m missing the function from MBS or what is going on, so I’m tossing this to y’all to see if anyone has relevant experience. The documentation and examples for DeclareCallBackMBS don’t make it easy to project how to handle this situation.

My code is as follows:

Var c As New MyCallback("(ILI)v")
c.AllowAsync = True

Var ldir As String = app.ExecutableFile.parent.parent.child(“Frameworks”).child(“libFDXSDK.dylib”).NativePath
Dim d As New DeclareLibraryMBS(ldir)
Dim p As ptr = d.Symbol(“RegisterDeviceEventHandler”)
Var m As New MyFunction( “p()i”, c.FunctionPtr)

Var v As Variant = m.Invoke()


The callback and the function to register it as as follows:

typedef void (*FPtr_FDX_DeviceEventHandler) (FDX_eEventCode outEventCode, uint32_km outRAWDataCount, FDXSDK_ERROR_TYPES outError);

FDXSDK_ERROR_TYPES KMAPI FDX_RegisterDeviceEventHandler(Const FPtr_FDX_DeviceEventHandler inHandler);

Make the declarecallbackmbs class instance a property of a module or window

Yep, that’s what happens with this line.


c1 is a property on a module. I had it as a member of an object but thought it needed to be globally accessible. That didn’t work either. You can see at the end of my code (above), I retain a reference to everything I can.

Never mind…

Try stepping trough the debugger and show some output if you can. Perhaps it can help. As it can be hard to track down.

Sometimes the problem can be incorrectly usage of pointers (arrays in c to xojo for example), i don’t see no here…

Try to find the exact datatypes for these values:
FDX_eEventCode outEventCode,
uint32_km outRAWDataCount,