Mouse (DirectInput): a little help needed

I’ve decided to create a node reading mouse data by DirectInput. it works so far (nicely outputs the relative and the absolute position and all the buttons) but i have some problems with it.
so first (and probably the simpler question is): how can i execute a method only at the initialization of the node? because now there has to be a separate pin for that (and it turns red before initialization).

second: i cannot set the cooperative level (i guess it’s the default now: it looks like background and non-exclusive). if i put back the commented out part i get this error in every SetCooperativeLevel()'s first argument (“this”):
cannot convert from “VVVV.Nodes.C1_0DirectInputMouseNode” to “System.Windows.Forms.Control”

so there is probably something what could solve the situation. anyone could help here?

here’s what i hammered together so far (13.0 kB)

Hi, microdee.

If you want to create or do something only when node initializing, just use it’s constructor.

Place this after variables declaration:

[ImportingConstructor](ImportingConstructor)
public C1_0DirectInputMouseNode() {
	//Your run once code here
}

For cooperative level, you passing your node to this method by “this” keyword. It’s not right, because you need to pass current form or space i think.

hiya! thanks! this helps a lot.
oh then what i should put in the SetCooperativeLevel to fit in vvvv’s environment. because all the examples what i found about DirectInput use forms

well adding the constructor generated this error:

00:14:42 ERR : System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Object reference not set to an instance of an object.

Resulting in: An exception occurred while trying to create an instance of type 'VVVV.Nodes.C1_0DirectInputMouseNode'.

Resulting in: Cannot activate part 'VVVV.Nodes.C1_0DirectInputMouseNode'.
Element: VVVV.Nodes.C1_0DirectInputMouseNode -->  VVVV.Nodes.C1_0DirectInputMouseNode -->  TypeCatalog (Types='VVVV.Nodes.C1_0DirectInputMouseNode').

Resulting in: Cannot get export 'VVVV.Nodes.C1_0DirectInputMouseNode (ContractName="VVVV.PluginInterfaces.V1.IPluginBase")' from part 'VVVV.Nodes.C1_0DirectInputMouseNode'.
Element: VVVV.Nodes.C1_0DirectInputMouseNode (ContractName="VVVV.PluginInterfaces.V1.IPluginBase") -->  VVVV.Nodes.C1_0DirectInputMouseNode -->  TypeCatalog (Types='VVVV.Nodes.C1_0DirectInputMouseNode').

   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
   at System.ComponentModel.Composition.Primitives.Export.get_Value()
   at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
   at System.ComponentModel.Composition.ExportServices.GetExportLifetimeContextFromExport[T](Export export)
   at System.ComponentModel.Composition.ExportServices.<>c**DisplayClass1c`1.<CreateStronglyTypedExportFactoryOfT>b**1b()
   at System.ComponentModel.Composition.ExportFactory`1.CreateExport()
   at VVVV.Hosting.Factories.DotNetPluginFactory.CreatePlugin(INodeInfo nodeInfo, IPluginHost2 pluginHost)
   at VVVV.Hosting.Factories.DotNetPluginFactory.CreateNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost)
   at VVVV.Hosting.Factories.AbstractFileFactory`1.Create(INodeInfo nodeInfo, INode host)
   at VVVV.Hosting.HDEHost.factory_NodeInfoUpdated(Object sender, INodeInfo info)

what can i do now?

upload your code please

well i’ve just added what you said

with the constructor (37.3 kB)

You can’t acess FLogger and ISpreads in constructor, because it’s creating after it.

oh good to know:D