Page 1 of 1

USBComposite and keymapping

Posted: Tue Oct 25, 2022 6:34 pm
by Phil242
Hi,

USBComposite is working like a charm to simulate a keyboard.

But, how to deal with key-mapping ?
On my test machine I have a french keyboard (AZERTY) and a "Keyboard.press('a');" give a "q".

Is there a way to deal with this problem ?

Cheers,

Phil

Re: USBComposite and keymapping

Posted: Tue Dec 27, 2022 3:10 pm
by arpruss
Background: https://stackoverflow.com/questions/393 ... d-keyboard

I guess you'll need to generate a map for the locale. I don't think there is a general solution on the stm side.

Re: USBComposite and keymapping

Posted: Tue Dec 27, 2022 4:19 pm
by Phil242
Hi Arpruss,

Thanks for the pointer.

As the project was for an event mid November, I've found a quick & dirt solution: I have map myself an AZERTY keyboard over the QWERTY template I've found. Just modify the output code with a translate table.
The major issue was the need of the key "Alt Gr" to obtain the specific chars related to this combo key. If someone have to do a similar job, have a look at the "modifiers". So the table is a char translation plus optionally the Alt Gr or Shift pressed and released.

It's so ugly, I can't show this mess ... But it worked as expected.
It's a shame I can't commit it, but as I'm not an expert of those HID devices, my patch will not be useful to someone aware of how it really works.

Cheers,

Phil

Re: USBComposite and keymapping

Posted: Thu Feb 02, 2023 6:45 am
by celinedion
arpruss wrote: Tue Dec 27, 2022 3:10 pm Background: https://stackoverflow.com/questions/393 ... d-keyboard

I guess you'll need to generate a map for the locale. I don't think there is a general solution on the stm side.
I had a similar problem. I will try it. Thank you!