locked
GestureRecognizer not working

    Question

  • m_gestureRec = ref new Windows::UI::Input::GestureRecognizer();
    
    	GameManager::m_inputManager->m_PointerPressed += ref new InputManager::PointerPressedDelegate([=](Windows::UI::Core::PointerEventArgs^ args)
    	{
    		m_gestureRec->ProcessDownEvent(args->CurrentPoint);
    		//m_zoom += 0.01f;
    	});
    
    	m_gestureRec->GestureSettings =
    		Windows::UI::Input::GestureSettings::Tap;
    	m_gestureRec->Tapped += ref new TypedEventHandler<GestureRecognizer^, TappedEventArgs^>
    	([=](GestureRecognizer^ r, TappedEventArgs^ e)
    	{
    		m_zoom += 1;
    	});

    I'm creating a DirectX, Windows 8 game and I need to detect gestures. Unfortunately, my GestureRecognizer isn't working. I've put a breakpoint in the handler but, it doesn't ever hit.  I know that the pointer pressed event works, I have a breakpoint there and it's constantly hit.

    Any help, thanks. 


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Wednesday, February 06, 2013 3:44 AM

All replies

  • Are you passing all of the Pointer events or just the ProcessDownEvent as listed in your code snippet? If not, please do. If so, can you please post a complete code snippet of the pointer and gesture handling?

    --Rob

    Wednesday, February 06, 2013 7:57 AM
    Owner
  • Well, I'm just doing a tap on the screen, for testing purposes. My actual final gesture will be rotation, but I can't get either working. I can code them all, but it seems a little odd that I would have to code all gestures just for any of the gestures to work.

    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Wednesday, February 06, 2013 1:32 PM
  • Okay, I think I may have found out the problem. I have to call Dispatcher->ProcessEvents(). Here's my problem, I'm using a SwapChainBackgroundPanel for the app. This way, I can have XAML and DirectX.

    But, when I call the ProcessEvents() method, I get an error.

    Here's the code.

    SwapChainPanel->Dispatcher->ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessAllIfPresent); 

    Here's the error.

    Unhandled exception at 0x648762E9 (Windows.UI.Xaml.dll) in SpritePlay.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x081A92C0, 0x00000001).


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Thursday, February 07, 2013 8:41 PM
  • You don't need to code all gestures, but you should plumb all of the pointer events through.

    Taps trigger when the pointer is released, so if you eat that event you won't get a Tap.

    --Rob

    • Proposed as answer by Jesse Jiang Monday, February 11, 2013 2:44 AM
    Saturday, February 09, 2013 7:29 AM
    Owner
  • Well, I'm just using tap as an example. I'm really after getting the rotate gesture working. And with the above code (for rotate), it doesn't work.

    Thanks.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Monday, February 11, 2013 3:08 AM
  • When you say "above code" do you mean the pasted in code with just PointerPressed and not move or release? Rotate will definitely need those.

    If not, can you provide enough code that we can try to replicate what you are doing to reproduce the problem? If you can upload a minimal project that demonstrates the problem to your SkyDrive that would be ideal.

    Also take a look at the Input: Manipulations and gestures (C++) sample which demonstrates using the GestureRecognizer in a Direct3D app to see if you can tell what you are doing differently from it.

    --Rob

    Monday, February 11, 2013 4:21 AM
    Owner
  • Well, I've seen the gestures sample multiple times. I've even downloaded it trying to see any relevant differences. The only thing I could see was the dispatcher->processEvents. But, trying to call that method from a XAML + Direct3D mixed app caused an error.

    At first I had the Move event hooked up with the gesture recognizer, but in order to debug it, I switched to tap, and tap doesn't work.

    PM me your Email address and I'll send you a SkyDrive link to the application.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Monday, February 11, 2013 5:00 AM
  • Please post your minimal repro sample to a public SkyDrive so that others in the community can help as well.

    If you need individual support then please create a case at http://getsupport.microsoft.com and we would be happy to help you privately.

    --Rob

    Tuesday, February 12, 2013 12:04 AM
    Owner
  • I'm trying to create a game through DirectX with XAML on top. I also need gesture recognizers in this game. My problem seems to be when I call Dispatcher->ProcessEvents() in this typed of app, I end up with an exception saying that an internal error has occurred. If I don't call Dispatcher->ProcessEvents(), then the gesture recognizer won't fire it's events.

    Thanks.


    [url=http://catalog.create.msdn.com/en-US/GameDetails.aspx?catalogEntryId=5cbacba6-05c2-4c33-9005-6cc80c8d5753&type=1]Bible Trivia Avatar Edition[/url], currently in review.

    Thursday, February 14, 2013 2:52 PM