How to set TUG Heading during push back?

Hello, I’m trying to create a pushback tool for Flow (JavaScript). I only have
access to MSFS events and variables. Everything is working well, except when I
attempt to turn left or right. My issue is that the tug doesn’t face the
correct direction. When I simply move backward (by setting “VELOCITY BODY Z”
to a negative value), everything is fine. The “PUSHBACK ANGLE” remains at 0.
However, when I try to turn, I set the “ROTATION VELOCITY BODY Y” variable,
and then the “PUSHBACK ANGLE” continuously fluctuates between -0.35 and 0.35
(even if I always turn in the same direction). Consequently, the tug sometimes
faces the wrong direction. Furthermore, after I stop turning, the
PUSHBACK_ANGLE retains a value of -0.35 or 0.35. As a result, the tug ends up
pushing the aircraft sideways. I attempted to set the TUG_HEADING using the
following value:

(PLANE HEADING DEGREES TRUE * 4,294,967,296 / 360)

However, it doesn’t seem to have any effect. Is TUG_HEADING still in use? How
can I resolve this problem? Thank you. EDIT: I’ve figured out what happened. I
need to use KEY_TUG_HEADING instead. However, there is a problem with MSFS (or
Simconnect) regarding how it handles numbers from JavaScript. For
KEY_TUG_HEADING, we require a 32-bit UNSIGNED value. If I send a value greater
than 2,147,483,647 (31 bits), Simconnect treats it as a negative value. How
can I resolve this issue? Thank you.

I’ve found the solution. MSFS requires a number between 0 and 2^32, which is
an unsigned value. However, simconnect processes the value as a signed number.
Numbers between 0 and 2^31 (-1) work normally. For numbers between 2^31 and
2^32 (-1), I have to treat them as int32 numbers (instead of uint32 as
mentioned in the SDK documentation). So, in my case, when dealing with degrees
versus simconnect’s signed 32-bit number:

  • 0° = 0 (0x0000 0000)
  • 45° = 536870912 (0x2000 0000)
  • 90° = 1073741824 (0x4000 0000)
  • 179,99° = 2147483647 (0x7FFF FFFF)
  • 180° = -2147483648 (0x8000 0000)
  • 270° = -10737411824 (0xC0000000)
  • 359,99° = -1