How to specifically detect a touch screen in Windows 8?


  • I am developing an app that needs to detect whether or not a touch screen is present. I am using the following code which works for the most part:

    TouchCapabilities^ tc = ref new TouchCapabilities();
    return tc->TouchPresent;

    The problem is that I have a laptop where this is returning true for the touchpad, there is no touch screen. I have tried to detect whether there is a touch screen present with the following code, but it never breaks inside the touch screen section. I admit I am not very confident in my understanding of HID.

    Windows::Foundation::Collections::IVectorView<PointerDevice^>^ devices = Windows::Devices::Input::PointerDevice::GetPointerDevices();
    for (int i = 0; i < devices->Size; ++i)
        PointerDevice^ pd = devices->GetAt(i);
        PointerDeviceType pdt = pd->PointerDeviceType;
        unsigned int contacts = pd->MaxContacts;
        bool integrated = pd->IsIntegrated;
        for (int j = 0; j < pd->SupportedUsages->Size; ++j)
            PointerDeviceUsage pdu = pd->SupportedUsages->GetAt(j);
            unsigned int usagePage = pdu.UsagePage;
            if (usagePage == 0x0D) // 0x0D is the Digitizer HID Usage Page
                unsigned int usage = pdu.Usage;
                if (pdu.Usage == 0x04) // 0x04 is the Touch Screen HID Usage ID
                     // Should be touch screen but never goes in here

    Is there a way to specificlly detect a touch screen? If so is it possible to see some example code?

    • Edited by Christian LG Monday, October 22, 2012 4:19 AM Formatting changes
    Monday, October 22, 2012 4:18 AM


  • It turns out whenever the simulator is open, TouchPresent will always return true. On one machine the simulator wasn't open but we still experienced the issue, opening and closing the simulator fixed this.
    • Edited by Christian LG Monday, October 22, 2012 5:28 AM
    • Marked as answer by Christian LG Monday, October 22, 2012 5:29 AM
    Monday, October 22, 2012 5:28 AM