Should this provider work?

Sep 2, 2011 at 12:44 AM
Edited Sep 2, 2011 at 12:44 AM

Hi, I have been trying to create a simple provider that sends the same two contacts.  This is before I move on to make it work with kinect.  I have pretty much just copied the MultipleMice code and changed/added bits I think are needed.  Could someone tell me if it should work or what else I have to do.  It currently shows up in Multitouch.Configuration.WPF and gets started, altough I dont see any red dots at the locations I expect to.

 

namespace TestProvider
{
    [AddIn("TestProvider", Publisher = "Jonny Hughes", Description = "Should send two contacts", Version = "1.0.0.0"), Export(typeof(IProvider))]
    public class TestProvider : IProvider
    {
        Timer timer;
        Queue<Contact> contactsQueue;
        Contact test = new Contact(0, ContactState.New, new Point(300, 200), 50, 50);
        Contact test2 = new Contact(1, ContactState.New, new Point(100, 400), 50, 50);

        public TestProvider()
		{
            timer = new Timer(1000 / 60d);
            timer.Elapsed += timer_Elapsed;

			contactsQueue = new Queue<Contact>();
            contactsQueue.Enqueue(test);
            contactsQueue.Enqueue(test2);

			SendEmptyFrames = false;
		}

        public void Start()
        {
            IsRunning = true;
            timer.Start();
        }

        public void Stop()
        {
            IsRunning = false;
            timer.Stop();
        }

        public bool SendImageType(ImageType imageType, bool value)
        {
            return false;
        }

        public UIElement GetConfiguration()
        {
            return null;
        }

        public bool IsRunning { get; private set; }

        public bool HasConfiguration
        {
            get { return false; }
        }

        public bool SendEmptyFrames { get; set; }

        public event EventHandler<NewFrameEventArgs> NewFrame;

        void timer_Elapsed(object sender, ElapsedEventArgs e)
		{
			lock (contactsQueue)
			{
				if (SendEmptyFrames || contactsQueue.Count > 0)
				{
					EventHandler<NewFrameEventArgs> eventHandler = NewFrame;
					if (eventHandler != null)
						eventHandler(this, new NewFrameEventArgs(Stopwatch.GetTimestamp(), contactsQueue, null));
                }
			}
		}
    }
}

 

 

Thanks in advance

Jonny

Sep 2, 2011 at 2:22 AM

I have checked and the Multitouch.Framework.Logic is getting the contacts that I send in the event for new frame.  Anyone know why they are not showing up as the red dots on the screen like the multimouse provider does?

Sep 2, 2011 at 2:52 AM

After Mutlitouch.Framework.Logic receives a frame it calls DispatchFrame(e) but mine always has 0 sessions so it just returns without doing anything with the contacts.  

Coordinator
Sep 3, 2011 at 9:50 AM

The code looks right. The red dots are painted by multiple mice provider. You will have to implement this yourself.
Make sure you run  Multitouch.Driver.Console.exe each time you run your logic. It will add itself to sessions.
Also you have to send contacts not just with state New, but also other states.

Sep 23, 2011 at 4:43 AM

You may want to setup a test program that logs touch events to make sure they are getting through. But one thing to look for is the onscreen keyboard should pop up, and you may get a circle appear around your touch if the touch dwells for long enough.