MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Input::TabletNode Class Reference

InputNode projecting one slot of a tablet frame. More...

#include <TabletNode.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Input::TabletNode:
+ Collaboration diagram for MayaFlux::Nodes::Input::TabletNode:

Public Types

using FrameCallback = TypedHook< TabletContext >
 

Public Member Functions

std::array< double, Core::TabletFrame::SLOT_COUNT > get_frame () const
 Most recent frame received, all slots.
 
NodeContext & get_last_context () override
 Retrieves the last created context object.
 
HookId on_contact_begin (FrameCallback callback)
 Callback when the tip touches the surface.
 
HookId on_contact_end (FrameCallback callback)
 Callback when the tip leaves the surface.
 
HookId on_frame (FrameCallback callback)
 Callback on every frame, with the full slot set.
 
HookId on_proximity_enter (FrameCallback callback)
 Callback when the tool enters sensing range.
 
HookId on_proximity_exit (FrameCallback callback)
 Callback when the tool leaves sensing range.
 
void restore_state () override
 Restores the node's state from the last save Recursively cascades through all connected modulator nodes Protected - only NodeSourceProcessor and NodeBuffer can call.
 
void save_state () override
 Saves the node's current state for later restoration Recursively cascades through all connected modulator nodes Protected - only NodeSourceProcessor and NodeBuffer can call.
 
 TabletNode (TabletConfig config={})
 
- Public Member Functions inherited from MayaFlux::Nodes::Input::InputNode
void clear_input_flag ()
 Clear the new input flag without checking.
 
const InputConfig & get_config () const
 
double get_current_value () const
 Get the current smoothed value.
 
std::vector< Core::InputValue > get_input_history () const
 Get input history (thread-safe copy)
 
std::optional< Core::InputValue > get_last_input () const
 Get the most recent raw InputValue.
 
double get_target_value () const
 Get the target value (before smoothing)
 
bool has_new_input ()
 Check if new input has arrived since last check.
 
 InputNode (InputConfig config={})
 
HookId on_button_press (const TypedHook< InputContext > &callback)
 Register callback for button press (0.0 → 1.0 transition)
 
HookId on_button_release (const TypedHook< InputContext > &callback)
 Register callback for button release (1.0 → 0.0 transition)
 
HookId on_input (const TypedHook< InputContext > &callback)
 Register callback for any input received.
 
HookId on_range_enter (double min, double max, const TypedHook< InputContext > &callback)
 Register callback for entering a value range.
 
HookId on_range_exit (double min, double max, const TypedHook< InputContext > &callback)
 Register callback for exiting a value range.
 
HookId on_threshold_falling (double threshold, const TypedHook< InputContext > &callback)
 Register callback for threshold crossing (falling edge)
 
HookId on_threshold_rising (double threshold, const TypedHook< InputContext > &callback)
 Register callback for threshold crossing (rising edge)
 
HookId on_tick (const TypedHook< InputContext > &callback)
 Register callback for any input received.
 
HookId on_tick_if (const NodeCondition &condition, const TypedHook< InputContext > &callback)
 Register conditional callback for input received.
 
HookId on_value_change (const TypedHook< InputContext > &callback, double epsilon=0.0001)
 Register callback for value changes.
 
std::vector< double > process_batch (unsigned int num_samples) override
 Process a batch of samples.
 
virtual void process_input (const Core::InputValue &value)
 Process an input value from a backend.
 
double process_sample (double input=0.0) override
 Process a single sample.
 
void set_slew_rate (double rate)
 
void set_smoothing (SmoothingMode mode, double factor=0.1)
 
HookId while_in_range (double min, double max, const TypedHook< InputContext > &callback)
 Register callback while value is in range.
 
 ~InputNode () override=default
 
- Public Member Functions inherited from MayaFlux::Nodes::Node
void add_buffer_reference ()
 Increments the buffer reference count This method is called when a new buffer starts using this node to ensure proper lifecycle management.
 
void enable_mock_process (bool mock_process)
 Old name of exclude_output_from_graph().
 
virtual void exclude_output_from_graph (bool excluded=true)
 Exclude this node's output from the graph it is registered in.
 
