Author Topic: Truly-Ergonomic’s keycodes remapping  (Read 123885 times)

0 Members and 1 Guest are viewing this topic.

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #100 on: Sat, 06 July 2013, 03:31:31 »
OK, it’s been longer than I expected, but I also did more than I planned :)

Firstly, the bug with leaking 0xDE is fixed, as well as another bug I introduced. I have reflashed both my home and office keyboards and am pretty convinced they work as expected (for me).

Secondly, there is now a configurator for the modded firmware. Instead of requiring you to copy and paste lines of .hex, it now gives you a complete .hex file ready for flashing. You can test it here.

And lastly, I have set up a GitHub repository hosting the reverse-engineered firmware and my modifications, so that if someone wants to build on it, they don’t have to repeat my work. (You will still need to know i8051 assembly and hand-assemble your modifications to machine code.)

Offline addwyn

  • Thread Starter
  • Posts: 26
  • Location: Brest, France.
Re: Truly-Ergonomic’s keycodes remapping
« Reply #101 on: Sat, 06 July 2013, 07:33:41 »
Hi Yuri,

Very great work !  :cool:

May I ask you where you found the numbers of clocks cycles in the "micro_delay" function ?

Code: [Select]
micro_delay:                                    ;void micro_delay(byte __register(R7) iters) {
  1AA5 EF               MOV A, R7               ;   for (; iters >= 1; --iters) { // 1 clock
  1AA6 D3               SETB C                  ;                                 // 1 clock
  1AA7 9400             SUBB A, #0h             ;                                 // 1 clock
  1AA9 4004             JC L0017                ;                                 // 2 clocks
  1AAB 00               NOP                     ;                                 // 1 clock
  1AAC 1F               DEC R7                  ;                                 // 1 clock
  1AAD 80F6             SJMP micro_delay        ;   }                             // 2 clocks, total 9 = 0.75 microseconds per iter
L0017:
  1AAF 22               RET                     ;}

When I disassembled this part of the TE209-v3 firmware, I found 14 cycles (based on the Megawin’s doc "MG84FL54BD_A3.pdf"):

Code: [Select]
;--------------------------------------- -------------------------------------------------------------------------------
; Pause of R7 loops of NOP
;--------------------------------------- -------------------------------------------------------------------------------
;                                Clocks
L1AA5: MOV A,R7 1 ; Loop:
SETB C 1 ;   Carry=1
SUBB A,#000H 2 ;   A=A-Carry
JC L1AAF 3 ;   If Carry set (If R7==0) then RETURN
NOP 1 ;
DEC R7 3 ;   R7--
SJMP L1AA5 3 ; LoopEnd
;                        Total: 14      ; 1.16µs/loop = 291µs/250d = 583µs/500d = 875µs/750d = 1.166 ms/1000d
L1AAF: RET

Am-I wrong somewhere ? Is the "MG84FL54BD_A3.pdf" file erroneous ? Are the Keil’s 8051 instruction set descriptions more exact ? What is your opinion ?
« Last Edit: Sat, 06 July 2013, 17:23:25 by addwyn »

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #102 on: Sat, 06 July 2013, 11:03:01 »
OK, it’s been longer than I expected, but I also did more than I planned :)

Wow. This is awesome. Thank you for your great work on this!
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #103 on: Sat, 06 July 2013, 22:17:20 »
May I ask you where you found the numbers of clocks cycles in the "micro_delay" function ?
I took the timings from the Keil site.
Am-I wrong somewhere ? Is the "MG84FL54BD_A3.pdf" file erroneous ? Are the Keil’s 8051 instruction set descriptions more exact ? What is your opinion ?
I guess you’re right and the direct manufacturer knows their chip better. I did not pay much attention to the exact values of the time intervals; for understanding the logic, it was sufficient to know the order of magnitude (that one micro_delay iteration is close to 1 microsecond).

I will update the disassembly with timings from the datasheet.
« Last Edit: Sat, 06 July 2013, 22:18:51 by Yuri Khan »

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #104 on: Sun, 07 July 2013, 11:26:27 »
I have looked at the various versions of the firmware released by Truly Ergonomic for different models, and am pretty sure my mod will work on all of them, with changes only in the layout configuration. I therefore added a model selector on the configurator, and collected their factory default layouts on a wiki page.

