USBX Host HID Keyboard Issues

I am working on project with an external USB Keyboard and am using the USBX Host Class HID framework and am having an couple of issues. 

1) Using ux_host_class_hid_keyboard_key_get() to get the keyboard events, I do not get the correct value for the LEFT arrow key press.  It returns 205 decimal which is the value for the RIGHT arrow.  Using the keypad (with num lock off) I get the correct values of 203 and 205 for the LEFT and RIGHT keypad arrows.

2) The second issue I am having is this:

2a) First key is pressed and held.  I get the correct key press event.

2b) Second key is pressed and released.  I get the first key event then the second key event then the first key event again.  I assume there must be a way to mask this behavior so I can blank keys that have not been released or determine if it is being held etc.  Looking through the USBX host docs I was not able to located any info.


I am using SSP 1.4.0 and E2 6.3.0.

I tried adding the USBX Host Class HID source to debug, but the ux_host_class_hid_keyboard_key_get() function is still hidden and I cannot view it.  Any help or insight would be appreciated.  Thank you.

  • Hi Jamie-
    What source are you using to find the values you expect for the keys? Are you looking at a standards doc? Does it define the key values differently if num lock is on or off?

    On the key held issue- in 2b it looks like you need to check for both press key and release key events. If a release key event hasn't been received, you could mask off any additional press key events from that key. Is that a possibility?

  • Hi Warren - Thanks for your reply.

    I am using the USBX HID Host function ux_host_class_hid_keyboard_key_get() to retrieve the key events. This function populates both a key event and keyboard status. I used the USBX Host Class HID Module R11AN0236EU0100 as a guide for implementing this in my application.

    I can't find any documentation the specifies expected return values for ux_host_class_hid_keyboard_key_get(), and I can't find any reference to press and release events. Perhaps I am missing something because implementing per your suggestion makes sense, but I don't see how the USBX framework provides access to that info.
  • Hi Jaime,

    We have a bug in the key mapping array we use to return characters from that API. This is what that array looks like:

    /* Define USB HID keyboard mapping tables. */

    UCHAR ux_host_class_hid_keyboard_regular_array[] =
    'a','b','c','d','e','f','g','h','i','j', 'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',

    This array is defined in an encrypted source file so you can fix it there, but it is not statically defined so you can just fix the array in your program before you ever get a key. To do this you should add these lines to some place soon after main:

    extern UCHAR ux_host_class_hid_keyboard_regular_array[];

    ux_host_class_hid_keyboard_regular_array[80] = 203;

    In the next version of the SSP there is a way that you can access and define this array in source code so that you can define your own key mapping without having to poke values into the array.

    On your desire to add key-up events, there is a lower level API that you can call into to see these and all events on the keyboard, however they are difficult to use and not very well documented. In the near future we plan to augment the HID host module guide example by calling into this lower level API so that these types of events are visible.
  • Hi Dale -

    The array modification worked to correct the left arrow functionality - thank you!

    Any information you can provide about the lower level API would be very appreciated. As it stands, the HID Keyboard functionality is unacceptable for our application.
  • Hi Dale -

    Checking in again to see if you can provide any more information or example for using the lower level HID API you referenced in your previous post? Thank you.
  • Hi Dale -

    Just pinging you again to see if you have any updates on this example you could provide? Thank you.
  • Hi Jamie,

    Sorry for the late reply.

    I took another look at the existing Host HID keyboard class implementation to see if there is a way to get you key up events but was unsuccessful. Even if the HID keyboard class did have some way to get to the raw report it throws away these events after it parses out the keys. Right now the only way to do this is to write your own Host HID keyboard class on top of the USBX Host HID stack. This would be a rather significant undertaking unless you have a source license for the class.

    In your original post you stated that you are unable to view these encrypted source files. To do this you will need to use a production and development license which you can get from the Gallery.


  • Hey Dale, I have the same issue. Any progress on the class driver? Bill
  • Bill

    Dale is no longer with the company. Anyway, it sounds like this is something that Dale expected the customer to develop on their own.