Hi All,
I’ve just created plugin which InputDevice, it simply reads data from Eye tracker device and set cursor position.
Could you please advice how can I start/stop this plugin from C++ code?
Thing is when I set it enabled it gets started right away in my Editor even when I did not started game yet…
You can’t disable plugin that requires restart to take effect, but you can unload module but then you lose your code from memory and you won’t be able to reeable it, you need to implement enabling and disabling yourself.
I think you misunderstand what plugin is in UE4 considering you see disabling as viable option and how code works in engine. UE4 code is divided in to modules compiled to dll in similar fashion as Linux kernel if you ever delt with it, which can be dynamically loaded and unloaded and it can be compiled monolithicly if needed. When you make C++ game project or plugin, you create extra module (you can actually make more then 1 if thats needed) which is added in to engine… yes it actully means you extending engine rether then making code of the game, the engine is pracicly the game it self. Regardless if module is in the engine code, or gamep roject or plugin they all work the same and under same rules, only diffrence is way those modules are distributed, in matter of fact game project nad plugins are brand new features that came with UE4, if you ever used UE3 (aka UDK) each project needed new installation of engine… im not joking. So UE4 plugins are not some special extendiables you can just disable and enable entirely, they are modules, if module is gone from memory then your code is dead.
First check if it is really needed to disable, if user intend of enbleing plugin is enouth, i dont think declaring DeviceInput gonna do harm. Yes your module will be always on in editor, that 100% perfecly normal and how most engine code works, engine needs to know o hey there eye tracking device that i can use, o hey i can do binding to it in project settings, without your module on it’s impossible, disabling plugin or unloading module will kill that information, you plugin is part of the engine. For some reason opther InputDevice plugins don’t need so maybe issue is in your design, look up how they are constructed and try to mimic what they are doing and see how they deal with same issues, you want your plug in to function the same way, since user will expect for it work same way.
Maybe don’t control cursor direly if you do that (as it sounds like doing so), let user bind that since they might use eye tracking in different way then you think you gonna use it, developer should have access to raw numbers and have full freedom on how to use it. Alternatively you can provide extra code that makes eye input to set mouse position, as some component or maybe actor or something.
If device sleeping is a issue then try to hook up to it somethings that detects activity of the game.
, thank you very much for explanation - now I have more clear picture on engine. (I am very new to Unreal and its ecosystem
)