{"id":677,"date":"2011-06-30T15:34:51","date_gmt":"2011-06-30T10:04:51","guid":{"rendered":"http:\/\/www.e-consystems.com\/blog\/windowsce\/?p=677"},"modified":"2023-08-15T12:31:28","modified_gmt":"2023-08-15T07:01:28","slug":"touch-gestures-windows-embedded-compact-7","status":"publish","type":"post","link":"https:\/\/www.e-consystems.com\/blog\/windowsce\/touch-gestures-windows-embedded-compact-7\/","title":{"rendered":"Touch Gestures in Windows Embedded Compact 7"},"content":{"rendered":"<p>Touch screen and gesture support a few years ago a niche technology\u00a0that was found in very few specialized businesses and industrial applications has suddenly seems to be everywhere. One day in the near future, operating a gadget, computer or other electronics devices without a touchscreen may seem as obsolete one to us like the idea of using a PC without a mouse does today.<\/p>\n<p>Moreover, gesture support has been the most promising feature of WEC7 from the User Interface perspective. For some time now, we had wanted to develop some real cool graphical user interface with Windows CE and every time in our brain storming sessions someone would come up with the lack of support of a full-fledged gesture support in Windows CE 6.0. Without gestures, I don\u2019t think we can associate cool and UI anymore. So as soon as I encountered the fact that WEC 7 has complete gesture support, the immediate thought of using gestures and Silverlight made my imagination run wild.<\/p>\n<p>Windows Embedded Compact 7 supports gestures that are single-touch, dual-touch symmetrical, and multi-touch with two contact points. This blog explains how to use the Touch Gestures in the Compact 7 WIN32 applications. This blog explains the Gesture events that are already supported by Windows Embedded Compact 7. It does not explain how to customize the touch gestures.<\/p>\n<p>So, I started to see what Microsoft says about gestures in WEC 7. In this blog post, I shall highlight what Microsoft says is possible with Gestures in WEC7 on the following lines:<\/p>\n<p>1. Touch Gestures in Compact 7<\/p>\n<p>2. OS Design Requirements<\/p>\n<p>3. WIN32 Gesture Application<\/p>\n<ul>\n<li>Enabling the Gestures<\/li>\n<li>Processing the Gestures<\/li>\n<li>Multi-touch Gestures<\/li>\n<li>Auto Gestures<\/li>\n<\/ul>\n<p>4. Building WIN32 Gestures Application<\/p>\n<p>&nbsp;<\/p>\n<h2>Touch Gestures in WEC 7<\/h2>\n<p>Compact 7 supports the following gestures:<\/p>\n<ul>\n<li><strong>Direct Manipulation &#8211; <\/strong>The user manipulates an object on the screen, which reacts so that the same point on the object always remains under the same finger. Direct manipulation can be single-touch, dual-touch symmetrical, or multi-touch with two contact points.<\/li>\n<\/ul>\n<ul>\n<li><strong>Double Tap &#8211; <\/strong>A double-tap represents the left double-click of a mouse.<\/li>\n<\/ul>\n<ul>\n<li><strong>Flick &#8211; <\/strong>The user presses a finger on the screen, moves in any direction, and then lifts up the finger to initiate scrolling that continues for a short time.<\/li>\n<\/ul>\n<ul>\n<li><strong>Hold &#8211; <\/strong>The user presses and holds a finger on the screen. This represents the right-click of a mouse<\/li>\n<\/ul>\n<ul>\n<li><strong>Pan &#8211; <\/strong>The user presses and holds a finger on the screen and then drags the finger in any direction. This represents a mouse move event.\u00a0Panning can occur after a hold gesture.<\/li>\n<\/ul>\n<ul>\n<li><strong>Tap &#8211; <\/strong>A tap represents the left click of a mouse.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>OS Design Requirements<\/h2>\n<p>To use the Touch Gestures in Compact 7, the OS image must include the following sysgen variables.<\/p>\n<ul>\n<li>SYSGEN_TOUCHGESTURE &#8211; Core OS -&gt; Windows Embedded Compact \u2013&gt;      Shell and User Interface -&gt; Graphics, Windowing and Events -&gt; Touch      Gesture GWES component.<\/li>\n<li>SYSGEN_PHYSICSENGINE &#8211; Core OS -&gt; Windows Embedded Compact \u2013&gt;      Shell and User Interface -&gt; Graphics, Windowing and Events -&gt;      Gesture Physics Engine<\/li>\n<\/ul>\n<p>The OS image must also include properly working touch driver.<\/p>\n<p>We can use CETouchView, a standalone tool in the Windows Embedded Compact Test Kit (CTK), to verify the raw touch data and gesture messages generated by touch device.<\/p>\n<p>&nbsp;<\/p>\n<h2>WIN32 Gesture Application<\/h2>\n<h3><span style=\"text-decoration: underline;\">Enabling the Gestures<\/span><\/h3>\n<p>All gesture events must be enabled for every window by calling <strong>EnableGestures<\/strong> API. QueryGestures API can be used to identify the gestures that are already enabled. If the Gesture event is enabled, the gesture engine posts the WM_GESTURE message to the Window Procedure to indicate that a gesture has occurred or is in progress.<\/p>\n<h3><span style=\"text-decoration: underline;\">Processing the Gestures<\/span><span style=\"text-decoration: underline;\"> <\/span><\/h3>\n<p><strong>WM_GESTURE<\/strong> Message:<\/p>\n<p>wParam &#8211; ID of the gesture command<\/p>\n<p>lParam &#8211; HGESTUREINFO handle to the gesture information<\/p>\n<p>If the application processes the gesture, then it returns a nonzero value. If the application does not process the gesture, it must pass the message to <strong>DefWindowProc<\/strong>.<\/p>\n<p>The gesture ID can be used to determine whether the window procedure has to handle the gesture or <strong>DefWindowProc<\/strong> to handle the gesture. If the window procedure handles the gesture, <strong>GetGestureInfo<\/strong> API must be called to obtain more information about the gesture. If window procedure processes the gesture, it must not pass the message to the default window procedure. After processing the message, <strong>CloseGestureInfoHandle<\/strong> must be called to close the handle.<\/p>\n<p>The following table lists the commands that are supported by the WM_GESTURE message:<\/p>\n<p>&nbsp;<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>Command<\/strong><\/td>\n<td width=\"432\" valign=\"top\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_BEGIN<\/strong><\/td>\n<td width=\"432\" valign=\"top\">Marks the beginning of each touch gesture, when the user first touches   the screen<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_END<\/strong><\/td>\n<td width=\"432\" valign=\"top\">Marks the end of each touch gesture, when the user lifts their finger   from the screen<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_PAN<\/strong><\/td>\n<td width=\"432\" valign=\"top\">A pan   gesture occurs when the user touches the screen and moves their finger in any   direction. This represents a mouse move event.&nbsp;<\/p>\n<p>When the   finger moves a distance equal to or greater than the pan threshold, the gesture   recognizer sends an initial <strong>GID_PAN<\/strong> message   that contains the current location of the finger. For more information about   defining the pan threshold, see <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee500273.aspx\">GESTUREMETRICS<\/a>.<\/p>\n<p>The   gesture recognizer sends a new <strong>GID_PAN<\/strong> message   for each mouse move message until the user lifts up their finger. <strong>GID_END<\/strong> marks the end of the pan movement. Mouse   messages are interleaved for backward compatibility, but the gesture messages   are always received before the corresponding mouse events.<\/p>\n<p>You can   calculate the movement delta by comparing two consecutive pan messages.<\/p>\n<p>Panning   can occur after a hold gesture.<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_SCROLL<\/strong><\/td>\n<td width=\"432\" valign=\"top\">A flick gesture occurs   when the user touches their finger to the screen and then moves the finger   quickly in any direction before lifting the finger.&nbsp;<\/p>\n<p>The gesture recognizer   sends the GID_SCROLL message   after a flick.<\/p>\n<p>The ullArguments member of GESTUREINFO contains the following   information:<\/p>\n<ul>\n<li>Direction:   GID_SCROLL_DIRECTION(x) macro   to retrieve the direction. The direction is one of the following values:\n<ul>\n<li>o ARG_SCROLL_NONE<\/li>\n<li>o ARG_SCROLL_DOWN<\/li>\n<li>o ARG_SCROLL_LEFT<\/li>\n<li>o ARG_SCROLL_UP<\/li>\n<li>o ARG_SCROLL_RIGHT<\/li>\n<\/ul>\n<\/li>\n<li>Velocity:   GID_SCROLL_VELOCITY(x) macro   to retrieve the velocity, in pixels per second.<\/li>\n<li>Angle:   GID_SCROLL_ANGLE(x) macro to   retrieve the angle as an unsigned, 16-bit integer. GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) macro to convert the angle   to radians.<\/li>\n<\/ul>\n<p>The gesture recognizer   sends the GID_SCROLL message   to the window that received the first gesture message, usually a pan or a   hold message, for the current touch session.<\/p>\n<p>A flick frequently occurs   after a pan (one or more GID_PAN gesture messages followed by a GID_END message   immediately before the flick).<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_HOLD<\/strong><\/td>\n<td width=\"432\" valign=\"top\">A hold   gesture occurs when the user touches the screen and holds their finger down   for more than the hold time-out period. This represents the right click of a   mouse.&nbsp;<\/p>\n<p>The   gesture recognizer sends a <strong>GID_HOLD<\/strong> gesture message and then sends a <strong>GID_END<\/strong> message   when the user lifts their finger or at the end of the hold time threshold.<\/p>\n<p>The hold   gesture can be followed by a panning movement that generates several <strong>GID_PAN<\/strong> messages, but the gesture recognizer never sends   a <strong>GID_HOLD<\/strong> message after a <strong>GID_PAN<\/strong> message. The gesture recognizer always sends a <strong>GID_HOLD<\/strong> message first after the user touches the   screen, if the gesture parameters meet the hold time-out recognition values.<\/p>\n<p>For more   information about defining the hold time-out period, see <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee500273.aspx\">GESTUREMETRICS<\/a>.<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_SELECT<\/strong><\/td>\n<td width=\"432\" valign=\"top\">A select,   or tap, gesture occurs when the user taps on the screen for a period of time   that is less than the hold time-out period. A tap represents the left click   of a mouse.&nbsp;<\/p>\n<p>There can   be several WM_MOUSEMOVE messages after the WM_LBUTTONDOWN event and before   the GID_SELECT message<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_DOUBLESELECT<\/strong><\/td>\n<td width=\"432\" valign=\"top\">A double select or double tap, gesture occurs when the user taps twice   on the screen within a period of time that is less than the hold time-out   period. A double tap represents the left double-click of a mouse.<\/td>\n<\/tr>\n<tr>\n<td width=\"158\" valign=\"top\"><strong>GID_DIRECTMANIPULATION<\/strong><strong> <\/strong><\/td>\n<td width=\"432\" valign=\"top\">Objects on the   screen react so that the same point on an object always remains underneath   the same finger. Direct manipulation maps points in an object&#8217;s local space   and points in screen space, without the need for gesture processing. During   direct manipulation, the gesture recognizer does not send GID_* messages.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h3><span style=\"text-decoration: underline;\">Multi-touch Gestures<\/span><\/h3>\n<p>Depending on the <strong>touch screen driver<\/strong>, Compact 7 supports multi-touch gestures with two contact points, or dual-symmetrical gestures. If the <strong>touch screen driver<\/strong> supports dual-symmetrical gestures, the gesture engine will try to determine how the X and Y coordinates should be paired. For both dual-touch symmetrical and multi-touch gestures, the gesture recognizer designates one contact point as the primary contact and keeps track of the distance between the primary contact and the secondary contact. The gesture engine posts the GID_DIRECTMANIPULATION command through the WM_GESTURE message when it detects the multi-touch or dual symmetrical.<\/p>\n<h3><span style=\"text-decoration: underline;\">Auto Gestures<\/span><\/h3>\n<p>Automatic handling for flick gestures can be enabled in all Win32 windows that allow scrolling by including the following sysgen variable in OS image.<\/p>\n<ol>\n<li>SYSGEN_GESTUREANIMATION &#8211; Core OS -&gt; Windows Embedded Compact \u2013&gt; Shell and User Interface -&gt; Graphics, Windowing and Events -&gt; Default Gesture Response<\/li>\n<\/ol>\n<p>Window auto gestures only work with windows that have the WS_HSCROLL or WS_VSCROLL styles.<\/p>\n<p>If automatic gestures are enabled, no need to process the WM_GESTURE window message for the scroll message, because the window procedure automatically passes the WM_GESTURE message to the default window procedure. Instead, the windows procedure can process WM_SCROLL and the WM_VSCROLL messages. The window auto gesture processes the flick gesture messages, and generates the horizontal or vertical scroll messages with the physics engine effect applied.<\/p>\n<p>Window auto gesture does not process the pan gesture. The application must process the pan gesture in order to respond to it. This gives the application the flexibility to determine how to respond to the gesture.<\/p>\n<p>&nbsp;<\/p>\n<h2>Building WIN32 Gestures Application<\/h2>\n<p>All the Gestures macros and functions are defined in WinUser.h. Add the TouchGesture.lib to the Project -&gt; Application Properties -&gt; Configuration Properties -&gt; Linker -&gt;Input field.<\/p>\n<p>I am rigging up my development board (e-con\u2019s <a href=\"https:\/\/www.e-consystems.com\/iMX6-development-board.asp\">Alioth \u2013 PXA300 based reference platform<\/a> running Windows Embedded Compact 7.0) with some multi touch sensor and am going to play around with gestures in WEC 7. Stay tuned to this blog to hear more from my experimentations with gestures.<\/p>\n<p>You want to know anything particular about gestures, go ahead and post a comment here and maybe I would include that in my experimentation.<\/p>\n<p>Ok!! Let\u2019s get my hand dirty on this one now\u2026..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Touch screen and gesture support a few years ago a niche technology\u00a0that was found in&#8230;<\/p>\n","protected":false},"author":15,"featured_media":1366,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[192],"tags":[107,132,93],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/677"}],"collection":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/comments?post=677"}],"version-history":[{"count":25,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/677\/revisions"}],"predecessor-version":[{"id":1866,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/677\/revisions\/1866"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media\/1366"}],"wp:attachment":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media?parent=677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/categories?post=677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/tags?post=677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}