#737 – Touch Behavior when Maximum Number of Touch Points Reached

When you already have the maximum number of touch points engaged as input devices, additional touches on the device will be ignored.

For example, assume that your hardware supports a maximum of two touch points and you’re already touching the screen with two fingers.  If you place a third finger on the screen, you will not get a TouchDown for that third finger.  However, if you leave all three fingers on the screen and then lift a finger up, the first finger lifted up will not see a TouchUp event.  The behavior can be summarized as:

  • If you’ve already reached maximum number of touch points, adding fingers will not result in TouchDown events
  • If you currently have more fingers touching the screen than the maximum number of touch points, lifting  a finger will not result in a TouchUp event until you’re back down to the maximum number of touch points
Advertisement

#736 – Finding the Maximum Number of Touch Points at Run-time

You can write code that discovers at run-time the number of touch points supported by the hardware that you’re running on.  You do this by calling the GetSystemMetrics Win32 API call.

    class Program
    {
        [DllImport("user32.dll")]
        static extern int GetSystemMetrics(int nIndex);

        // Index passed in to GetSystemMetrics() indicates
        // what data we're asking for.
        private const int SM_DIGITIZER = 94;
        private const int SM_MAXIMUMTOUCHES = 95;

        // Masks used to check results from SM_DIGITIZER check
        private const int NID_READY = 0x80;
        private const int NID_MULTI_INPUT = 0x40;

        static void Main(string[] args)
        {
            string info;

            int digitizer = GetSystemMetrics(SM_DIGITIZER);

            if ((digitizer & (NID_READY + NID_MULTI_INPUT)) == NID_READY + NID_MULTI_INPUT)
            {
                int numTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES);
                info = string.Format("Multitouch ready, {0} inputs supported", numTouchPoints);
            }
            else
                info = "Multitouch not supported";

            Console.WriteLine(info);
            Console.ReadLine();
        }
    }

736-001

#735 – System Applet Indicates Maximum Number of Touch Points

The number of simultaneous touch points depends on the particular touch hardware that you’re using.  To quickly check what is supported on the machine that you’re using, bring up the System applet in Control Panel.  (Control Panel | System and Security | System, or just type “System” in Windows 7 or Windows 8 search.

The maximum number of simultaneous touch points is listed in the middle of the window, labeled Pen and Touch.

735-001

#733 – A Full List of Touch Related Events

Here’s a full list of UIElement events that you can handle when you want to handle touch input.  All of the events listed below are also defined for ContentElement.

All events are bubbling, unless flagged as tunneling.

Raw touch events:

  • GotTouchCapture – element has captured touch input
  • LostTouchCapture – element has lost touch capture
  • PreviewTouchDown – finger touches element  (tunneling)
  • PreviewTouchMove – finger moving on screen  (tunneling)
  • PreviewTouchUp – finger lifts off screen after moving  (tunneling)
  • TouchDown – finger touches element
  • TouchEnter – finger moves into element from outside
  • TouchLeave – finger moves out of element
  • TouchMove – finger moving on screen
  • TouchUp – finger lifts off screen after moving

Events related to manipulation (gestures):

  • ManipulationBoundaryFeedback – manipulation enters boundary
  • ManipulationCompleted – manipulation on element finishes
  • ManipulationDelta – position changes during manipulation
  • ManipulationInertiaStarting – finger leaves screen during manipulation
  • ManipulationStarted – manipulation on element starts
  • ManipulationStarting – user puts finger on element

#731 – The Idea of Multi-Touch

Touch input is the idea of using your finger as an input device by touching a screen.  Multi-touch means that you can touch the screen with more than one finger, with each finger touching a different spot on the screen.

Multit-touch is typically used to track gestures that the user performs with more than one finger.  For example, placing two fingers on the screen and then spreading the fingers apart is interpreted as a “zoom in” gesture.  Moving the two fingers together is intepreted as a “zoom out” gesture.  And placing two fingers on the screen and rotating them both is interpreted as a “rotate” gesture.

731-001731-002731-003

Windows 7 and Windows 8 both include support for multi-touch input.