Tips for Writing New Plugins

Top  Previous 

Tips for Writing New Plugins

 

The easiest method for producing a new plugin is to start with one of the supplied plugins and make the necessary changes / additions.  The SimpleInOut plugin is a good candidate for starting the process.

 

1) Copy the SimpleInOut directory (along with its subdirectories) to a new name MyNewPlugin.

 

2) Group rename all files from SimpleInOut* to MyNewPlugin*

 

3) Search and replace within all files:

       SIMPLEINOUT -> MYNEWPLUGIN

       SimpleInOut -> MyNewPlugin

       Simpleinout -> mynewplugin

 

4) Edit the MyNewPlugin.html file.  Change the SimpleInOut text to a description of your own plugin.

 

5) If your plugin is input only, edit MyNewPlugin.cpp and change the IOXLoad routine to set the LOADPARMSOUT pluginOutput field to false.  .  You can then delete the OutputExecute code and anything else that is output specific.

 

6) If your plugin is output only, edit MyNewPlugin.cpp and change the IOXLoad routine to set the LOADPARMSOUT pluginInput field to false.  You can then delete all of the worker thread code and anything that is input specific.

 

7) Edit the Configuration, ShowInSettings, and ShowOutSettings dialogs to match your needs.  This is *much* easier if you use DialogBlocks

http://www.anthemion.co.uk/dialogblocks/

and the resproj/mynewpluginres.pjd project file, but you can use any method to create the new dialogs.

 

8) Edit the LoadConfig() and SaveConfig() routines in MyNewPlugin.cpp to load and save your plugins configuration data.

 

9) Change the SETTINGSINDATA and SETTINGSOUTDATA structure typedefs in resproj/mynewpluginsettingsinput.h and resproj/mynewpluginsettingsoutput.h to contain the fields needed for your purposes, then change the plugin code that accesses fields in those structures.  In particular, youll need to get/set the new fields from/to the dialog controls and re-write the serialize/deserialize code used for building and using the outData buffer.

 

10) Add the input and/or output code specific to your device or purpose by replacing the proper code sections in MyNewPlugin.cpp.  For output plugins, youll just re-write OutputExecute.  Input plugins can be a little more difficult, but most of your changes will be to code found in PluginWorkerThread::execute().

 

11) Run bakefile f msvc MyNewPlugin.bkl, bakefile f msvc6prj MyNewPlugin.bkl, and bakefile f gnu MyNewPlugin.bkl to re-generate the makefiles from the MyNewPlugin.bkl file in the build subdirectory.

 

That should do it.  Assuming that the device you are controlling isnt overly complicated, the process is actually easier than it sounds (really).