Creation of a C++ InputProvider

Jun 25, 2009 at 4:49 PM
Edited Jun 25, 2009 at 4:49 PM

Hello,

I try to create a new InputProvider written in C++. So, I use example of Touchlib InputProvider to create this one.

Everything compiles but there's still a problem in my Provider : When I launched MTVista configuration tool, my provider does not appear.

I think there's still a problem in my project since it seems InputProvider is not linked to IProvider interface from Multitouch.Contracts project and I guess it's the main reason I can't see it in configuration tool.

As I'm a real beginner with Visual Studio, may you give me a few hints to achieve this ?

For example, my project is a "Win32 / Win32 project / DLL" project ? Is it ok to build a new provider DLL ?

Which references are required by project ?

Thanks in advance for your help !

Regards

Laurent

 

Jun 26, 2009 at 2:38 PM

Hello,

I realized some more tests :

- I create a EmptyProvider inside a "C++\CLR\Class library" project. InputProvider.h defines class, methods and attributes but doesn't do anything. This provider is not found by MTV configuration app.

- I create an EmptyProvider inside a"C#\Windows\Class library" project. InputProvider.cs defines class, methods and attributes but doesn't do anything. This provider is found by MTV configuration app.

When I check structure of TouchlibProvider.dll, I can see something very similar to my C++ dll. I don't understand where is the problem.

Some hints or ideas are very welcome since I must define my provider as a C++ project.

Thanks in advance.

Laurent

 

Coordinator
Jun 26, 2009 at 6:50 PM

Your c++ dll is not recognized because it is not .NET library. You have to use Managed C++ (CLI/C++).

Jun 26, 2009 at 11:10 PM
Edited Jun 26, 2009 at 11:16 PM

Thank you nesher for this answer !

Unfortunately, as I'm a java man, I''m not sure to understand what really means C++ CLI code :D

Im my second test, my provider is defined in a "C++\CLR\Class library" project. It seems to me it's the main condition to get a C++ CLI library.

Here is the code of InputProvider.h defined in my project created in "Multitouch.InputProviders solution" :

-----------------------------------------------------------------------------------------------------------------

 

// TestProvider.h

#pragma once

// Il s'agit du fichier DLL principal.
using namespace System::Collections::Generic;
using namespace System::Windows;
using namespace System::Diagnostics;
using namespace System::ComponentModel::Composition;
using namespace Multitouch::Contracts;

namespace TestProvider
{
	[AddIn("TestProvider", Publisher = "Laurent", Description = "Empty provider", Version = "1.0.0.0")]
    [Export(IProvider::typeid)]
	public ref class InputProvider : IProvider
	{
	public:
        virtual event System::EventHandler<Multitouch::Contracts::NewFrameEventArgs^>^ NewFrame;
        
		// -----------------------------------------------------
		// Constructor
		// -----------------------------------------------------
        InputProvider(void)
        {
        }

		// -----------------------------------------------------
		// Destructor
		// -----------------------------------------------------
        virtual ~InputProvider(void)
        {
           Stop();
        }

		// -----------------------------------------------------
		// Check if Provider has configuration data
		// -----------------------------------------------------
		virtual property bool HasConfiguration
        {
            bool get(void)
            {
                return false;
            }
        }

		// -----------------------------------------------------
		// SendEmptyFrames flag
		// -----------------------------------------------------
        virtual property bool SendEmptyFrames;

		// -----------------------------------------------------
		// Configuration getter
		// -----------------------------------------------------
        virtual UIElement^ GetConfiguration(void)
        {
            return nullptr;
        }

		// -----------------------------------------------------
		// Send Image Type
		// -----------------------------------------------------
		virtual bool SendImageType(ImageType imageType, bool isEnable)
        {
            return false;
        }

		// -----------------------------------------------------
		// Check if Provider is running
		// -----------------------------------------------------
        virtual property bool IsRunning
        {
            bool get(void)
            {
                return isRunning;
            }
        }

		// -----------------------------------------------------
		// Start Provider
		// -----------------------------------------------------
        virtual void Start(void)
		{
        }

		// -----------------------------------------------------
		// Stop Provider
		// -----------------------------------------------------
        virtual void Stop(void)
        {
            isRunning = false;
        }

	private:    
		// -----------------------------------------------------
		// isRunning flag
		// -----------------------------------------------------
        bool isRunning;
		

	}
}

 

-----------------------------------------------------------------------------------------------------------------

I think I've got a problem with some project parameters but I can't find which one :(

I don't know if it matters but I use VS2008 SP1 on WIN7.

[EDIT] : I've uploaded my 2 "empty providers" projects (C++ and C#) here.

C# provider is ok. C++ is ko.

 

Coordinator
Jul 4, 2009 at 11:36 AM

Add #include "InputProvider.h" in Stdafx.cpp. Also you are missing ; before last }

Jul 6, 2009 at 9:04 AM

Thank you Nesher ! I'll try to test this asap.

To bypass this problem, I built a C++ "tracker" in console mode  which sends TUIO messages to MTV TUIO provider. It works fine but surely with lower performances than a direct provider.