Custom Hardware USB Keyboard [T1] - Toggle between two specific layouts using a special key

vikas

06 Feb 2019, 06:39

Hello All,

In the new custom keyboard I am designing I have a special key which I have named as SS (Script Switching) Key.

I have used one of the 'reserved for OEMs' scan code in the keyboard buffer, generated from the keyboard firmware. If required, I can also map it to 1 of the 8 bits of the 1 Reserved Byte in the Report Buffer,.

Anyway, I want to use this SS Key to toggle between two layouts (DLLs) on key-up event (not on key-down).

i.e. Assuming current selected layout is Layout1, if we then Press and release the SS Key once --> Switch the script to Layout2.
Press and release this key again --> then switch the script back to Layout1.

I want to discuss if this is possible or not?
If yes, How?
If not, why?

I found a link that may suggest something like this

https://www.usb.org/sites/default/files ... ctor_0.pdf

Your help and advice is very important for me to go forward.

Thanks heaps,

Vikas

User avatar
purdobol

06 Feb 2019, 09:02

Ok couple questions.
If this is custom keyboard, what firmware are you using?
If you're looking for software solution. What OS are you using?

Theoretically it should be possible (at least on Linux machine).
Script would look something like this:
1. release code detected -> change env variable (from 0 to 1 for example) -> if env variable = 1 change layout to x
2. release code detected -> change env variable (from 1 back to 0) -> if env variable = 0 change layout to y

Custom firmware supports toggling layouts. Although not sure if possible on key release. But it'll be easier that way.

Out of curiosity, why toggling layouts on key release specifically?

User avatar
Muirium
µ

06 Feb 2019, 10:27

Layouts are something we already support in every community made firmware out there. We call them layers.

A layer is a completely independent remap, so you can do big things like throw Colemak or Dvorak on there without messing up the Qwerty default.

Triggering them can be done many different ways, from a simple “activate while this key is held” to a selected mode like you’ve described.

The beauty of doing this logic *inside* the keyboard is it’ll work on any host, with no configuration required. Really handy for limited systems like the iPad! It becomes a feature of the keyboard, not your specific environment.

Anyway, if you’re interested, check TMK. It even has a nice visual editor for the code averse like me:

Image
It’s open source so you can dig down into its guts if you prefer. Excellent platform for so many keyboard projects.

vikas

06 Feb 2019, 15:00

purdobol wrote:
06 Feb 2019, 09:02
Ok couple questions.
If this is custom keyboard, what firmware are you using?
If you're looking for software solution. What OS are you using?

Theoretically it should be possible (at least on Linux machine).
Script would look something like this:
1. release code detected -> change env variable (from 0 to 1 for example) -> if env variable = 1 change layout to x
2. release code detected -> change env variable (from 1 back to 0) -> if env variable = 0 change layout to y

Custom firmware supports toggling layouts. Although not sure if possible on key release. But it'll be easier that way.

Out of curiosity, why toggling layouts on key release specifically?
I am planning for Windows OS first. But it is good to know that it is possible on Linux OS.
I am not 100% sure about your firmware question, but I know that it is a customized firmware to also support the additional keys that I have in my keyboard. This custom keyboard has 20 extra keys out of which 4 are modifier keys.

I need to toggle the script on the SS Key release as I want to use the same SS Key to switch to a particular layout (kbd*.DLL file) based on the key combination.
e.g.
SS Key + G --> will switch to German Layout
SS Key + F --> will switch to French Layout
SS Key + R --> will switch to Russian Layout

So by doing that if I use the SS Key individually it will TOGGLE between two predefined Layouts.
But if I use the SS Key in combination with any other non-modifier key it will SWITCH to a particular Layout.

Please advise how is it possible for Windows OS too.

User avatar
purdobol

06 Feb 2019, 16:31

Haven't touched Windows in long time. Powershell should do the job, including changing layouts.

KeyEventArgs Class is what you're looking for.
Especially KeyUp event: https://docs.microsoft.com/en-us/dotnet ... work-4.7.2.

vikas

07 Feb 2019, 02:38

Muirium wrote:
06 Feb 2019, 10:27
Layouts are something we already support in every community made firmware out there. We call them layers.

A layer is a completely independent remap, so you can do big things like throw Colemak or Dvorak on there without messing up the Qwerty default.

Triggering them can be done many different ways, from a simple “activate while this key is held” to a selected mode like you’ve described.

The beauty of doing this logic *inside* the keyboard is it’ll work on any host, with no configuration required. Really handy for limited systems like the iPad! It becomes a feature of the keyboard, not your specific environment.

It’s open source so you can dig down into its guts if you prefer. Excellent platform for so many keyboard projects.

Thanks for this interesting option.
Please guide how I can achieve the following using this TMK approach?

1) This custom keyboard has 15 'additional' character (non-modifier) keys.
2) So there are more characters to print for each level
3) This custom keyboard has 4 'additional' Modifier keys (Left Shift2 Key, Right Shift2 Key, Left SS Key, Right SS Key)
4) There are more modifier keys and their combinations i.e. (Shift2, SS, Shift+Shift2, Shift+SS, Ctrl+Shift2, Alt+Shift2, etc.) to print characters. How to address that issue? The characters typed by these Modifier states are not supported by any current keyboard.

Thanks heaps

Post Reply

Return to “Keyboards”