locked
Not able to connect to HID device

    Question

  • Hi!

    I am trying to connect to my HID touch device using windows store app I am trying to develop.

    When I call await HidDevice.FromIdAsync(id, FileAccessMode.Read) it returns null.

    My device is touch digitizer so I am using Usage page 0d and usage id 04 in AppManifest.xml.

    Can someone help me debugging this issue?

    Is there way to figure out usage page and usage id for your device?

    Thanks,

    Prtaibha

    Thursday, June 19, 2014 11:53 PM

Answers

  • Hi Pratibha,

    Thanks for your clarify. I may consider that might be the limitation of the Windows Store App if you read the documentation: Devices. You can see the limitation of the HID API. And I'm not sure if your device is in list.

    However if you need a sample app for Winform, I would again suggest you to post question at WinForm forum for a better support(http://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms). This is Windows Store App Dev forum, hardly to solve some WinForm questions. Thanks for your understanding.

    --James

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, July 1, 2014 2:25 AM
    Moderator

All replies

  • Hi Prtaibha,

    "My device is touch digitizer so I am using Usage page 0d and usage id 04 in AppManifest.xml."

    ->Not quite sure if this is the correct way, but per documentation Quickstart: HID, you can use following code to select device:

            private async void EnumerateHidDevices()
            {
                UInt32 vendorId = 0x045E;
                UInt32 productId = 0x078F;
                UInt32 usagePage = 0xFF00;
                UInt32 usageId = 0x0001;
    
                // Create a selector that gets a HID device using VID/PID and a 
                // VendorDefined usage
                string selector = HidDevice.GetDeviceSelector(usagePage, usageId, 
                                  vendorId, productId);
    
                // Enumerate devices using the selector
                var devices = await DeviceInformation.FindAllAsync(selector);
    
                if (devices.Count > 0)
                {
                    // Open the target HID device
                    HidDevice device = await HidDevice.FromIdAsync(devices.ElementAt(0).Id, 
                                       FileAccessMode.ReadWrite);
    
                    // At this point the device is available to communicate with
                    // So we can send/receive HID reports from it or 
                    // query it for control descriptions
                }
                else
                {
                    // There were no HID devices that met the selector criteria
                    this.NotifyUser("MUTT HID device not found");
                }
            }

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, June 20, 2014 5:30 AM
    Moderator
  • Hi Jamles,

    Thanks a lot for the reply.

    I tried your suggestion, it identifies my device in the collection with ID:

    \\?\HID#VID_06CB&PID_1D4D&Col04#7&25b4360a&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}

    but

    HidDevice.FromIdAsync still returns null.

    My code snapshot is:

    {

               

    try


    {

                

    HidDevicedevice;

                   

    MainPage.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>

                    {                   

    //device = await HidDevice.FromIdAsync(id, FileAccessMode.Read);

                     

    ushortvendorId = 0x06Cb;

                       

    ushortproductId = 0x1d4d;

                       

    ushortusagePage = 0xFF00;

                       

    ushortusageId = 0x0001;

    stringselector = HidDevice.GetDeviceSelector(usagePage, usageId,

                                  vendorId, productId);

               

    // Enumerate devices using the selector


               

    DeviceInformationCollectiondevices = awaitDeviceInformation.FindAllAsync(selector);

               

    if(devices.Count > 0)

                {

                   

    // Open the target HID device


                    device =

    awaitHidDevice.FromIdAsync(devices[0].Id,

                                      

    FileAccessMode.Read);



    Friday, June 20, 2014 9:55 PM
  • I am totally new to HID device app.

    Does the HID device app has to be a store app?

    Can anyone suggest some simple winform app to connect to HID device?

    Thanks,

    Pratibha

    Friday, June 20, 2014 11:05 PM
  • Hi Pratibha,

    I think we both made a mistake somehow, I read the documentation again, and there is a word:

    The target device for several of these examples is the SuperMUTT, a test device which you can order from JJG Technologies.

    it means the vendorId, productId in the code snippet only work with SuperMUTT device. I think you have to find out what is your own device vendorId and productId.

    Does the HID device app has to be a store app?

    -> No, you don't have to, store app is one of the choice.

    Can anyone suggest some simple winform app to connect to HID device?

    -> For WinForm App I believe you could find answer at WinForm forum(http://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms).

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, June 23, 2014 2:06 AM
    Moderator
  • Hi James,

    Thanks for the reply.

    But as you can see in my code snippet, I am using VID and PID for my own device.

    Also, can someone please share the link to the specific winform sample app for HID? Because, I tried to do it myself, but it doesn't give me an option to add reference to Windows library which has APIs for HID.

    Thanks,

    Pratibha

    Tuesday, June 24, 2014 5:30 PM
  • Hi Pratibha,

    Thanks for your clarify. I may consider that might be the limitation of the Windows Store App if you read the documentation: Devices. You can see the limitation of the HID API. And I'm not sure if your device is in list.

    However if you need a sample app for Winform, I would again suggest you to post question at WinForm forum for a better support(http://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms). This is Windows Store App Dev forum, hardly to solve some WinForm questions. Thanks for your understanding.

    --James

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, July 1, 2014 2:25 AM
    Moderator