Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2013

    Question Is it possible to detect two (or more) simultaneous touches?

    To test multi-touch I am building a simple drum kit-like app. This is a combination of other samples on the internet and in these forums. The trick is clearly using the System.Windows.Input.Touch.FrameReported event instead of Tapped or anything else; it's the fastest without question. When the user taps on a single "drum" in my sample it works perfectly. However, when the user attempts to tap two at a time (and I mean at the exact same time), there is no event raised. I am testing on a (WP8) Lumia 920.

    First, look at the code:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Style TargetType="Ellipse">
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Top" />
        <Ellipse x:Name="Ellipse1" Fill="Blue" Height="177" Margin="17,17,0,0" Width="177"/>
        <Ellipse x:Name="Ellipse2" Fill="#FFFFA300" Height="223" Margin="212,25,0,0" Width="223"/>
        <Ellipse x:Name="Ellipse3" Fill="#FFFF00E8" Height="97" Margin="89,207,0,0" Width="97"/>
        <Ellipse x:Name="Ellipse4" Fill="#FF00C135" Height="162" Margin="186,249,0,0" Width="162"/>
        <Ellipse x:Name="Ellipse5" Fill="#FF00AEFF" Height="272" Margin="59,416,0,-81" Width="272"/>
        <Ellipse x:Name="Ellipse6" Fill="Red" Height="97" Margin="320,395,0,0" Width="97"/>
        <Ellipse x:Name="Ellipse7" Fill="#FFF3FF00" Height="133" Margin="10,304,0,0" Width="133"/>
    public MainPage()
        // setup sounds
        Ellipse1.Tag = new Uri("Sounds/GVD_snr1.wav", UriKind.Relative);
        Ellipse2.Tag = new Uri("Sounds/GVD_snr2.wav", UriKind.Relative);
        Ellipse3.Tag = new Uri("Sounds/GVD_snr3.wav", UriKind.Relative);
        Ellipse4.Tag = new Uri("Sounds/GVD_snr4.wav", UriKind.Relative);
        Ellipse5.Tag = new Uri("Sounds/GVD_snr5.wav", UriKind.Relative);
        Ellipse6.Tag = new Uri("Sounds/GVD_snr6.wav", UriKind.Relative);
        Ellipse7.Tag = new Uri("Sounds/Gong.wav", UriKind.Relative);
        // respond to touch(es)
        var _Ellipses = new[] { Ellipse1, Ellipse2, Ellipse3, Ellipse4, Ellipse5, Ellipse6, Ellipse7 };
        System.Windows.Input.Touch.FrameReported += async (s, e) =>
            var _Touches =
                from touch in e.GetTouchPoints(null)
                where touch.Action == System.Windows.Input.TouchAction.Down
                let ellipse = touch.TouchDevice.DirectlyOver as Ellipse
                where _Ellipses.Contains(ellipse)
                select ellipse;
            System.Diagnostics.Debug.WriteLine("{0} touch(es).", _Touches.Count());
            foreach (var ellipse in _Touches)
                var _Stream = Application.GetResourceStream(ellipse.Tag as Uri).Stream;
                var _SoundEffect = Microsoft.Xna.Framework.Audio.SoundEffect.FromStream(_Stream);
    Simple enough, huh? There are some occasions where the Debug line actually reads (2) instead of (1). But these only occur when I ever-so-slightly stagger the touches to be not quite simultaneous. Otherwise, it's one and only one occurring - and nothing occurring when two simultaneous taps occur. So, I have a few questions:

    1. Is this even possible?
    2. What's the trick?

    Last edited by Jerry Nixon; 2013-05-29 at 18:00. Reason: Readability

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013

    Re: Is it possible to detect two (or more) simultaneous touches?

    Hmmm i dont know VB much but i'll try...

    Perhaps your elipses are overlapping? their x,y are all the same even though u used margin that just change the visual start of the component but doesnt change its x,y i believe.
    If that doesnt work try using a Canvas object instead of Ellipse
    If that still doesnt work make sure you enable MultiTouchBehavior on your components
    and finally try using ManipulationEvents http://msdn.microsoft.com/en-us/libr...v=vs.105).aspx

    and if all else fails.... in your current method comment out all the code and just print the Count of the touch points like so
    int pointsNumber = e.GetTouchPoints(canvas).Count;

Similar Threads

  1. Getting Kern Exec 3 if touches the screen
    By sunitha.m13 in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2009-10-24, 14:45
  2. [moved] Detecting "multiple" touches on S60 5th Ed
    By walkl in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-12-25, 02:19
  3. PC suite can't detect my 6680 phone althouth PC detect it
    By Elnegm in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2006-12-25, 18:39
  4. Simultaneous Connections
    By vishwas_dot_h in forum Mobile Java General
    Replies: 2
    Last Post: 2005-12-23, 12:02
  5. Simultaneous PDP from PC
    By adamfli in forum PC Suite API and PC Connectivity SDK
    Replies: 3
    Last Post: 2005-11-28, 08:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts