예제 #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)
		}
	}

}
예제 #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
}
예제 #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))
		}
	}
}
예제 #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))
}