locked
Disable palm rejection in Windows Store app?

    Question

  • Following this tutorial http://msdn.microsoft.com/en-us/library/windows/apps/hh465086.aspx, I tried to build a simple Windows Store application that accepts simultaneous pen and touch input. Touch events do not seem to register, however, when the pen is in the hover state above the display. I believe this is due to the operating system's standard "palm rejection" feature, meant to ignore palms rested on the display while the pen is writing.

     

    This example http://msdn.microsoft.com/en-us/library/windows/desktop/dd940546(v=vs.85).aspx seems to indicate it is possible to disable palm rejection in a Windows desktop application with the following code:

    // Registering the window for multi-touch, using the default settings.
    // p/invoking into user32.dll
    if (!RegisterTouchWindow(this.Handle, 0))
    {
        Debug.Print("ERROR: Could not register window for multi-touch");
    }

    I have been unable to adapt this to my Windows Store app, because I don't know if/where I can retrieve the window handle object. Is it possible to do this in a Windows Store app? If not, is there another technique for disabling palm rejection in Windows Store applications?

    Thanks,

    Ben

    Sunday, December 02, 2012 6:40 AM

Answers

  • Hi realisty,

    Yes and no. The workaround I found works in WPF and Forms applications, not Store apps as far as I know. The crutch of the problem is acquiring a window handle to the Store app window, which appears to be impossible, if this is to be believed:

    http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/fdc14663-4ab8-484b-aae5-4639e0699624

    On my Windows 8 device at least, the registerTouchWindow call did not work, even for WPF and Forms apps where acquiring an HWND is no problem. I found, however, that the raw touch data could be obtained through the Raw Input API:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms645543(v=vs.85).aspx

    After a lot of parsing, I was able to pass the raw data back to my application as standard touch events. This, however, involved reverse-engineering the contents of the raw touch data packets, for which I could not find an open source driver that corresponded to my device, as recommended in this codeproject article:

    http://www.codeproject.com/Articles/381673/Using-the-RawInput-API-to-Process-MultiTouch-Digit

    It was not an easy route, but it worked for me. Good luck!

    Ben

    • Marked as answer by Ben McCanny Wednesday, January 30, 2013 1:53 AM
    Wednesday, January 30, 2013 1:51 AM

All replies

  • I also want to know how to to this. Did you find a solution, Ben?
    Tuesday, January 29, 2013 2:05 PM
  • Hi realisty,

    Yes and no. The workaround I found works in WPF and Forms applications, not Store apps as far as I know. The crutch of the problem is acquiring a window handle to the Store app window, which appears to be impossible, if this is to be believed:

    http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/fdc14663-4ab8-484b-aae5-4639e0699624

    On my Windows 8 device at least, the registerTouchWindow call did not work, even for WPF and Forms apps where acquiring an HWND is no problem. I found, however, that the raw touch data could be obtained through the Raw Input API:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms645543(v=vs.85).aspx

    After a lot of parsing, I was able to pass the raw data back to my application as standard touch events. This, however, involved reverse-engineering the contents of the raw touch data packets, for which I could not find an open source driver that corresponded to my device, as recommended in this codeproject article:

    http://www.codeproject.com/Articles/381673/Using-the-RawInput-API-to-Process-MultiTouch-Digit

    It was not an easy route, but it worked for me. Good luck!

    Ben

    • Marked as answer by Ben McCanny Wednesday, January 30, 2013 1:53 AM
    Wednesday, January 30, 2013 1:51 AM
  • It works gracefully! I just used Win32 and RawInput API worked well.

    Thanks.

    Saturday, February 02, 2013 7:20 PM