MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ parse_axis()

double MayaFlux::Nodes::Input::HIDNode::parse_axis ( std::span< const uint8_t >  bytes) const
private

Parse axis value from HID report bytes.

Parameters
bytesHID report bytes
Returns
Normalized axis value (0.0 to 1.0)

Definition at line 39 of file HIDNode.cpp.

40{
41 if (bytes.size() <= m_config.byte_offset) {
43 }
44
45 double raw = 0.0;
46
47 if (m_config.byte_size == 1) {
48 uint8_t b = bytes[m_config.byte_offset];
50 ? static_cast<double>(static_cast<int8_t>(b))
51 : static_cast<double>(b);
52 } else if (m_config.byte_size == 2 && bytes.size() > m_config.byte_offset + 1) {
53 uint16_t w = bytes[m_config.byte_offset] | (bytes[m_config.byte_offset + 1] << 8);
55 ? static_cast<double>(static_cast<int16_t>(w))
56 : static_cast<double>(w);
57 }
58
59 // Normalize to 0-1
61 normalized = std::clamp(normalized, 0.0, 1.0);
62
63 // Apply deadzone if configured
64 if (m_config.deadzone > 0.0) {
66 }
67
68 return normalized;
69}
size_t b
double apply_deadzone(double normalized) const
Definition HIDNode.cpp:86
std::vector< double > normalized(const std::vector< double > &data, double target_peak)
Normalize single-channel data (non-destructive)
Definition Yantra.cpp:593
size_t byte_size
1 or 2 bytes (for AXIS)
Definition HIDNode.hpp:26
double default_value
Initial output value.
Definition InputNode.hpp:83

References apply_deadzone(), b, MayaFlux::Nodes::Input::HIDConfig::byte_offset, MayaFlux::Nodes::Input::HIDConfig::byte_size, MayaFlux::Nodes::Input::HIDConfig::deadzone, MayaFlux::Nodes::Input::InputConfig::default_value, MayaFlux::Nodes::Input::HIDConfig::is_signed, m_config, MayaFlux::Nodes::Input::HIDConfig::max_raw, MayaFlux::Nodes::Input::HIDConfig::min_raw, and MayaFlux::normalized().

Referenced by extract_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: