Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vberthiaume committed Jan 8, 2025
1 parent 79efa7c commit 4fdde04
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions include/puara/descriptors/touchFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class TouchFeature
*/
float value{};

/**
* @brief Pointer to an external value that the feature is tied to.
* When set, updates to this feature also update the tied value.
*/
float* tied_value{nullptr};

/**
Expand Down Expand Up @@ -67,6 +71,12 @@ class TouchFeature
return value;
}

/**
* @brief Updates the feature using the tied value.
* Ensures that the tied value is not null and synchronizes the tied
* value with the feature's updated value.
* @return True if the update was successful; false if `tied_value` is null.
*/
bool update()
{
if(tied_value == nullptr)
Expand All @@ -79,10 +89,18 @@ class TouchFeature
return true;
}

/**
* @brief Ties the feature to an external value.
* @param new_tie Pointer to the external value to tie the feature to.
* @return True if the tie was successful; false if `new_tie` is null.
*/
bool tie(float* new_tie)
{
if(new_tie == nullptr)
{
assert(false && "tied_value cannot be null!");
return false;
}

tied_value = new_tie;
return true;
Expand Down Expand Up @@ -122,6 +140,10 @@ class Brush : public TouchFeature
public:
Brush() = default;

/**
* @brief Constructs a Brush feature tied to an external value.
* @param tied Pointer to the external value to tie the feature to.
*/
explicit Brush(float* tied)
: TouchFeature(tied)
{
Expand All @@ -141,14 +163,19 @@ class Brush : public TouchFeature

/**
* @brief Derived class implementing the "rub" touch feature.
* The feature value is based on the absolute value of movement,
* this increasing as the sensors are rubbed in any direction.
* The feature value is based on the absolute value of movement. This increases
* as the sensors are rubbed in any direction, making it ideal for detecting
* bidirectional or multidirectional gestures.
*/
class Rub : public TouchFeature
{
public:
Rub() = default;

/**
* @brief Constructs a Rub feature tied to an external value.
* @param tied Pointer to the external value to tie the feature to.
*/
explicit Rub(float* tied)
: TouchFeature(tied)
{
Expand Down

0 comments on commit 4fdde04

Please sign in to comment.