The Windows Simulator is a tool provided in Visual Studio 11 Developer Preview that enables debugging Metro style applications in scenarios requiring hardware support such as rotation and touch. For a quick introduction to the Windows Simulator, see this blog entry. This article will introduce you to Touch Emulation in the Windows Simulator.
Touch Emulation in the Simulator enables developers to test and debug how an application reacts to different touch gestures. The Simulator does all the hard work of converting mouse events into touch events received by the running application. This is especially useful for developers who are creating Metro style applications that are touch-enabled but do not have a touch monitor to test those applications.
To demonstrate Touch Emulation inside the Windows Simulator, we will use the Touch Events Sample provided by the Windows Developer Preview Metro style apps samples. After downloading and unpacking the sample, open the solution TouchEvents.sln in Visual Studio 11 Developer Preview, then Debug the sample targeting the Windows Simulator:
The sample will run inside the Windows Simulator and will look something like this:
This sample code recognizes touch events in the right rectangle and displays the information about those events in the left rectangle. Using the Windows Simulator Touch Controls found on the Simulator palette, we can switch between Mouse mode and Touch mode:
When in Touch mode, the Windows Simulator shows a special mouse pointer indicating that it is in Touch Emulation mode. The Simulator will convert mouse clicks into touch events, and the application receives touch events exactly as it would if they were generated by a physical touch device.
The Windows Simulator can also simulate two finger gestures, such as the Pinch/Zoom gesture and the Rotate gesture. When using the two finger gestures, the Windows Simulator will display two contact points.
In Pinch/Zoom mode, use the mouse wheel to set the two contact points closer or farther apart from each other. If you click the left mouse button and rotate the wheel simultaneously, the Windows Simulator will send touch events to the target application as if the user was performing a Pinch/Zoom gesture on a physical touch device. Similarly, in Rotate mode you can use the wheel to rotate the two contact points relative to each other.
The Windows Simulator allows emulating the following touch gestures:
- Tap (single contact)
- Hold (single contact)
- Double Tap (single contact)
- Pan/Swipe (single contact)
- Flick/Inertia (single contact)
- Pinch/Zoom (2 contact points)
- Rotate (2 contact points)
We encourage you to use the Touch Emulation features in the Windows Simulator to develop your Windows 8 applications. These features allow you to test and debug your applications to ensure they work correctly for touch – without having a physical touch device.
To learn more about Touch input in Metro style applications, see the following articles:
Mynor Ivan Muralles
Software Design Engineer, Visual Studio