Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event handling #1

Open
mtp opened this issue Mar 16, 2021 · 3 comments
Open

Event handling #1

mtp opened this issue Mar 16, 2021 · 3 comments

Comments

@mtp
Copy link

mtp commented Mar 16, 2021

Hello !
Thanks for this great library, brilliant!
Do you know how can I handle sending event to the simulator ?

Best regards,

@grumpypixel
Copy link
Owner

Hello mtp,

Thanks for your question and for opening an issue.

Could you be a little bit more specific what you mean by "event"? May I ask, what you are trying to achieve?

The library currently does not support all SimConnect functions but I am working on a bigger update.

If by "event" you mean to "set data on a simobject", like the plane's altitude ("PLANE ALTITUDE"), you could have a look at the function handleTeleportMessage from GoPilot's main.go:

The function handleTeleportMessage calls SetSimObjectData of the struct SimMate.

If you don't want to use the SimMate, just roll your own:

Assuming you have an SimConnect instance named simConnect:
simConnect = simconnect.NewSimConnect()

Your function could look as follows:

func MySetSimObjectData(name, unit string, value float64) error {
	defineID := simconnect.NewDefineID()
	if err := simConnect.AddToDataDefinition(defineID, name, unit, simconnect.DataTypeFloat64); err != nil {
		return err
	}
	buffer := [1]float64{value}
	size := simconnect.DWord(unsafe.Sizeof(buffer))
	return simConnect.SetDataOnSimObject(defineID, simconnect.ObjectIDUser, 0, 0, size, unsafe.Pointer(&buffer[0]))
}

And call it like this:
MySetSimObjectData("PLANE ALTITUDE", "feet", 7700)

Not sure if this is of any help though. Just let me know, I would be happy to help you find a solution.

Cheers!

@mtp
Copy link
Author

mtp commented Mar 17, 2021

Hello, thank for your answer.
I wanted to send an event to othe sim using the SimConnect_TransmitClientEvent function.

@grumpypixel
Copy link
Owner

Thanks for clarifying, mtp. The function SimConnect_TransmitClientEvent is not supported yet but it will be in the next update (which will be available soon). Sorry for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants