mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 11:42:55 +02:00
use packet version helpers for PACKET_TYPE_TRANSMITTER_DATA
This commit is contained in:
parent
202d446f07
commit
185d5bb0a2
2 changed files with 15 additions and 8 deletions
|
@ -3,15 +3,20 @@
|
||||||
// hifi
|
// hifi
|
||||||
//
|
//
|
||||||
// Created by Philip Rosedale on 5/20/13.
|
// Created by Philip Rosedale on 5/20/13.
|
||||||
//
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Transmitter.h"
|
|
||||||
#include "InterfaceConfig.h"
|
|
||||||
#include "Util.h"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
#include <PacketHeaders.h>
|
||||||
|
|
||||||
|
#include "InterfaceConfig.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "Transmitter.h"
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
|
|
||||||
const float DELTA_TIME = 1.f / 60.f;
|
const float DELTA_TIME = 1.f / 60.f;
|
||||||
const float DECAY_RATE = 0.15f;
|
const float DECAY_RATE = 0.15f;
|
||||||
|
@ -45,7 +50,9 @@ void Transmitter::resetLevels() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) {
|
void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) {
|
||||||
const int PACKET_HEADER_SIZE = 1; // Packet's first byte is 'T'
|
// Packet's first byte is 'T'
|
||||||
|
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
||||||
|
|
||||||
const int ROTATION_MARKER_SIZE = 1; // 'R' = Rotation (clockwise about x,y,z)
|
const int ROTATION_MARKER_SIZE = 1; // 'R' = Rotation (clockwise about x,y,z)
|
||||||
const int ACCELERATION_MARKER_SIZE = 1; // 'A' = Acceleration (x,y,z)
|
const int ACCELERATION_MARKER_SIZE = 1; // 'A' = Acceleration (x,y,z)
|
||||||
if (!_lastReceivedPacket) {
|
if (!_lastReceivedPacket) {
|
||||||
|
@ -53,10 +60,10 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) {
|
||||||
}
|
}
|
||||||
gettimeofday(_lastReceivedPacket, NULL);
|
gettimeofday(_lastReceivedPacket, NULL);
|
||||||
|
|
||||||
if (numBytes == PACKET_HEADER_SIZE + ROTATION_MARKER_SIZE + ACCELERATION_MARKER_SIZE
|
if (numBytes == numBytesPacketHeader + ROTATION_MARKER_SIZE + ACCELERATION_MARKER_SIZE
|
||||||
+ sizeof(_lastRotationRate) + sizeof(_lastAcceleration)
|
+ sizeof(_lastRotationRate) + sizeof(_lastAcceleration)
|
||||||
+ sizeof(_touchState.x) + sizeof(_touchState.y) + sizeof(_touchState.state)) {
|
+ sizeof(_touchState.x) + sizeof(_touchState.y) + sizeof(_touchState.state)) {
|
||||||
unsigned char* packetDataPosition = &packetData[PACKET_HEADER_SIZE + ROTATION_MARKER_SIZE];
|
unsigned char* packetDataPosition = packetData + numBytesPacketHeader + ROTATION_MARKER_SIZE;
|
||||||
memcpy(&_lastRotationRate, packetDataPosition, sizeof(_lastRotationRate));
|
memcpy(&_lastRotationRate, packetDataPosition, sizeof(_lastRotationRate));
|
||||||
packetDataPosition += sizeof(_lastRotationRate) + ACCELERATION_MARKER_SIZE;
|
packetDataPosition += sizeof(_lastRotationRate) + ACCELERATION_MARKER_SIZE;
|
||||||
memcpy(&_lastAcceleration, packetDataPosition, sizeof(_lastAcceleration));
|
memcpy(&_lastAcceleration, packetDataPosition, sizeof(_lastAcceleration));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// hifi
|
// hifi
|
||||||
//
|
//
|
||||||
// Created by Philip Rosedale on 5/20/13.
|
// Created by Philip Rosedale on 5/20/13.
|
||||||
//
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __hifi__Transmitter__
|
#ifndef __hifi__Transmitter__
|
||||||
|
|
Loading…
Reference in a new issue