From d566187f429616fe401eeb539db01a8aa3507186 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Sat, 20 Aug 2011 18:45:23 +0200 Subject: [PATCH] [Client] Fix "blinking" coordinates in flood mode In calibration flood mode, the coordinates were "blinking" (correct values, then 0, etc.). This is now fixed. --- owlps-client/owlps-client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index 33c616f..4d465a3 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -410,14 +410,21 @@ void make_packet() printf("Direction = %d, X = %f, Y = %f, Z = %f\n", packet[offset - 1], options.x, options.y, options.z) ; #endif // DEBUG + // Convert the coordinates to the network endianess options.x = owl_htonf(options.x) ; options.y = owl_htonf(options.y) ; options.z = owl_htonf(options.z) ; + // Copy the coordinates to the packet memcpy(&packet[offset], &options.x, sizeof(float)) ; offset += sizeof(float) ; memcpy(&packet[offset], &options.y, sizeof(float)) ; offset += sizeof(float) ; memcpy(&packet[offset], &options.z, sizeof(float)) ; + // Convert the coordinates back to the host endianess (mandatory + // in flood mode) + options.x = owl_ntohf(options.x) ; + options.y = owl_ntohf(options.y) ; + options.z = owl_ntohf(options.z) ; } else // Standard packet