If someone with 207 or 104/105 wants to test this hypothesis, please have a spare keyboard handy and use it to report any bugs you encounter ;)
« Last Edit: Sun, 07 July 2013, 12:06:14 by Yuri Khan »

Offline listboss

  • Posts: 22
Re: Truly-Ergonomic’s keycodes remapping
« Reply #105 on: Wed, 10 July 2013, 17:50:04 »
I have looked at the various versions of the firmware released by Truly Ergonomic for different models, and am pretty sure my mod will work on all of them, with changes only in the layout configuration. I therefore added a model selector on the configurator, and collected their factory default layouts on a wiki page.

If someone with 207 or 104/105 wants to test this hypothesis, please have a spare keyboard handy and use it to report any bugs you encounter ;)

Just wanted to say a great thank you for your great work. very appreciated.
Is it possible to use your configurator and add 'layer' functionality to TEK?
I am interested in getting TEK similar to ErgoDox, for example replace the LEFT ARROW key with FN key
« Last Edit: Wed, 10 July 2013, 17:53:50 by listboss »

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #106 on: Wed, 10 July 2013, 21:33:33 »
Is it possible to use your configurator and add 'layer' functionality to TEK?
I am interested in getting TEK similar to ErgoDox, for example replace the LEFT ARROW key with FN key

In the current version, you have three layers for each position of the DIP switch 2. Two of them are persistent (Main and Num) and switched with a key that you configure as T⇭ (TECK Num Lock). The Fn layer is transient and is activated when a key configured as Fn is held down. These switching keys can be placed on any of the 88 keys.

So yes, you can make your Left arrow a Fn key and then bind IJKL or HJKL in the Fn layer to arrows. Shortcuts like Shift+arrow will work, as long as you don’t override Shift in the Fn layer. But I imagine Ctrl+Alt+arrow shortcuts will not be very convenient to press.

Offline listboss

  • Posts: 22
Re: Truly-Ergonomic’s keycodes remapping
« Reply #107 on: Thu, 11 July 2013, 11:05:44 »
So yes, you can make your Left arrow a Fn key and then bind IJKL or HJKL in the Fn layer to arrows. Shortcuts like Shift+arrow will work, as long as you don’t override Shift in the Fn layer. But I imagine Ctrl+Alt+arrow shortcuts will not be very convenient to press.

That's great news however, I have a 207 model and I used the configurator to just change the layout
to Colemak (nothing fancy) using this file.
But after flashing the hex the layout is completely different/nuts  :eek:
For example this is what I get when I type 'yuri khan'  --> 'jlpu ehak'  :)
my dip switch is set as: 11010

Am I missing something here or this can be bug?

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #108 on: Thu, 11 July 2013, 11:28:09 »
I have a 207 model and I used the configurator to just change the layout
to Colemak (nothing fancy) using this file.
But after flashing the hex the layout is completely different/nuts  :eek:
For example this is what I get when I type 'yuri khan'  --> 'jlpu ehak'  :)
my dip switch is set as: 11010

Am I missing something here or this can be bug?

My crystal ball is a bit blurry but it suggests that you might have a case of double Colemak translation. This will happen if, on top of your keyboard remapped to Colemak, you also have the Colemak layout selected in your OS.

Choose one level where remapping happens. You can leave your keyboard QWERTY and use the Colemak layout in your OS (recommended), or you can remap the keyboard to Colemak and use the standard QWERTY layout at the OS level (only for users who want to use Colemak without having to, being able to or being allowed to configure the OS).

Also, in my book, in Colemak the top row goes QWFPG and the bottom row ZXCVB. Your link has G/B/V rotated, is that intentional?
« Last Edit: Thu, 11 July 2013, 11:49:56 by Yuri Khan »

Offline listboss

  • Posts: 22
Re: Truly-Ergonomic’s keycodes remapping
« Reply #109 on: Thu, 11 July 2013, 12:18:04 »
Also, in my btook, in Colemak the top row goes QWFPG and the bottom row ZXCVB. Your link has G/B/V rotated, is that intentional?
yes it is.

