Ejemplo n.º 1
0
func UnregisterFlightLoopCallback(flightLoop FlightLoopFunc, ref interface{}) {
	for key, data := range callbacks {
		if data.funcPointerAsString == fmt.Sprint(flightLoop) && data.flightLoopData.Ref == ref {
			C.XPLMUnregisterFlightLoopCallback(C.XPLMFlightLoop_f(unsafe.Pointer(C.flightLoop)), unsafe.Pointer(data.flightLoopData))
			delete(callbacks, key)
		}
	}

}
Ejemplo n.º 2
0
func CreateFlightLoop(data *CreateFlightLoopData) FlightLoopId {
	id := C.CString(goplane.IdGenerator())
	cRegData := C.XPLMCreateFlightLoop_t{}
	cRegData.structSize = C.int(unsafe.Sizeof(cRegData))
	cRegData.phase = C.XPLMFlightLoopPhaseType(data.Phase)
	cRegData.callbackFunc = C.XPLMFlightLoop_f(unsafe.Pointer(C.flightLoop))
	cRegData.refcon = unsafe.Pointer(id)
	callbacks[id] = regData{fmt.Sprint(data.Callback), data}
	flightLoopId := FlightLoopId(C.XPLMCreateFlightLoop(&cRegData))
	return flightLoopId
}
Ejemplo n.º 3
0
func SetFlightLoopCallbackInterval(flightLoop FlightLoopFunc, interval float32, relativeToNow bool, ref interface{}) {
	cRelativeToNow := 0
	if relativeToNow {
		cRelativeToNow = 1
	}
	for key, current := range callbacks {
		if current.funcPointerAsString == fmt.Sprint(flightLoop) {
			current.flightLoopData.Ref = ref
			C.XPLMSetFlightLoopCallbackInterval(C.XPLMFlightLoop_f(C.flightLoop), C.float(interval), C.int(cRelativeToNow), unsafe.Pointer(key))
		}
	}
}
Ejemplo n.º 4
0
func RegisterFlightLoopCallback(flightLoop FlightLoopFunc, interval float32, ref interface{}) {
	data := regData{fmt.Sprint(flightLoop), &CreateFlightLoopData{FlightLoop_Phase_BeforeFlightModel, flightLoop, ref}}
	id := C.CString(goplane.IdGenerator())
	callbacks[id] = data
	C.XPLMRegisterFlightLoopCallback(C.XPLMFlightLoop_f(unsafe.Pointer(C.flightLoop)), C.float(interval), unsafe.Pointer(id))
}