uint64_t get_active_snapshot_context () const
 Get the active snapshot context ID.
 
const std::atomic< uint32_t > & get_channel_mask () const
 Retrieves the current bitmask of active channels using this node.
 
uint32_t get_frame_rate () const
 
std::span< const float > get_gpu_data_buffer () const
 Provides access to the GPU data buffer.
 
virtual double get_last_output ()
 Retrieves the most recent output value produced by the node.
 
std::vector< ModulatorTree > get_modulator_tree () const
 Returns the full modulator tree rooted at this node.
 
virtual std::vector< std::pair< ModulatorRole, std::shared_ptr< Node > > > get_modulators () const
 Returns direct modulator nodes and their roles.
 
RoutingState & get_routing_state ()
 Retrieves the current routing state of the network (non-const)
 
const RoutingState & get_routing_state () const
 Retrieves the current routing state of the network.
 
uint32_t get_sample_rate () const
 
bool has_active_snapshot () const
 Check if node is currently being snapshotted by any context.
 
bool has_capability (NodeCapability cap) const
 Query a single capability.
 
bool is_buffer_processed () const
 Checks if the buffer has been processed.
 
bool is_gpu_compatible () const
 Checks if the node supports GPU processing.
 
bool is_in_network () const
 Sets whether the node is part of a NodeNetwork.
 
bool is_in_snapshot_context (uint64_t context_id) const
 Check if currently in a snapshot context.
 
virtual bool is_output_excluded_from_graph () const
 True if the node's output is excluded from the graph.
 
bool is_used_by_channel (uint32_t channel_id) const
 Checks if the node is currently used by a specific channel.
 
bool mark_buffer_processed ()
 Marks the node as having been processed by a buffer.
 
bool needs_channel_routing () const
 Checks if the network is currently in a routing transition phase.
 
virtual uint8_t node_capabilities () const
 Declare which data shapes this node's context can produce.
 
virtual HookId on_tick (const NodeHook &callback)
 Registers a callback to be called on each tick.
 
virtual HookId on_tick_if (const NodeCondition &condition, const NodeHook &callback)
 Registers a conditional callback.
 
void register_channel_usage (uint32_t channel_id)
 Mark the specificed channel as a processor/user.
 
void release_snapshot_context (uint64_t context_id)
 Release snapshot context.
 
virtual void remove_all_hooks ()
 Removes all registered callbacks.
 
void remove_buffer_reference ()
 Decrements the buffer reference count This method is called when a buffer stops using this node to ensure proper lifecycle management.
 
virtual bool remove_conditional_hook (const NodeCondition &callback)
 Removes a previously registered conditional callback.
 
virtual bool remove_hook (const NodeHook &callback)
 Removes a previously registered callback.
 
void request_buffer_reset ()
 Requests a reset of the buffer state.
 
void request_reset_from_channel (uint32_t channel_id)
 Requests a reset of the processed state from a specific channel.
 
virtual void reset_processed_state ()
 Resets the processed state of the node and any attached input nodes.
 
void set_frame_rate (uint32_t frame_rate)
 
virtual void set_gpu_compatible (bool compatible)
 Sets whether the node is compatible with GPU processing.
 
void set_in_network (bool networked)
 Marks the node as being part of a NodeNetwork.
 
void set_sample_rate (uint32_t sample_rate)
 
bool should_mock_process () const
 Old name of is_output_excluded_from_graph().
 
bool try_claim_snapshot_context (uint64_t context_id)
 Attempt to claim snapshot context for this processing cycle.
 
virtual bool unhook (HookId id)
 Removes the one registration with this id, whichever hook list holds it.
 
void unregister_channel_usage (uint32_t channel_id)
 Removes the specified channel from the usage tracking.
 
virtual ~Node ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Protected Member Functions

double extract_value (const Core::InputValue &value) override
 Extract a scalar value from an InputValue.
 
void notify_tick (double value) override
 Fires the hooks for one delivered input.
 
void update_context (double value) override
 Update context after processing.
 
- Protected Member Functions inherited from MayaFlux::Nodes::Input::InputNode
double held_value () const
 The smoothed value the node currently holds.
 
