func UnregisterCommandHandler(command CommandRef, callback CommandCallback, before bool, ref interface{}) { callbackAsString := fmt.Sprint(callback) for cId, regInfo := range callbacks { if regInfo.command == command && regInfo.callbackAsString == callbackAsString && regInfo.ref == ref { C.XPLMUnregisterCommandHandler(C.XPLMCommandRef(command), C.XPLMCommandCallback_f(unsafe.Pointer(C.commandCallback)), C.int(goplane.FromBoolToInt(before)), unsafe.Pointer(cId)) defer C.free(unsafe.Pointer(cId)) } } }
func RegisterCommandHandler(command CommandRef, callback CommandCallback, before bool, ref interface{}) { cId := C.CString(goplane.IdGenerator()) callbacks[cId] = ®Info{fmt.Sprint(callback), command, callback, ref} C.XPLMRegisterCommandHandler(C.XPLMCommandRef(command), C.XPLMCommandCallback_f(unsafe.Pointer(C.commandCallback)), C.int(goplane.FromBoolToInt(before)), unsafe.Pointer(cId)) }