Hardware USB keyboard layout switch (f.e. Qwerty<->Dvorak)

Hi! I think about to build a USB keyboard layout switch in hardware with arduino, so that i can connect my device to computer, a USB keyboard to the device and switch layouts in hardware and make other things, like macros (f.e. pressing CTRL+ALT+ types predifined text). I think about to use the following components:

http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini/
http://www.ebay.com/itm/HT82K629A-HT82K629-USB-PS-2-Keyboard-Encoder-IC-/320486016437

Is it possible? What could be a problem?

Best regards,
Oleksandr

blengon:
Is it possible? What could be a problem?

Sounds quite possible, however you don't need a keyboard encoder (which is going to be very difficult to interface) if instead you use a Pro Micro (Leonardo variant) which can implement a HID class in itself. This may still fit the "Mini" USB host shield (haven't looked at the connections).

Paul__B:
Sounds quite possible, however you don't need a keyboard encoder (which is going to be very difficult to interface) if instead you use a Pro Micro (Leonardo variant) which can implement a HID class in itself. This may still fit the "Mini" USB host shield (haven't looked at the connections).

I do not think, that the Mini USB host shield fits to the Pro Micro, but it is nothing what could not be solved with several short cables :slight_smile:

But with the keyboard encoder: why it is difficult to interface, what could be the problem here? To my mind, it is maybe easier to interface the keyboard encoder then to solve the USB problems by hand ... but I could be wrong :roll_eyes:

A problem can be the number of pins, I need at least 30-35 pins, it can be solved maybe with a shift register ...

And another question, does it exists a good USB HOST shield for Arduino Micro directly?

blengon:
Hi! I think about to build a USB keyboard layout switch in hardware with arduino, so that i can connect my device to computer, a USB keyboard to the device and switch layouts in hardware and make other things, like macros (f.e. pressing CTRL+ALT+ types predifined text).

What operating system are you using on the PC side? These features all seem like things that could be achieved within the PC without needing any custom keyboard hardware.

PeterH:
What operating system are you using on the PC side? These features all seem like things that could be achieved within the PC without needing any custom keyboard hardware.

I will connect the keyboard not to a real PC, but to different hardware, which have USB keyboard support but have typically no possibility to change the layout and if possibility is there (which is rare), than it have definitly no support for Dvorak/Colemak and similar. And I want to use the keyboard, which is already there and do not want to take a modified keyboard with me, but only a small adapter. They are already some keyboards which do what i want pretty well, for example http://tinyurl.com/p23h7hr but again, I do not want to take the big and havy keyboard with me every time and this keyboard is to expensive to by 10 of them.

Paul__B:
Sounds quite possible, however you don't need a keyboard encoder (which is going to be very difficult to interface) if instead you use a Pro Micro (Leonardo variant) which can implement a HID class in itself. This may still fit the "Mini" USB host shield (haven't looked at the connections).

I think i will try with this two: http://tinyurl.com/lh5eeyq and http://tinyurl.com/l3ky8uf :slight_smile:

blengon:
I think I will try with this two: http://tinyurl.com/lh5eeyq and http://tinyurl.com/l3ky8uf :slight_smile:

So you have checked that the connections match? I have not looked into that so far - I have both Pro Minis and Nanos but have had some trouble with the Nanos so have avoided them for the present.

blengon:
I do not think, that the Mini USB host shield fits to the Pro Micro, but it is nothing what could not be solved with several short cables

Quite so.

blengon:
But with the keyboard encoder: why it is difficult to interface, what could be the problem here? To my mind, it is maybe easier to interface the keyboard encoder then to solve the USB problems by hand ... but I could be wrong

The problem is that keyboard encoders are multiplexed - they activate one set of lines one after another and read another set of lines to see which crosspoints come up. To interface with such an arrangement you would have to determine which multiplex was active at any instant and provide a matching signal to correspond to the "virtual" keypress. That turns out to be extremely difficult to do. And a PC keyboard is at least a 10 by 12 grid - 22 lines - which explains why the chip you originally cited has so many legs.

Paul__B:

blengon:
I think I will try with this two: http://tinyurl.com/lh5eeyq and http://tinyurl.com/l3ky8uf :slight_smile:

So you have checked that the connections match? I have not looked into that so far - I have both Pro Minis and Nanos but have had some trouble with the Nanos so have avoided them for the present.

I have checked the description, and it looks like it can work, I have ordered it, as soon it is here, I will try to connect them and write here what I get :wink:

Paul__B:

blengon:
But with the keyboard encoder: why it is difficult to interface, what could be the problem here? To my mind, it is maybe easier to interface the keyboard encoder then to solve the USB problems by hand ... but I could be wrong

The problem is that keyboard encoders are multiplexed - they activate one set of lines one after another and read another set of lines to see which crosspoints come up. To interface with such an arrangement you would have to determine which multiplex was active at any instant and provide a matching signal to correspond to the "virtual" keypress. That turns out to be extremely difficult to do. And a PC keyboard is at least a 10 by 12 grid - 22 lines - which explains why the chip you originally cited has so many legs.

I have understood it too and decided against the encoder, the direct combination of Pro Micro and USB Host Mini is also much more compact as to have 3 or more chips!

blengon:
I will connect the keyboard not to a real PC, but to different hardware, which have USB keyboard support but have typically no possibility to change the layout and if possibility is there (which is rare), than it have definitly no support for Dvorak/Colemak and similar

I guess I don't understand what you really want to achieve, then. Are you also going to relabel the keys when you switch the keyboard between different layouts? If you only translate the scancodes and leave the original key labels in place, I would have thought that would be extremely confusing.

PeterH:
I guess I don't understand what you really want to achieve, then. Are you also going to relabel the keys when you switch the keyboard between different layouts? If you only translate the scancodes and leave the original key labels in place, I would have thought that would be extremely confusing.

The labels on the keys have no meaning for me, because I never look to them. But using a keyboard I would like to expect the English-Dvorak layout, because the switching between Qwerty and Dvorak is confusing. So only translate the scancodes is absolutely enough, it is also usual, because most keyboards I use have other labels as configured layouts, f.e. mostly they are english and sometimes also russian layout but with german labels, because here in germany it is difficult to find a english or russian labeled keyboard :slight_smile:

OK, that makes sense and as far as I can see it should be possible to achieve using the Pro Micro and USB host shield that you linked to. You will need to provide a mapping between the input and output scan codes - or perhaps multiple mappings selected by a switch, if you want to be able to select the layout in the fly. You will probably want to keep that mapping in program memory using the PROGMEM modifier.