Hi,
lion032 figured it out for his Kinect Plugin (The following are excerpts from his github code, all credit to him)
you can see where the IInputDevice you make will come to life in *Application.cpp files
I.E. In WindowsApplication.cpp → PollGameDeviceState( … )
if (!bHasLoadedInputPlugins)
{
TArray<IInputDeviceModule*> PluginImplementations = IModularFeatures::Get().GetModularFeatureImplementations<IInputDeviceModule>( IInputDeviceModule::GetModularFeatureName() );
for( auto InputPluginIt = PluginImplementations.CreateIterator(); InputPluginIt; ++InputPluginIt )
{
TSharedPtr<IInputDevice> Device = (*InputPluginIt)->CreateInputDevice(MessageHandler);
if ( Device.IsValid() )
{
ExternalInputDevices.Add(Device);
}
}
bHasLoadedInputPlugins = true;
}
This bit will run immediately after game play first starts, and will run through once
// Poll externally-implemented devices
for( auto DeviceIt = ExternalInputDevices.CreateIterator(); DeviceIt; ++DeviceIt )
{
(*DeviceIt)->Tick( TimeDelta );
(*DeviceIt)->SendControllerEvents();
}
}
And this bit will run every poll, checking all the custom input devices (I.E. your ones)
Your plugin modules .h file will need to extend IInputDeviceModule like the skeleton below. If it does it will appear in the array of IInputDeviceModules that the *Application initializes on the first game state poll (shown above)
IYourPluginName.h
#pragma once
#include "ModuleManager.h"
#include "IInputDeviceModule.h"
class I*YourPluginName* : public IInputDeviceModule {
public:
static inline I*YourPluginName*& Get()
{
return FModuleManager::LoadModuleChecked< I*YourPluginName* >("YourPluginHandel");
}
static inline bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded( "YourPluginHandel" );
}
}
Your plugin modules .cpp file will need to implement IInputDeviceModule’s CreateInputDevice method in addition to the usual suspects.
YourPluginName.cpp
class F*YourPluginName* : public I*YourPluginName*
{
virtual TSharedPtr< class IInputDevice > CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler);
// *+ other stuff...*
};
IMPLEMENT_MODULE(F*YourPluginName*, *YourPluginHandel*)
TSharedPtr< class IInputDevice > FKinectV2Plugin::CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler)
{
return MakeShareable(new F*YourInputDeviceName*(InMessageHandler));
}
// *+ other stuff...*
Create your device class similar to XInputDevice in the codebase, check lions KinectV2InputDevice for a refrence if your not sure what to do…
Best of luck