I have made sure the OS is set to qwerty, and no other input method is even active in control panel (win7)
I prefer the hardware solution since I take my keyboard with me to work/home and I don't wanna deal with
os settings, it's specially helpful when you are at login screens and the layout driver hasn't kicked in yet.

But I believe you are right that another software might be interfering, will update when I figure it out.

thanks

Offline tayot

  • Posts: 13
Re: Truly-Ergonomic’s keycodes remapping
« Reply #110 on: Sat, 13 July 2013, 18:15:04 »
[quote author=Yuri Khan link=topic=38943.msg953309#msg953309 date=1373214387
If someone with 207 or 104/105 wants to test this hypothesis, please have a spare keyboard handy and use it to report any bugs you encounter ;)
[/quote]

Yuri Khan - Just want to say thanks for your awesome work and express my appreciation. I have a 207  that was sitting in a box because I couldn't get used to the way some keys like Ctrl, Shft and Alt were placed. Even used Keytweak a while back. I just flashed it recently and have been enjoying it a lot. So far so good. My adjustments were pretty basic - but I'm a happy camper. I'll be ordering another TEK board now that I know I can reconfigure the keys. Once again thanks very much.

Offline xsar

  • Posts: 8
Re: Truly-Ergonomic’s keycodes remapping
« Reply #111 on: Wed, 31 July 2013, 13:01:03 »
thank you so much for your excellent work, yuri! typing on my newly flashed dvorak layout. what I didn't get to work though is the FN-xcv (cut-copy-paste commandz) though, I'm assuming the applications I tested it with don't support this command.
« Last Edit: Thu, 01 August 2013, 01:17:30 by xsar »

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #112 on: Wed, 31 July 2013, 13:48:31 »
Yes, it’s very possible that applications ignore AC Cut/Copy/Paste keys. If you are on Windows, maybe you can translate them to ordinary Ctrl+XCV with some thirdparty software — such as Microsoft IntelliType or AutoHotkey.

Do also be aware that, as you’ve rearranged keys form their normal positions, you won’t be able to use any international keyboard layouts. Additionally, playing games (such as those using WASD keys for motion) might be very uncomfortable :)

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #113 on: Fri, 02 August 2013, 20:57:57 »
Hi,

I'm a little scared of flashing my firmware with a custom keymap, especially after Tracer's experience in bricking his/her keyboard. How dangerous do you think it is to use your firmware generator, Yuri Khan? Obviously there are no guarantees, etc., but what is your feeling for how safe this process is?

(I've been trying to mess around with xkb in Linux, but I'm finding it all a bit too complicated for me. I can find files to move alphanumeric keys, but am not sure where the shift keys, etc. are.)

Cheers.

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #114 on: Sat, 03 August 2013, 01:50:25 »
About as safe as crossing the street on a red light after a careful look at the sides.

Of course it’s dangerous. If power goes out while you’re flashing, or if USB connection drops due to a flaky cable or port, or another program starts swapping like crazy or locks up your computer, you can brick your keyboard. This is why Truly Ergonomic discourages flashing from a virtual machine, or with a USB hub in between your computer and keyboard, or having many other programs running — not because flashing definitely won’t work, but because it increases the probability of failure.

On the other hand, I have successfully reprogrammed my two keyboards from within VirtualBox (from Oracle repositories, with USB support) over an unpowered USB hub.

And on the third hand, unlike the street crossing analogy, I believe the worst you can get into is having to open up the keyboard and to issue a hard reset by shorting pins 1 and 36 while powered. (Of course, if you end up in this situation, there are more chances to screw up.)

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #115 on: Sat, 03 August 2013, 02:28:53 »
Thanks Yuri. That's good to know. I do jaywalk, so it would be hypocritical of me not to reflash the firmware.  ;D

If the major potential problems are those that you mention, I'm happy to take the risk, I think. I was more afraid of some imperfect code getting into and bricking the keyboard (since it's reverse engineered). I presumed that was what happened with Tracer.

Also, my keyboard is still under warranty, so I didn't really want to break the sticker at the back. I still think there is a slim chance I might have to return it, as I still occasionally have issues with missed or repeating key presses, although it's definitely getting better. Thanks again for the advice (and software!).

Offline tekkendama

  • Posts: 4
Re: Truly-Ergonomic’s keycodes remapping
« Reply #116 on: Wed, 07 August 2013, 11:03:31 »
thank you so much, Yury.

It works a charm.

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #117 on: Fri, 09 August 2013, 06:17:22 »
Huh… I was just about to sit down and create my layout with Yuri's script, when I spotted the official firmware reprogrammer, which must have just come out…

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #118 on: Fri, 09 August 2013, 08:46:27 »
Yay! We have a public release! :)

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #119 on: Fri, 09 August 2013, 13:59:49 »
Yay! We have a public release! :)

Is it based on your work? If so, congrats!
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #120 on: Fri, 09 August 2013, 14:05:32 »
Huh… I was just about to sit down and create my layout with Yuri's script, when I spotted the official firmware reprogrammer, which must have just come out…

Weird. I can't get that link to load at all. I can get the main page to load, but no other pages off of it.
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #121 on: Fri, 09 August 2013, 16:05:11 »
Nevermind. Looks like they were in the middle of updating their pages, and I was getting blank pages due to it. They're all working again.
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #122 on: Fri, 09 August 2013, 18:13:16 »
@Yuri, what are your thoughts of setting up macros via the firmware?

My thoughts are to use the Fn layer to map a bunch of common symbols used for programming. My inspiration in the "PunctPad" feature of the old Fingerworks Touchstream keyboards. The "PunctPad" modifier was all internal to the keyboard, so that, holding down the modifier on the left hand, on the right hand, you get the following outputs:

y -> //
u -> {
i -> }
o -> [
p -> ]
h -> ->
j -> -
k -> _
l -> (
; -> )
n -> !=
m -> +
, -> =
. -> |
/ -> \

Obviously this is with a QWERTY layout. The 2 character macros can't be replicated at this time, but some of the single key ones I can map to the Fn layer, and I can get the shifted versions by mapping the shift key to the Fn layer (I hope, I haven't actually tried it). But with support of 2 character macros, the shifted keys can also be supported.
« Last Edit: Fri, 09 August 2013, 18:15:32 by nomaded »
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #123 on: Fri, 09 August 2013, 19:03:03 »
Here's my Dvorak layout with "PunctPad" on the "main" layer. I have the QWERTY layout on the "alternate" layer. The programming symbols are on the Fn layer for both layouts. I'm still experimenting, but if I change things up, I'll update this post.

The Main (Dvorak) layer:
31743-0

The Alternate (QWERTY) layer:
31745-1

The Fn layer:
31747-2

Edit 20130810: updated the url because I forgot to move a key in the Alternate Fn layer.

Edit 20130814: I've update the url and the images to reflect the following:
-   I've put the tab key back in the center, on home row. I've been missing the tab key in the higher position a lot more than I would have expected.
-   I found that I was mistakenly hitting the LGUI key quite a bit when it was above the Enter key. I've moved LGUI to the key below it's normal position, because I wal also hitting it by accident when I lift my hands to touch type 5 or 6.
-   I have put the TECK Fn key above the Enter key for easy access to my "PunctPad". I also moved the LShift key in the Fn layer to follow the Fn key.
« Last Edit: Wed, 14 August 2013, 17:46:09 by nomaded »
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #124 on: Fri, 09 August 2013, 20:50:04 »
The firmware code contains a preliminary implementation of a macro facility, although, as far as I know, it never was released as a public feature. Notably, there is no macro programming application available. The protocol for uploading macros into a working keyboard is also not quite clear to me.

I believe it should be possible to set up macros by including them into the firmware image (possibly extending the layout configurator).

That said, I see no possibility of actually writing a macro that will always produce e.g. ->, in all applications on all operating systems, no matter whichever language layout is active:
  • Straightforward keypresses (-_, LShift down, .>, LShift up). This is limited to US English QWERTY or a sufficiently similar layout.
  • Windows/DOS Alt+nnnn codes (turn on Num Lock if needed, LAlt down, K0, K4, K5, LAlt up, LAlt down, K0, K6, K2, LAlt up, restore Num Lock). Works only in Windows and only for characters included in the ANSI and/or OEM code page. (There is also a Unicode method that involves the K+ prefix and a registry key.)
  • Linux: simulate a Ctrl+Shift+U press/release, then simulate entering the Unicode hex code, then Enter. Only Linux and only in most but not all applications, depending on the GUI library used.
Therefore, such macros will have to be personal and tailored to each user’s particular needs. Not going to be as easy as “enter a string to be ‘typed’”.

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #125 on: Fri, 09 August 2013, 23:32:29 »
Hi Yuri, I was wondering if it were possible to remap keys to control brightness. (Currently, in xmodmap, I have Fn+F5 and Fn+F6 mapped to XF86MonBrightnessDown and XF86MonBrightnessUp.) I couldn't find anything in the default keys, so I looked for the HID codes, but it seems like these are not covered by page 07 or 0C. If I am reading it correctly, the codes are 0x0070 and 0x006F. These won't work in the configurator. Does this mean it's not possible to map them?

Thanks again for the script and all your comments. Cheers.

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #126 on: Sun, 11 August 2013, 03:19:48 »
There does not seem to be any HID usage codes for brightness. Also, searching the sources of the Linux HID driver for “brightness” only yields a few places for specific Apple and Chicony keyboards.

I do not know where you got 0x6F and 0x70 from. The Linux kernel codes are 224 (E0h) and 225 (E1h), the evdev-style XKB key codes are 232 and 233, and the XF86 keysym codes are 0x1008FF02 0x1008FF03, but none of these are usable in the configurator which only deals with usage codes.

I believe your solution of mapping XF86MonBrightness* by means of XKB configuration is optimal. (Apple and Chicony can get away with a driver quirk because their keyboards are mass-produced. Your configuration, on the other hand, is unique.)

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #127 on: Sun, 11 August 2013, 06:53:09 »
There does not seem to be any HID usage codes for brightness.

Thanks again. I may have misinterpreted the page, but I followed your link to the HID Usage Tables and then clicked on the link saying Review Request 41:  Display Brightness Controls.

I'm not sure if it's relevant, but the internal keyboard of my Dell laptop has brightness-modifying keys that work out-of-the-box. I suppose there are non-HID ways to send keystrokes…

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #128 on: Sun, 11 August 2013, 07:43:40 »
Nice. This review request is marked as “Approved”; this means the new usage codes will likely be in the next version of the HID Usage Tables.

Still, they have this disclaimer:

Quote
Please note that the creation of a new Usage does not imply support for that Usage by any USB HID Host vendor.

In case of Linux, this means that someone needs to submit a patch that adds such support.
« Last Edit: Sun, 11 August 2013, 07:53:41 by Yuri Khan »

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #129 on: Sun, 11 August 2013, 08:10:02 »
In case of Linux, this means that someone needs to submit a patch that adds such support.

Does the fact that my laptop's inbuilt keys work suggest that Linux already supports them?

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #130 on: Sun, 11 August 2013, 09:01:10 »
Sorry to disappoint you. I have checked the driver source and there is no code to handle these new usages. Your laptop probably uses some other mechanism to control monitor brightness — maybe ACPI events. And no, I don’t think you can generate those from your Truly Ergonomic keyboard without significant changes to the firmware.

Offline nomaded

  • Posts: 197
  • Location: Andover, MA
Re: Truly-Ergonomic’s keycodes remapping
« Reply #131 on: Wed, 14 August 2013, 17:47:56 »
Some additional alternate layouts have been posted to TECK's website.

I've also made some small changes to my alternate Dvorak layout.
« Last Edit: Wed, 14 August 2013, 17:50:04 by nomaded »
Dvorak
ErgoDox fullhand (MX Clears) w/Nuclear Green Data SA || Infinity ErgoDox (Zealios 78g tactile) w/SA Retro || Atreus62 (MX Clears) w/Chocolatier || TECK 209 (MX Browns) || TouchStream ST
Kensington Slimblade Trackball || Logitech Cordless Optical Trackman || Apple Magic Trackpad
Current Dvorak-based ErgoDox layout || Current Dvorak-based TECK layout

Offline sparhawk

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #132 on: Thu, 15 August 2013, 06:42:27 »
Sorry to disappoint you. I have checked the driver source and there is no code to handle these new usages. Your laptop probably uses some other mechanism to control monitor brightness — maybe ACPI events. And no, I don’t think you can generate those from your Truly Ergonomic keyboard without significant changes to the firmware.

Thanks very much for checking anyway, Yuri.

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #133 on: Sun, 14 December 2014, 18:03:34 »
Hi
I am considering whether to buy a TE, and have been looking at the online layout creator.

I have a very simple (maybe stupid) question about which I asked TE but got no reply.
When you drag a key into a location on a layout, the shifted and unshifted characters travel together.

For example,  ] and } are always together on a key.
Does this mean that you always need to press SHIFT to get a } character? So if the key is on the fn layer, you would need to press fn+SHIFT+} to get a } character?

How do you specify to the mapper that you want the shifted character?



Offline Sc0tTy

  • Posts: 167
  • Location: Netherlands
  • Ergo enthousiast
Re: Truly-Ergonomic’s keycodes remapping
« Reply #134 on: Sun, 14 December 2014, 18:30:49 »
Hi
I am considering whether to buy a TE, and have been looking at the online layout creator.

I have a very simple (maybe stupid) question about which I asked TE but got no reply.
When you drag a key into a location on a layout, the shifted and unshifted characters travel together.

For example,  ] and } are always together on a key.
Does this mean that you always need to press SHIFT to get a } character? So if the key is on the fn layer, you would need to press fn+SHIFT+} to get a } character?

How do you specify to the mapper that you want the shifted character?

Yeah they are together. You are just moving around normal keys. Sadly you cant do what you are thinking of, I would love for that to be added. Same goes for combo's. Maybe in the future this will be added but I guess only time will tell.

1x ErgoDox EZ
2x Truly Ergonomic Keyboard 229
2x Kinesis Freestyle V3-VIP
2x Bamboo Pen & Touch (Mouse replacement)
2x Salli Swing
1x Herman Miller Aeron

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #135 on: Sun, 14 December 2014, 20:41:27 »
When you drag a key into a location on a layout, the shifted and unshifted characters travel together.
Does this mean that you always need to press SHIFT to get a } character? So if the key is on the fn layer, you would need to press fn+SHIFT+} to get a } character?

Yes and no.

When you press a key or an Fn+key combination, the keyboard sends a key code to the computer. It is then the operating system’s concern to translate that code into characters.

The TECK configurator deals with the first of these two steps only: you choose which key sends which key code, and for your convenience the key codes are displayed as the characters they are mapped to in the standard PC US keyboard layout. So if that’s the layout you use, you get a pretty accurate representation of what you get.

On the other hand, many users (myself included) use other layouts. They (we) are expected to know the mapping between US QWERTY and their (our) layouts. So on a standard Russian layout the [{ keycode maps to the letter Х (that’s Cyrillic Letter Ha, not Latin Letter X).

The configurator is primarily meant to customize the placement of editing keys such as Enter, Backspace, Shift/Ctrl/Alt, Ins, Del and such; and a few punctuation keys. If you want to customize your layout at the shift state level, you had better use the facility provided by your OS — xkb in Linux, Ukelele on OS X and MSKLC on Windows.

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #136 on: Sun, 14 December 2014, 23:25:02 »
I think I understand, thanks.

It would be much nicer though if the keyboard itself could store a default shift state (and other modifiers) for each mapped key, and prefix the appropriate modifier codes before sending the mapped keycode. That way, you would get the same result on any computer, and you would not have to futz with both the keyboard and mapping software on the os.

(Where modifier keys were pressed, that would reverse the defaults for each modifier)

Offline Sc0tTy

  • Posts: 167
  • Location: Netherlands
  • Ergo enthousiast
Re: Truly-Ergonomic’s keycodes remapping
« Reply #137 on: Mon, 15 December 2014, 03:14:22 »
Yeah. I still need to look at manually configuring keycodes on the board. Apparently it should be possible to do this but I haven't tried it yet.
1x ErgoDox EZ
2x Truly Ergonomic Keyboard 229
2x Kinesis Freestyle V3-VIP
2x Bamboo Pen & Touch (Mouse replacement)
2x Salli Swing
1x Herman Miller Aeron

Offline Sc0tTy

  • Posts: 167
  • Location: Netherlands
  • Ergo enthousiast
Re: Truly-Ergonomic’s keycodes remapping
« Reply #138 on: Wed, 17 December 2014, 13:32:12 »
Yeah looks like we'll have to use AHK or some other solution..

Hopefully they or Yuri can add this in the future.
I would love to have dedicated CTRL+C and { keys!
1x ErgoDox EZ
2x Truly Ergonomic Keyboard 229
2x Kinesis Freestyle V3-VIP
2x Bamboo Pen & Touch (Mouse replacement)
2x Salli Swing
1x Herman Miller Aeron

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #139 on: Wed, 18 February 2015, 00:05:01 »
Hi again
Just received my TEK today, and looking more closely at mapping options.

I intend to use remapping software on my machine in addition to remapping, as Yuri suggests, to get the desired effect.

So I started out intending to use T_FN on the left space key. However, a quick experiment showed me that T_FN is purely internal to the TEK and does not transmit a modifier key. (Interestingly, on the Mac, the Fn key *does* transmit a code, but I cannot find a corresponding code on Yuri's mapper, nor in the USB HID tables).

Without a modifier present, I have no way to remap the keys in software. Eg I want to put the 9( key produced when I hit T_FN+Y, and then map this to the shifted version ( in software.

With a normal keyboard I could use R_CTRL or R_ALT for this purpose, and not use them for their normal role, but the non-orthogonal TEK layout does not lend itself to pressing a left modifier while pressing a left handed key with the right hand, so I'd like to keep these modifiers in their usual role for now.

Is the only option use T_FN to produce a codes not normally used, like the numpad keys, than remap those to unrelated keys in software?

Also, is there a way for T_NL to function like a shift key (ie not locking, but just accessing the number keys while the T_NL is held down)

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #140 on: Wed, 18 February 2015, 00:45:04 »
Hello pw,

if you find out which HID usage code the Mac Fn key transmits, you can click any key on the configurator and just enter it as a hexadecimal number followed by the letter h. E.g. 2Ch is the code for Space. (The case is not significant.) Otherwise, maybe you can persuade your remapping software to react to a keycode of your own choice, such as F13.

As for a non-locking Num modifier, I actually put the T_FN (not T_NL!) on my middle bottom key and put keypad keys in the Fn layer. I’ve got mixed feelings about the utility of that; most of the time, I just reach for the digit row.

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #141 on: Wed, 18 February 2015, 01:56:16 »
Thanks Yuri
Do you know of a quick and dirty way of dumping the HID codes? A quick search found python library python-libusb1 which will probably do it for me, but Id rather not go down any rabbit holes I can avoid.

Yes, I was thinking of the same with the T_FN, but I wanted mainly punctuation on the fn layer, not leaving enough for the numbers too.

PS Have you hand-assembled the 8051 code to modify the existing TE code? Do you know if (eg) the MCU 8051 IDE could be used to develop in C instead?

« Last Edit: Wed, 18 February 2015, 02:00:44 by pw »

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #142 on: Wed, 18 February 2015, 01:57:08 »
Thanks Yuri
Do you know of a quick and dirty way of dumping the HID codes? A quick search found python library python-libusb1 which will probably do it for me, but Id rather not go down any rabbit holes I can avoid.

Yes, I was thinking of the same with the T_FN, but I wanted mainly punctuation on the fn layer, not leaving enough for the numbers too.

PS Have you hand-assembled the 8051 code to modify the existing TE code? Do you know if (eg) the MCU 8051 IDE could be used to develop in C instead?


Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #143 on: Wed, 18 February 2015, 03:22:48 »
I believe the quickest and dirtiest would be to use a slightly modified hid_listen tool from the PJRC Teensy kit. (You’d need to modify the VID:PID of the device to which it connects.) Alternatively, you might be able to use wireshark.

Yes, all the modifications I have done to the TE firmware are hand-assembled. I have done a few experiments and am fairly convinced the SDCC compiler (which is used by MCU 8051 IDE) can be used to program the TECK. I plan to implement a firmware providing at least all the features of the existing one, plus freedom to tinker with.

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #144 on: Wed, 18 February 2015, 03:41:40 »
>I plan to implement a firmware providing at least all the features of the existing one, plus freedom to tinker with.

Wow! I look forward to tinkering.
I hope that it works out for you Yuri, and that TE is recompensing you for your efforts.



Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #145 on: Sat, 21 February 2015, 05:09:32 »
Ive been experimenting with a few layouts, think I found a small problem with the keypad digits. Instead of transmitting just K1 etc, six HID codes are transmitted for each key press. Pressing K1 will give

clear/num lock down (47)
clear/num lock up
K1 down (53)
K1 up
clear/num lock down
clear/num lock up

Maybe this represents a workaround of some sort, but while it does give digit chars in a word processor, it wont work in a calculator because the number is immediately cleared.

I will put in the normal keyboard digits instead, but the keypad digits are more useful because you can use Karabiner etc to default to symbols on the keyboard, then use the keypad to enter numbers without having to press shift in addition to T_FN.

paul


Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #146 on: Sat, 21 February 2015, 05:59:43 »
Yes. This is what Truly Ergonomic calls “non-synchronized Num Lock”. Basically, when you press T_NL, the keyboard lights up the Num Lock LED but tells nothing to the OS, so that the OS thinks Num Lock is off. When you press a key, the keyboard tells the OS “hey, the user pressed and released Num Lock to turn it on, then pressed and released End/1, then pressed and released Num Lock to turn it back off”. As a result, the OS should produce a 1 digit. (This logic only kicks in if the OS-reported Num Lock status is off; if on, each keypress generates a single key up/down pair.)

This feature was introduced in version 2 of the firmware, AFAIR. The motivation was that otherwise TECK would be controlled by the Num Lock status sent by the OS. And some PC BIOSes turn on Num Lock at boot, which makes typing on TECK 1 very inconvenient.

Why does your calculator clear the number when Num Lock is turned off?

Oh wait. Macs do not have a notion of Num Lock mode and call the key with that keycode Clear? D’oh.

Is there a way to cause a Mac to tell the keyboard that Num Lock is on so it won’t try to turn it on and off each time?

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #147 on: Sat, 21 February 2015, 07:16:16 »
Erggh, thanks Yuri
I figured it was something like that, but it still doesn't make much sense to me.
I can see how you would need that if you were always transmitting a 'j' so the os needed to interpret the character as 'j' or '1' depending on its own numlock state. But in our case a unique code for k1 is transmitted, so shouldn't it work regardless of the os numlock state?
Also, if the os numlock state is initially set wrong on some machines, and correct number entry does depend (somehow) on having the correct os numlock state, even when sending unique codes, then wouldn't the first character be lost, because the first sent num lock would turn the os numlock state to off?

 Anyhow, the is a setting in Karabiner to disable num lock for the logitech N305 which appears to do the trick.

Thanks again.

Offline pw

  • Posts: 21
Re: Truly-Ergonomic’s keycodes remapping
« Reply #148 on: Sat, 21 February 2015, 07:40:10 »
More info:
The numpad number keys do seem to behave correctly in the numpad layer itself; I was using them in the fn layer.

Offline Yuri Khan

  • Posts: 31
  • Location: Novosibirsk, Russia
Re: Truly-Ergonomic’s keycodes remapping
« Reply #149 on: Sat, 21 February 2015, 07:43:15 »
On PCs, the code 59h is interpreted as Keypad 1 and produces the digit 1 only when OS Num Lock is on. Otherwise, it gets interpreted as Keypad End and moves the cursor. Therefore:
  • if OS Num Lock is off, the keyboard turns it on by sending a 53h down and up, then the actual key, and then restores OS Num Lock back after key activity pauses;
  • if OS Num Lock is on, the keyboard only sends the actual key.
This is how the firmware currently works.

On Macs, there is no Num Lock; keypad keys always generate digits (as far as I understand). Additionally, the key code 53h is interpreted as Clear. So:
  • on Mac, the keyboard should only send the actual Keypad key code without any Num Lock keypresses.
Problem is, the keyboard has no means of automatically knowing it is connected to a Mac.

Cross-platform development is hard. I will need to remember this particular gotcha for the C firmware project.