Author Topic: OS independent device/controller which would transparently remap keys?  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

Offline TacticalCoder

  • Thread Starter
  • Posts: 526
I've got a very noobish question for the pros here...

If I hit, say, the 'fn' key on my HHKB Pro 2 by itself, it doesn't generate any keycode that the OS can see. For example under Linux if I launch 'xev' and then hit the 'fn' key, nothing happens. If I press 'fn', then hit ';' then a code corresponding to the left arrow is sent and, AFAIK, the OS has no way to detect that ';' was pressed. For the OS it's as if my keyboard had a real arrow keys cluster. (please correct me if I'm way off here)

Now here comes my question (and the example I'll use is, on purpose, far-fetched, to try to better understand how it all works): can I somehow "add" a device/controller between the keyboard and the computer that would allow to:

- hit the key 's' and have no keycode send to the computer unless I hit another key ?

- press the key 's' and keep it pressed and then hit 'y' and have the code equivalent to hitting the right arrow key send? (without the OS being able to determine that 's' or 'y' were pressed)

If it can be done, does it work with any key (any modifier etc.)? What about the 'fn' key itself, which doesn't send anything unless you hit another key? (not that I'd miss it much)

Basically instead of having to remap all my OSes (say Linux, OpenBSD, OS X, Windows, ...) so that my keyboard(s) behave more or less similarly on all of them, I was wondering if it was possible to do this at a lower level, entirely bypassing the OS?



HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline damorgue

  • Posts: 1176
  • Location: Sweden
    • Personal portfolio
Re: OS independent device/controller which would transparently remap keys?
« Reply #1 on: Wed, 11 December 2013, 09:00:43 »
Hmm, Soarer's converter sort of does a similar thing where the PS/2, AT or XT codes sent to it are interpreted and then sent over USB. There is a table which allows you to make remappings in that conversion. The only difference is that you want USB to USB converter which I haven't seen but which might already be supported.

http://geekhack.org/index.php?topic=17458.0

Edit: I read it more thoroughly, if the fn-code doesn't send anything since it is an internal function, then you won't be able to remap it that way. I think Soarer's converter only does simple conversions from one code to another and that ability to have it wait upon receiving one keycode until another certain one is received is a bit more advanced that what it can currently do. Soarer could probably give a better answer.

Edit2: To get at those internal things of the keyboard, you pretty much have to replace the controller.
« Last Edit: Wed, 11 December 2013, 09:04:38 by damorgue »

Offline TacticalCoder

  • Thread Starter
  • Posts: 526
Re: OS independent device/controller which would transparently remap keys?
« Reply #2 on: Wed, 11 December 2013, 09:04:01 »
Hmm, Soarer's converter sort of does a similar thing where the PS/2, AT or XT codes sent to it are interpreted and then sent over USB. There is a table which allows you to make remappings in that conversion. The only difference is that you want USB to USB converter which I haven't seen but which might already be supported.

Ah I'll go check that... Do you know if I could use a "USB-to-PS/2" and then Soarer's converter to get back to USB?  Does a USB-to-PS/2 converter even exist in that direction?

It's really not a problem if I can't remap the HHKB 'fn' key. As long as I could use the converter to send any keycode, I'd be fine.
« Last Edit: Wed, 11 December 2013, 09:05:39 by TacticalCoder »
HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline damorgue

  • Posts: 1176
  • Location: Sweden
    • Personal portfolio
Re: OS independent device/controller which would transparently remap keys?
« Reply #3 on: Wed, 11 December 2013, 09:06:57 »
I would read his thread and ask him. I see that simple macros are supported where if you press for instance 'a', it can then send a couple of keypresses instead of that 'a'.


Offline spiceBar

  • Posts: 998
    • ChessTiger.com
Re: OS independent device/controller which would transparently remap keys?
« Reply #5 on: Fri, 13 December 2013, 01:40:47 »
I've got a very noobish question for the pros here...

If I hit, say, the 'fn' key on my HHKB Pro 2 by itself, it doesn't generate any keycode that the OS can see. For example under Linux if I launch 'xev' and then hit the 'fn' key, nothing happens. If I press 'fn', then hit ';' then a code corresponding to the left arrow is sent and, AFAIK, the OS has no way to detect that ';' was pressed. For the OS it's as if my keyboard had a real arrow keys cluster. (please correct me if I'm way off here)

Now here comes my question (and the example I'll use is, on purpose, far-fetched, to try to better understand how it all works): can I somehow "add" a device/controller between the keyboard and the computer that would allow to:

- hit the key 's' and have no keycode send to the computer unless I hit another key ?

- press the key 's' and keep it pressed and then hit 'y' and have the code equivalent to hitting the right arrow key send? (without the OS being able to determine that 's' or 'y' were pressed)

If it can be done, does it work with any key (any modifier etc.)? What about the 'fn' key itself, which doesn't send anything unless you hit another key? (not that I'd miss it much)

Basically instead of having to remap all my OSes (say Linux, OpenBSD, OS X, Windows, ...) so that my keyboard(s) behave more or less similarly on all of them, I was wondering if it was possible to do this at a lower level, entirely bypassing the OS?

Yes it is possible. This problem has already been solved brilliantly by Hasu.

He has designed several masterpieces:

1. An alternate controller for the HHKB. It replaces the controller inside the HHKB, which is on a small PCB that is separate from the PCB that supports the keys. The controller allows to remap any key, including Fn, and to define dual role modifiers. I am typing this post on an HHKB with said controller, and it implements the SpaceFN layout perfectly. But you could program it to do anything.

2. A converter that plugs between a keyboard and a PC (or Mac). The converter takes the incoming key presses/releases sent by the keyboard and converts them to do anything you want. I also have this converter, which is currently programmed to convert a standard keyboard into a SpaceFN keyboard. I use it with a Poker. The only limitation is that your keyboard must be PS/2 compatible. That is, if it's a USB keyboard, it must work when plugged to the PS/2 plug of a PC (thru the classical passive USB to PS/2 adapter).

3. A controller for the GH60 keyboard that allows to program any layout. That includes dual-role modifiers.

As far as I know, he has designed both the hardware and software (firmware) for all of these. The firmware, which is essentially the same for the 3 devices above, is called "TMK".

If you have an HHKB, you need #1. You will lose the USB hub, but I have been told that it is almost completely useless anyway.

If you have other standard keyboards (or TKL or even 60%), you need #2.

I do not know if Hasu wants to sell more of these adapters and controllers. You will need to ask him.

I do know that they work really well and that they are like little treasures in my keyboards collection.