Author Topic: TMK: Custom keyboard layout with non-standard shift-characters; how?  (Read 3325 times)

0 Members and 1 Guest are viewing this topic.

Offline fille3002

  • Thread Starter
  • Posts: 5
Hello fellow keyboard people!
I'm just getting started with my ergodox ez, and I did some analysis of my typing habits (keylogged myself, datamined my stack overflow, messenger history, all the source code i could find etc.) and consequently made a custom keyboard layout suited for me using http://www.keyboard-layout-editor.com/ based on my data, based on the workman layout. Here's a dump of my layout:

Code: [Select]
[{x:3.5},":\n3",{x:10.5},"(\n2"],
[{y:-0.875,x:2.5},"?\n5",{x:1},"\"\n1",{x:8.5},"=\n0",{x:1},")\n4"],
[{y:-0.875,x:5.5},"'\n9",{a:7},"",{x:4.5},"",{a:4},"%\n8"],
[{y:-0.875,w:1.5},"esc","#\n7",{x:14.5},"+\n6",{w:1.5},"¨\n~"],
[{y:-0.375,x:3.5},"R\n\n\n\n\n\n\n\n\n↑",{x:10.5},"U\n\n\n\n\n\n\n\n\n↑"],
[{y:-0.875,x:2.5},"D",{x:1},"W",{x:8.5},"F\n\n\n\n\n\n\n\n\n\nLMB",{x:1},"P\n\n\n\n\n\n\n\n\n\nRMB"],
[{y:-0.875,x:5.5},"B",{a:7,h:1.5},"",{x:4.5,h:1.5},"",{a:4},"J"],
[{y:-0.875,w:1.5},"tab","Q",{x:14.5},"Ö\n\n\n🔇",{w:1.5},"^\n*"],
[{y:-0.375,x:3.5},"H\n\n\n\n\n\n\n\n\n↓",{x:10.5},"E\n\n\n\n\n\n\n\n\n↓"],
[{y:-0.875,x:2.5},"S\n\n\n\n\n\n\n\n\n←",{x:1},"T\n\n\n\n\n\n\n→\n\n.",{x:8.5},"N\n\n\n\n\n\n←\n\n\n.",{x:1},"O\n\n\n\n\n\n\n\n\n→"],
[{y:-0.875,x:5.5},"G",{x:6.5},"Y"],
[{y:-0.875,w:1.5},"alt","A",{x:14.5},"I\n\n\n🔊",{w:1.5},"_\n/"],
[{y:-0.625,x:6.5,a:7,h:1.5},"",{x:4.5,h:1.5},""],
[{y:-0.75,x:3.5,a:4},"M",{x:10.5},"Ä\n\n\n\n\n\n\n\n\n\n▶ ❚❚"],
[{y:-0.875,x:2.5},"X",{x:1},"C",{x:8.5},"L\n\n\n\n\n\n\n\n\n\n|◀◀",{x:1},"Å\n\n\n\n\n\n\n\n\n\n▶▶|"],
[{y:-0.875,x:5.5},"V",{x:6.5},"K"],
[{y:-0.875,w:1.5},";\n-","Z",{x:14.5},".\n,\n\n🔉",{w:1.5},">\n<"],
[{y:-0.375,x:3.5},"\\\n|",{x:10.5},"&\n!"],
[{y:-0.875,x:2.5},"´\n`",{x:1},"media",{x:8.5},"ctrl",{x:1},"@\n$"],
[{y:-0.75,x:0.5,a:7},"<=",{a:4},"}\n{",{x:14.5},"]\n[",{a:7},"=>"],
[{r:30,rx:6.5,ry:4.25,y:-1,x:1},"",""],
[{h:2},"shift",{h:2},"backsp",""],
[{x:2},"del"],
[{r:-30,rx:13,y:-1,x:-3},"",""],
[{x:-3},"",{h:2},"enter",{h:2},"space"],
[{x:-3},"win"]

