diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index 051f87779d..4733a87a87 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -464,7 +464,8 @@ double Encoder::PIDGet() { */ void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) { // Force digital input if just given an index - m_indexSource = std::make_unique(channel); + m_indexSource = std::make_shared(channel); + AddChild(m_indexSource); SetIndexSource(*m_indexSource.get(), type); } diff --git a/wpilibc/src/main/native/include/Encoder.h b/wpilibc/src/main/native/include/Encoder.h index b34f73ba29..5e856fdf0d 100644 --- a/wpilibc/src/main/native/include/Encoder.h +++ b/wpilibc/src/main/native/include/Encoder.h @@ -91,7 +91,7 @@ class Encoder : public SensorBase, public CounterBase, public PIDSource { std::shared_ptr m_aSource; // The A phase of the quad encoder std::shared_ptr m_bSource; // The B phase of the quad encoder - std::unique_ptr m_indexSource = nullptr; + std::shared_ptr m_indexSource = nullptr; HAL_EncoderHandle m_encoder = HAL_kInvalidHandle; friend class DigitalGlitchFilter; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java index abd17727bb..472222ac89 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java @@ -540,6 +540,7 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, Senda } m_indexSource = new DigitalInput(channel); m_allocatedI = true; + addChild(m_indexSource); setIndexSource(m_indexSource, type); }