Exemplo n.º 1
0
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))
		}
	}
}
Exemplo n.º 2
0
func RegisterCommandHandler(command CommandRef, callback CommandCallback, before bool, ref interface{}) {
	cId := C.CString(goplane.IdGenerator())
	callbacks[cId] = &regInfo{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))
}