The problem seems to be that I now have non-standard key combinations, so just moving the keys around isn't enough. I need the shifted keys to map to other characters than they would normally do. Since I have the ergodox, I thought this shouldn't be a problem, but it seems to be a limitation in the usb keyboard spec, that shift position is sent separately from key id's.

I would very much like to work around this in my ergodox rom, since that means I can take my keyboard and go to another computer with zero setup time. Otherwise autohotkey or a custom program could solve this. Besides, it was a long time since I wrote some code this close to hardware.

Does anyone here have some tips to get me going, or some guide or something that I can follow?

Offline algernon

  • Posts: 311
  • A tiny mouse, a hacker.
    • Diaries of a Madman
Re: TMK: Custom keyboard layout with non-standard shift-characters; how?
« Reply #1 on: Tue, 14 June 2016, 12:31:01 »
Macros, or a software layout to complement your HW layout. Either or both. Myself, I went with macros, see here.

This is QMK, but something similar with TMK should work too. (Though if you have the EZ, QMk is <3)

Offline algernon

  • Posts: 311
  • A tiny mouse, a hacker.
    • Diaries of a Madman
Re: TMK: Custom keyboard layout with non-standard shift-characters; how?
« Reply #2 on: Tue, 14 June 2016, 12:32:59 »
Macros, or a software layout to complement your HW layout. Either or both. Myself, I went with macros, see here.

This is QMK, but something similar with TMK should work too. (Though if you have the EZ, QMk is <3)

..or you can turn shift from a modifier into mod + layer key. Press shift, switch to another layer with the symbols in the right position, and register a shift too.

Offline fille3002

  • Thread Starter
  • Posts: 5
Re: TMK: Custom keyboard layout with non-standard shift-characters; how?
« Reply #3 on: Wed, 15 June 2016, 11:10:50 »
I switched to QMK and got it running. The keymap works, except for the problem that I have no idea how to use non-shift characters on the layer that the shift-key activates (while held down). I need to type both non-modified and alt-gr (without shift) characters while holding the shift-key. I've tried macros, but even MACRODOWN(U(LSFT), T(MINS), D(LSFT)) doesn't work; the shift-key is still held down when T(MINS) happens. All shifts, both keyboard and macro, are left-shift.

Do you have any tips? Do I have to remove shift and only use the key as a layer modifier, having shift-macros for almost all the keys?

Offline algernon

  • Posts: 311
  • A tiny mouse, a hacker.
    • Diaries of a Madman
Re: TMK: Custom keyboard layout with non-standard shift-characters; how?
« Reply #4 on: Wed, 15 June 2016, 14:48:48 »
I switched to QMK and got it running. The keymap works, except for the problem that I have no idea how to use non-shift characters on the layer that the shift-key activates (while held down). I need to type both non-modified and alt-gr (without shift) characters while holding the shift-key. I've tried macros, but even MACRODOWN(U(LSFT), T(MINS), D(LSFT)) doesn't work; the shift-key is still held down when T(MINS) happens. All shifts, both keyboard and macro, are left-shift.

Do you have any tips? Do I have to remove shift and only use the key as a layer modifier, having shift-macros for almost all the keys?

Instead of returning a macro like that, try this:

Code: [Select]
if (record->event.pressed) {
  unregister_code(KC_LSFT);
  register_code(KC_MINS);
  unregister_code(KC_MINS);
  register_code(KC_LSFT);
}

I have had issues with MACRO/MACRODOWN not releasing modifiers when they were registered some other way, but explicitly unregistering them helped, and did the trick for me.

Offline fille3002

  • Thread Starter
  • Posts: 5
Re: TMK: Custom keyboard layout with non-standard shift-characters; how?
« Reply #5 on: Fri, 17 June 2016, 11:51:45 »
Awesome help! It seems to work just fine now. I'll spend a few weeks switching over now, and see if my layout needs some changes. Keep noticing my brain jumping back to qwerty when touch typing :)