104 lines
2.7 KiB
C++

//======================================================================================================
// Copyright 2016, NaturalPoint Inc.
//======================================================================================================
//
// dllmain.cpp : Defines the entry point for the DLL application.
//
#include "dllcommon.h"
// stl
#include <list>
#include <memory>
using namespace std;
// OptiTrack Peripheral Device API
#include "IDeviceManager.h"
using namespace AnalogSystem;
// local devices
#include "ExampleGloveDevice.h"
using namespace OptiTrackPluginDevices;
int hostVersionMajor, hostVersionMinor, hostVersionRevision;
#ifdef OPTITRACKPERIPHERALEXAMPLE_EXPORTS
#define OPTITRACKPERIPHERALEXAMPLE_API __declspec(dllexport)
#else
#define OPTITRACKPERIPHERALEXAMPLE_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
using namespace OptiTrackPluginDevices;
using namespace ExampleDevice;
/**
* Defines the version information of the plugin DLL within Motive.
*/
OPTITRACKPERIPHERALEXAMPLE_API void DLLVersion(int hostMajor, int hostMinor, int hostRevision, int& dllMajor, int& dllMinor, int& dllRevision)
{
hostVersionMajor = hostMajor;
hostVersionMajor = hostMinor;
hostVersionMajor = hostRevision;
// report this peripheral device's version to host
dllMajor = 1;
dllMinor = 0;
dllRevision = 0;
}
/**
* Motive calls the following method on application start up. This register device factories with Motive
* so that the device can be instantiated when it's ready (1 factory per device)
*/
OPTITRACKPERIPHERALEXAMPLE_API int DLLEnumerateDeviceFactories(IDeviceManager* pDeviceManager)
{
list<unique_ptr<IDeviceFactory>> availDFs;
ExampleDevice::ExampleGlove_EnumerateDeviceFactories(pDeviceManager, availDFs);
for (list<unique_ptr<IDeviceFactory>>::iterator iter = availDFs.begin(); iter != availDFs.end(); iter++) {
// transfers ownership of device factory to host
pDeviceManager->AddDevice(std::move(*iter));
}
return (int)availDFs.size();
}
/**
* The following method gets called on application shutdown. Proper shutdown should happen here;
* including termination of the process of the DLL and memory unload.
*/
OPTITRACKPERIPHERALEXAMPLE_API int PluginDLLUnload(IDeviceManager* pDeviceManager)
{
// OPTIONAL: perform device DLL shutdown here
ExampleGlove_Shutdown();
return 0;
}
#ifdef __cplusplus
}
#endif
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}