USBFS - Creating a HID Keyboard that uses more than 101 keys?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KyTr_1955226
Level 6
Level 6
250 sign-ins 10 likes given 50 solutions authored

Hi all,

I have a question about my USB HID Keyboard I'm running off a PSoC5LP [CY8C5468AXI-LP106].

End goal is I want to have the keyboard support keys beyond the standard 101.  From a code perspective this is no problem, just load the keycode I want into the Endpoint and send it out to the host, but where I'm running into hang-ups is figuring out if my HID Descriptor is appropriate for what I'm trying to do.  My current descriptor is as follows (based off the standard Keyboard w/ LEDs descriptor provided with PSoC Creator):

pastedImage_0.png

Now when I look at this, the values that stand out are:

LOGICAL_MINIMUM(0)        15 00

LOGICAL_MAXIMUM(101)   25 65

and

USAGE_MINIMUM(0)           19 00

USAGE_MAXIMUM(101)      29 65

My thought was I could just change these  values, and that would tell the OS to expect key codes from this device beyond the standard 101, letting me use codes for keys like F13 - F24 and other various HID Keyboard codes >0x65:

LOGICAL_MINIMUM(0)        15 00

LOGICAL_MAXIMUM(221)   25 DD 00

and

USAGE_MINIMUM(0)           19 00

USAGE_MAXIMUM(221)      29 DD 00

This leaves me with:

pastedImage_1.png

Unfortunately this change doesn't seem to do anything on the Host PC Side (Windows 7 x64).  The OS still does not appear to process any codes beyond 0x65.  I'm unsure as to where the problem lies, in my Windows Host PC, or if I'm not setting up the Descriptor correctly.

Would anyone with some USB HID chops be able to shed a little light on the subject (or at least tell me if the descriptor is OK)?

Thanks in advance for the help!

0 Likes
1 Solution

You can verify the USB descriptors with the project at this link.it may be useful:

GitHub - MinatsuT/PSoC5_USB_Keyboard: PSoC5 USB HID Keyboard

View solution in original post

7 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

I think this link from Microsoft describes about the phenomenon observed by you:

https://support.microsoft.com/en-in/help/927824/windows-may-not-use-the-correct-keyboard-layout-when...

Interesting link, thanks.

I wonder why it never came up in the googling I've done on this in the past week trying to figure out how Windows handles Keyboards.

This looks like it could give me support for some extra keys/layouts, like Japanese 106/109 key layout in the example, but doesn't seem to cover what I'm looking to do: have the ability for the OS recognize any arbitrary code between 0x66 and 0xDD on an English layout.  I wonder if there's an english layout out there I could assign that would support, say F13-F24 (0x68-0x73).  I'll have to do some digging.

It's looking like the only way to do this may be to have a custom driver?  Which is strange to me since I thought the entire point of the HID spec was that this could all just work without additional configuration.  Using these F13-F24 keycodes is actually a customer requirement, so I wonder if perhaps they've already got a driver for it and I just haven't been privy to that information...

Should the USB Descriptor I posted be OK on the microcontroller end?  From what I can determine it should be doing it's job in letting the OS know those key codes can come from they keyboard, even if the OS/driver doesn't account for them, from a HID compliance standpoint that descriptor is OK?

Thanks for the lead, this is more info than I had yesterday.

0 Likes

KTrenholm,

I'm not an expert in this discussion but here goes:

There are non-english keyboards available such as the Japanese Katakana keyboards and I believe the Chinese have keyboards to support may of their symbols.  These keyboard goes beyond the standard 101 keys and must have support with a USB HID.  How do they do it?  If you can figure it out, you're probably half-way there.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Len,

You're right, I could probably get at a couple of these codes by having the OS (Windows) use a different layout such as Japanese/106 or similar.  But if I switch the layout for this keyboard to something like Japanese/106 then I'm suddenly typing in Katakana.  I want a standard 101 key US layout, the only difference is I have some extra buttons on the PSoC that I want to use as F13-F24 keys.  Keys I know will not be duplicated on the 101-US keyboard.  I can send the HID codes for these keys just fine, but the OS will not recognize any key is being pressed because they are not included in a standard 101 key US layout, so I'm guessing that Windows is filtering them out as "not real codes".

I was hoping setting up the descriptor to tell the USB host that they keycodes can range between 0x00 and 0xDD would nudge the host into accepting these keys but it seems that is not the case.

I don't think it's an issue with the HID interface.  HID Protocol specifies the codes (see page 53 here).  I think it's probably an issue with getting the host OS to accept these codes as "real keys".  F13, F14, and F15 are actually accepted on mac systems according to the document I linked above, as well as a number of additional keys.  I'd bet that if I plugged into a mac, F13,F14, and F15 would suddenly work.  I just can't seem to figure out how to get windows to cooperate.

Currently looking into creating a custom layout using Microsoft Keyboard Layout Creator.  Maybe it'll let me do what I need to do, but it's blocked by the group policy on my machine for some reason.  I'll check back in if I manage to get it installed and can mess around with it.

0 Likes

No luck with Microsoft Keyboard Layout Creator.  Looks like it only lets you edit the main block of keys and nothing else, so I can't do something like add additional "valid" keys.  Back to the drawing board I suppose.

This has kind of gotten off track from being a PSoC question, so getting slightly back on topic, can anyone tell me if my descriptor is OK?  I'd like to confirm that the issues I'm having are on the host side rather than the PSoC side.

0 Likes

You can verify the USB descriptors with the project at this link.it may be useful:

GitHub - MinatsuT/PSoC5_USB_Keyboard: PSoC5 USB HID Keyboard

Thanks, that is quite helpful, if even to just have a nice commented reference for a HID keyboard descriptor (also, I didn't notice you could have comments in a descriptor.  I will be sure to make use of that in the future)

The descriptor in that project calls out key codes (USAGE MIN/MAX and LOGICAL MIN/MAX) 0-255, whereas mine calls out 0-221, but they generally look the similar aside from the example not having Keyboard LEDs.  This is more and more pushing me to thinking that it's an issue with the host, and for Windows at least, a custom driver may be needed (although I haven't gotten a 100% crystal clear answer on if that's true).  I would hope, since our customer specifically asked for these HID codes, that they have a host that supports them.

I made a StackOverflow question regarding properly handing of these code in a C# .NET Winforms application if anyone is having a similar issue and wants to keep an eye on it.  Figured it belonged more there than here since it's not really a PSoC related issue.

Thanks again!

0 Likes