35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
#ifndef NUI_CORE_PROTOCOL_WIRE_H
|
|
#define NUI_CORE_PROTOCOL_WIRE_H
|
|
|
|
#include "protocol/protocol.h"
|
|
|
|
namespace nui::protocol::wire {
|
|
|
|
inline uint16_t u16(const Bytes& bytes, std::size_t offset) {
|
|
return static_cast<uint16_t>(bytes[offset] | (bytes[offset + 1] << 8));
|
|
}
|
|
inline void put16(Bytes& bytes, std::size_t offset, uint16_t value) {
|
|
bytes[offset] = static_cast<uint8_t>(value);
|
|
bytes[offset + 1] = static_cast<uint8_t>(value >> 8);
|
|
}
|
|
inline void put32(Bytes& bytes, std::size_t offset, uint32_t value) {
|
|
for (unsigned i = 0; i < 4; ++i) {
|
|
bytes[offset + i] = static_cast<uint8_t>(value >> (i * 8));
|
|
}
|
|
}
|
|
|
|
// Synthetic 1414 calibration, shared by EEPROM replies and metric->raw depth.
|
|
// Units and conversion: libfreenect 09a1f098 src/registration.c:315-325.
|
|
constexpr float kEmitterDistance = 7.5f;
|
|
constexpr float kCameraDistance = 2.4f;
|
|
constexpr float kReferenceDistance = 120.0f;
|
|
constexpr float kPixelSize = 0.1052f;
|
|
constexpr uint16_t kConstantShift = 200;
|
|
|
|
std::optional<Bytes> descriptor(UsbFunction function, uint16_t type_index);
|
|
bool endpoint_exists(UsbFunction function, uint16_t endpoint);
|
|
uint8_t interface_count(UsbFunction function);
|
|
|
|
} // namespace nui::protocol::wire
|
|
#endif // NUI_CORE_PROTOCOL_WIRE_H
|