diff --git a/modules/touch/include/tuioear.h b/modules/touch/include/tuioear.h index a2db75f503..16d8750bf6 100644 --- a/modules/touch/include/tuioear.h +++ b/modules/touch/include/tuioear.h @@ -52,7 +52,7 @@ namespace openspace { class TuioEar : public TUIO::TuioListener { public: - TuioEar(); + explicit TuioEar(int port = 3333); ~TuioEar(); /** diff --git a/modules/touch/src/tuioear.cpp b/modules/touch/src/tuioear.cpp index 9173ff0295..150b2eaddc 100644 --- a/modules/touch/src/tuioear.cpp +++ b/modules/touch/src/tuioear.cpp @@ -96,8 +96,8 @@ std::vector TuioEar::takeRemovals() { } // Standard UDP IP connection to port 3333 -TuioEar::TuioEar() - : _tuioClient(3333) +TuioEar::TuioEar(int port) + : _tuioClient(port) { _tuioClient.addTuioListener(this); _tuioClient.connect(); diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index bb6e6b46b0..c94666ccea 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -40,6 +40,13 @@ using namespace TUIO; namespace { constexpr std::string_view _loggerCat = "TouchModule"; + constexpr openspace::properties::Property::PropertyInfo TuioPortInfo = { + "TuioPort", + "TUIO Port", + "TUIO UDP port, by default 3333. The port cannot be changed after startup.", + openspace::properties::Property::Visibility::AdvancedUser + }; + constexpr openspace::properties::Property::PropertyInfo EnableTouchInfo = { "EnableTouchInteraction", "Enable touch interaction", @@ -66,18 +73,28 @@ namespace { "relatively spherical objects.", openspace::properties::Property::Visibility::AdvancedUser }; + + struct [[codegen::Dictionary(TouchModule)]] Parameters { + // [[codegen::verbatim(TuioPortInfo.description)]] + std::optional tuioPort [[codegen::inrange(1, 65535)]]; + }; + + #include "touchmodule_codegen.cpp" } // namespace namespace openspace { TouchModule::TouchModule() : OpenSpaceModule("Touch") + , _tuioPort(TuioPortInfo, 3333, 1, 65535) , _touchIsEnabled(EnableTouchInfo, true) , _hasActiveTouchEvent(EventsInfo, false) , _defaultDirectTouchRenderableTypes(DefaultDirectTouchRenderableTypesInfo) { addPropertySubOwner(_touch); addPropertySubOwner(_markers); + _tuioPort.setReadOnly(true); + addProperty(_tuioPort); addProperty(_touchIsEnabled); _touchIsEnabled.onChange([this]() { _touch.resetAfterInput(); @@ -116,8 +133,11 @@ bool TouchModule::isDefaultDirectTouchType(std::string_view renderableType) cons _sortedDefaultRenderableTypes.end(); } -void TouchModule::internalInitialize(const ghoul::Dictionary&) { - _ear.reset(new TuioEar()); +void TouchModule::internalInitialize(const ghoul::Dictionary& dict) { + const Parameters p = codegen::bake(dict); + + _tuioPort = p.tuioPort.value_or(_tuioPort); + _ear = std::make_unique(_tuioPort); global::callback::initializeGL->push_back([this]() { LDEBUG("Initializing TouchMarker OpenGL"); diff --git a/modules/touch/touchmodule.h b/modules/touch/touchmodule.h index 6b922920d8..4c76f80f5a 100644 --- a/modules/touch/touchmodule.h +++ b/modules/touch/touchmodule.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -77,6 +78,7 @@ private: std::vector _deferredRemovals; std::vector _lastTouchInputs; + properties::IntProperty _tuioPort; properties::BoolProperty _touchIsEnabled; properties::BoolProperty _hasActiveTouchEvent; properties::StringListProperty _defaultDirectTouchRenderableTypes;