2

In a Microsoft Surface 1.0 SDK project based on WPF, I'd like to transform contacts captured in a small part of the screen to match the whole screen (like a virtual touchpad).

After capturing a contact and transforming it's position and orientation I would like to send it back to the event queue. I already figured out that there seems to be no way to create a "new Contact()" or to change anything in the "ReadOnlyContactCollection" (like it's name already says).

Here's what I was trying to do:

private void OnContactDown(object sender, ContactEventArgs e)
{
    base.OnContactDown(e);
    e.Contact.Capture(this);

    // transform the contact's center and orientation
    // and write them back into e.Contact via own private method
    // e.Contact = transformContact(e.Contact);

    // keep transformed contact in the event queue
    // so it can be processed at it's new position
    e.Handled = false;
}

My next idea was to make use of the simulator and automation to create SimulatedContacts, but sadly this doesn't work on the surface table itself, only in the simulator.

Is there any way to send out "virtual" contacts (that don't exist in the raw image) so that they will be recognized by the surface (without the use of the simulator)? How does the SurfaceInput.exe send out the recognized contacts?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
HeBu
  • 125
  • 1
  • 8

1 Answers1

0

Surface v1 doesn't officially support WPF 4.0, but others have figured out how to take Surface v1 input and route it into the standardized & extensible touch APIs that come with WPF 4.0. Take a look at http://nui.joshland.org/2010/07/how-to-write-surface-applications-with.html for creating a custom "touch device" that transforms Surface input into WPF 4.0 input events. Following that same approach, you can create another "touch device" on your own in order to pass in your fake touches.

Robert Levy
  • 28,747
  • 6
  • 62
  • 94
  • Seems to be a reasonable solution. I'll try installing Win7 on the Surface v1 first, then I'll try to use MultiTouchVista and Surface Toolkit for Windows Touch or Blake.NUI to get the Surface Input converted into Windows touch events. – HeBu Feb 22 '11 at 10:38
  • You don't need Win7. Definitely go with Blake.NUI... it interacts directly with WPF rather than taking a longer and more complicated route of pumping Surface input into Win7. MTV is good for when you want to have non-Surface applications work with Surface input but for other scenarios it's not really appropriate. – Robert Levy Feb 22 '11 at 13:56
  • @Robert Levy : Don't I need to install Surface Toolkit for Windows Touch to run Blake.NUI applications? I tried to run the Surface TestApplication which comes with Blake.NUI and it says, that it can't find the RegisterTouchWindow in the user32 DLL. Should I patch the Surface Toolkit installer and install it on Vista? – HeBu Mar 01 '11 at 14:28
  • 1
    HeBu, I answered your question on the Blake.NUI forum: http://blakenui.codeplex.com/discussions/248005 In short, do not install Win7 or Surface Toolkit on your Surface. I just have an extra call in the Surface sample and you need to comment out NativeTouchDevice.RegisterEvents(this). – Joshua Blake Mar 01 '11 at 16:42
  • I finally managed to derive my own SimulatedTouchDevice from System.Windows.Input.TouchDevice to send out my mapped positions. Now I have to face the question, why the ScatterView in my application won't behave like it should, although it is triggered by the TuchDown events. But that's another story... – HeBu Mar 07 '11 at 17:22
  • You will need to use the version of ScatterView contained in the Surface Toolkit for Windows Touch - not the version contained in the Surface v1 SDK. – Robert Levy Mar 07 '11 at 21:00
  • My final solution uses a SimulatedTouchDevice based on the Blake.NUI's NativeTouchDevice. The application is based on WPF4 / Surface Toolkit 1.5 without use of Surface SDK 1.0 and Blake.NUI, running on a Win7 system, with MultiTouchVista + SurfaceInputProvider for getting the contact events converted to touch points. Yeah, I know - the surface table is not a surface table anymore without Vista and contact events... but Surface 2.0 is coming soon, anyway. – HeBu Mar 14 '11 at 21:14