- Protected Member Functions inherited from MayaFlux::Nodes::Node
virtual void reset_processed_state_internal ()
 Resets the processed state of the node directly.
 

Private Member Functions

void fire (const HookList &callbacks)
 
void fire_edges ()
 

Private Attributes

TabletConfig m_config
 
HookList m_contact_begin_callbacks { *this }
 
HookList m_contact_end_callbacks { *this }
 
std::array< double, Core::TabletFrame::SLOT_COUNT > m_frame {}
 
HookList m_frame_callbacks { *this }
 
std::atomic< bool > m_frame_pending { false }
 
uint32_t m_previous_state {}
 
HookList m_proximity_enter_callbacks { *this }
 
HookList m_proximity_exit_callbacks { *this }
 
TabletContext m_tablet_context
 

Additional Inherited Members

- Public Attributes inherited from MayaFlux::Nodes::Node
bool m_fire_events_during_snapshot = false
 Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don't fire during isolated buffer processing) Can be exposed in future if needed via concrete implementation in parent.
 
std::atomic< uint32_t > m_modulator_count { 0 }
 Counter tracking how many other nodes are using this node as a modulator.
 
std::atomic< NodeState > m_state { NodeState::INACTIVE }
 Atomic state flag tracking the node's processing status.
 
- Protected Attributes inherited from MayaFlux::Nodes::Input::InputNode
InputConfig m_config
 
InputContext m_context
 
- Protected Attributes inherited from MayaFlux::Nodes::Node
HookList m_callbacks { *this }
 Hooks fired on every tick.
 
HookList m_conditional_callbacks { *this }
 Hooks fired on a tick only while their condition holds.
 
uint32_t m_frame_rate { 60 }
 Frame rate for time-based processing, used for normalization.
 
bool m_gpu_compatible {}
 Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate whether the node can be processed on the GPU.
 
std::vector< float > m_gpu_data_buffer
 GPU data buffer for context objects.
 
double m_last_output { 0 }
 The most recent sample value generated by this oscillator.
 
bool m_networked_node {}
 Flag indicating if the node is part of a NodeNetwork This flag is used to disable event firing when the node is managed within a NodeNetwork, preventing redundant or conflicting event notifications.
 
uint8_t m_node_capability { NodeCapability::SCALAR }
 Bitmask of capabilities declared by this node.
 
uint32_t m_sample_rate { 48000 }
 Sample rate for audio processing, used for normalization.
 
bool m_state_saved {}
 tracks if the node's state has been saved by a snapshot operation
 
uint32_t m_timing_rate { m_sample_rate }
 Current timing rate for the node, used for timing calculations (can be sample rate or frame rate)
 

Detailed Description

InputNode projecting one slot of a tablet frame.

Receives InputValue::Type::VECTOR frames from TabletBackend and outputs the configured slot as a smoothed scalar, while carrying the whole frame into every callback through TabletContext.

Multi-axis use is several TabletNode instances bound to the same tool. InputManager hands each the same InputValue in one dispatch pass, so their frames are the same hardware sample.

Contact and proximity edges fire regardless of which slot the node projects, since they are transitions of the frame rather than of the scalar.

Example usage:

auto tools = engine.input().get_backend(Core::InputType::TABLET)->get_devices();
auto pressure = std::make_shared<TabletNode>(TabletConfig::pressure());
register_input_node(pressure, InputBinding::tablet(tools[0].id));
pressure->on_contact_begin([](TabletContext& ctx) {
// stroke start, with position and tilt available
});
pressure->on_threshold_rising(0.5, [](InputContext& ctx) {
// half pressure crossed
});
Context for InputNode callbacks - provides input event access.
Definition InputNode.hpp:38
Node context carrying a full tablet frame alongside the scalar.
@ TABLET
Digitizers and styluses (pressure, tilt, rotation)
void register_input_node(const std::shared_ptr< Nodes::Input::InputNode > &node, const Core::InputBinding &binding)
Register an input node with specified binding.
Definition Input.cpp:21
static TabletConfig pressure()
Tip pressure, 0 to 1.

Definition at line 215 of file TabletNode.hpp.


The documentation for this class was generated from the following files: