//====================================================================================================== // Copyright 2023, NaturalPoint Inc. //====================================================================================================== /** * This is an example glove device provided to demonstrate how a plugin device can be set up as a glove device * in Motive. This class derives from GloveDeviceBase class which contains basic setups required by gloves. */ #pragma once #include #include // OptiTrack Peripheral Device API #include "dllcommon.h" #include "GloveDeviceBase.h" #include "GloveDataFormat.h" #include "ExampleGloveAdapterSingleton.h" namespace OptiTrackPluginDevices { namespace ExampleDevice{ class ExampleGloveDevice; class ExampleGloveDeviceFactory; void ExampleGlove_EnumerateDeviceFactories(AnalogSystem::IDeviceManager* pDeviceManager, std::list>& dfs); void ExampleGlove_Shutdown(); /** * For creating a device in Motive, a factory class must be created first. This example class inherits from the * parent glove device factory where common glove functionalities and configurations are set. */ class ExampleGloveDeviceFactory : public OptiTrackPluginDevices::GloveDeviceFactoryBase { public: ExampleGloveDeviceFactory(std::string deviceName, sGloveDeviceBaseInfo deviceInfo) : GloveDeviceFactoryBase(deviceName.c_str(), deviceInfo.gloveId), mDeviceInfo(deviceInfo) { } /** * Return device factory name */ virtual const char* Name() const override; /** * The following method gets called by Motive. It creates and returns a new instance of device and transfers ownership to Motive. */ std::unique_ptr Create() const override; private: sGloveDeviceBaseInfo mDeviceInfo; }; /** * ExampleGloveDevice inherits from GloveDeviceBase and demonstrates how a glove plugin device can be created. * Each device gets their own collection thread where they populate the channel data. This class is inherited from the parent * GloveDeviceBase class where the basic glove setup is shown. */ class ExampleGloveDevice : public OptiTrackPluginDevices::GloveDeviceBase { public: ExampleGloveDevice(uint32_t serial, sGloveDeviceBaseInfo deviceInfo); virtual ~ExampleGloveDevice() = default; // IDevice implementation virtual bool Configure(); virtual bool Deconfigure(); virtual bool StartCapture(); virtual bool StopCapture(); virtual void OnPropertyChanged(const char* propertyName); private: /** * Collection thread for populating glove analog data channels */ static unsigned long __stdcall CollectionThread(LPVOID Context); unsigned long DoCollectionThread() override; void* mCollectionThread = nullptr; }; } }