/// <summary> /// Decode a Gesture Status packet from a byte stream. /// </summary> /// <param name="buffer"></param> /// <param name="index"></param> /// <param name="enabled"></param> /// <returns></returns> private static GestureId DecodeGestureStatus(byte[] buffer, ref int index, out bool enabled) { GestureStatusPacket status = DeserializePacket <GestureStatusPacket>(buffer, ref index); enabled = (status.enabled != 0); return((GestureId)status.gestureId); }
/// <summary> /// Encode a Gesture Status packet into the buffer /// </summary> /// <param name="buffer"></param> /// <param name="index"></param> /// <param name="gesture"></param> /// <param name="enabled"></param> public static void EncodeGestureStatus(byte[] buffer, ref int index, GestureId gesture, bool enabled) { // Encode header PacketHeader header = new PacketHeader(PacketTypeCode.GestureStatus); SerializePacket(buffer, ref index, header); // Encode payload GestureStatusPacket packet = new GestureStatusPacket { gestureId = (int)gesture, enabled = (byte)(enabled ? 1 : 0) }; SerializePacket(buffer, ref index, packet); // Encode footer SerializePacket(buffer, ref index, _footer); }