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

◆ extract_value()

double MayaFlux::Nodes::Input::HIDNode::extract_value ( const Core::InputValue value)
overrideprotectedvirtual

Extract a scalar value from an InputValue.

Parameters
valueThe input value to extract from
Returns
Scalar value for smoothing/output

Override in derived classes for specific input types. Default handles SCALAR and MIDI CC values.

Reimplemented from MayaFlux::Nodes::Input::InputNode.

Definition at line 15 of file HIDNode.cpp.

16{
17 if (value.type != Core::InputValue::Type::BYTES) {
19 }
20
21 const auto& bytes = value.as_bytes();
22
23 switch (m_config.mode) {
25 return parse_axis(bytes);
26
28 return parse_button(bytes);
29
32 ? m_config.custom_parser(bytes)
34 }
35
37}
double parse_button(std::span< const uint8_t > bytes) const
Parse button value from HID report bytes.
Definition HIDNode.cpp:71
double parse_axis(std::span< const uint8_t > bytes) const
Parse axis value from HID report bytes.
Definition HIDNode.cpp:39
@ BUTTON
Digital button (bit mask)
@ CUSTOM
User-provided parser function.
@ AXIS
Joystick/gamepad axis with normalization & deadzone.
@ BYTES
Raw byte data (HID reports, sysex)
std::function< double(std::span< const uint8_t >)> custom_parser
Definition HIDNode.hpp:39
double default_value
Initial output value.
Definition InputNode.hpp:83

References MayaFlux::Core::InputValue::as_bytes(), MayaFlux::Nodes::Input::AXIS, MayaFlux::Nodes::Input::BUTTON, MayaFlux::Core::InputValue::BYTES, MayaFlux::Nodes::Input::CUSTOM, MayaFlux::Nodes::Input::HIDConfig::custom_parser, MayaFlux::Nodes::Input::InputConfig::default_value, m_config, MayaFlux::Nodes::Input::HIDConfig::mode, parse_axis(), parse_button(), and MayaFlux::Core::InputValue::type.

+ Here is the call graph for this function: