Agent 2: Next-level UHK and module configuration

TL;DR: Say hi to 12 layers per keymap, module speed and acceleration settings, and loads of advanced features, mostly enabled by the new smart macros functionality of the latest UHK Agent and firmware releases.

I don’t usually write dedicated posts about new releases, but this is a major one, we’ve been working on it for a year, and it delivers a huge punch that can elevate your UHK experience to the next level, so it mustn’t go unnoticed.

A summary of new features to whet your appetite:

  • Extended the original four layers per keymap with four regular layers (Fn2, Fn3, Fn4, Fn5) and four modifier layers (Shift, Ctrl, Alt, Super).
  • All modules: speed and acceleration settings, axis locking settings, per-layer navigation modes
  • Key cluster module: Added the ability to fine-tune or disable the behavior of the mini trackball.
  • Trackpoint module: Fixed occasional trackpoint pointer jumps and made it easy to stop drifting if it occurred.
  • Touchpad module: Implemented pinch-to-zoom, two-finger scrolling, doubletap-to-drag, and made the tap action configurable.
  • Advanced configuration scenarios via smart macros, such as configurable modifier layer triggers, mouse key axis skew, and LED fade timeout
  • Super-advanced configuration scenarios via extended macro commands, such as variables, loops, double tap actions, and runtime macro recording.
  • Implemented N-key rollover.
  • Made accelerate and decelerate actions work with modules.
  • Fixed USB descriptors which caused high CPU load on Macintosh computers.

Let’s go over the main features, but first, install the new Agent. Then it’ll upgrade your UHK to the new firmware.

12 layers per keymap

Instead of 4 layers, you can now have 12 layers per keymap.

You can enable/disable any of the above layers per keymap except for the base layer, which is mandatory.

The Fn2, Fn3, Fn4, and Fn5 layers work just like the existing layers, but Shift, Ctrl, Alt, and Super are modifier layers.

On modifier layers, you can map alternative actions per key, which trigger when the key is pressed with the relevant modifier. For example, now you can implement the Programmer Dvorak layout solely on the UHK.

Credit: “The Case for the Programmers’ Keyboard Layout” by Zachary Johnson

Smart macros introduction

You’re probably already familiar with regular macros, which are a sequence of macro actions, such as keypresses and mouse movements.

Smart macros, however, enable the advanced customization of your UHK and its modules. See the following screenshot, which shows a macro named $onInit containing a command macro action that contains multiple macro commands:

$onInit is a special macro name. It's a macro event that executes each time your UHK gets powered and when you save its configuration.

"set module.trackball.baseSpeed 1" is a macro command that sets the base speed of the trackball module to 1.

Macro commands work in any macros, not only in macro events, and you can bind them to any key. This way, you can make Fn+1 set your trackball base speed to 1, and make Fn+2 set it to 2, for example.

Interactive smart macro editing

Adjusting values by editing text is tedious. This is why we created a smart macro sidebar that can be opened on macro pages. This sidebar contains easy-to-read documentation and provides interactive widgets that make configuration a breeze.

When clicking on a macro command action, the widgets of the smart macro sidebar display the actual values of the commands, and module-specific widgets appear. You just have to interact with these widgets, hit the usual “Save to keyboard” button, and your settings will be applied immediately.

I strongly recommend you delve into these settings, as they can make a huge difference. The default sensitivity settings of the modules are reasonable, but by tweaking them to your needs, you can make them so much more usable. Maybe, just maybe, you can finally get rid of your mouse.

Advanced configuration scenarios

Besides $onInit, there’s also the “$onKeymapChange {keymapId}” macro event, such as $onKeymapChange QWR, which is executed when the QWR keymap is activated.

This event enables you to have keymap-specific settings, which allows for many advanced use cases. For example, different operating systems have different mouse sensitivity. This feature allows you to have different speed and acceleration settings for your mouse keys and modules via different operating system-specific keymaps.

Believe it or not, I’m still scratching the surface. If you really want to go crazy, you can use the set "macroEngine.extendedCommands 1" command to enable the extended macro engine, allowing for variables, loops, and countless advanced commands. If you’re comfortable with delving into manual pages, check out the extended macro engine user guide and reference manual.

Smart macros history and credit

Smart macros have an interesting history, starting out as Karel Tuček’s UHK firmware fork on GitHub.

Karel wanted special firmware features, and he originally (ab)used the text macro actions of Agent by making the firmware interpret the lines starting with the $ character as special commands. He’s essentially implemented a command interpreter in the UHK firmware that allowed for his advanced use cases.

I saw his efforts early on, and I was impressed, but I considered his work quite niche and wasn’t too interested. (In retrospect, I can see that his advanced commands are used and loved by many.)

Then it struck me that smart macros could enable the configuration of many UHK and module features without developing Agent, which is a huge win, as adding new features both to Agent and the firmware takes a ton of work. Exposing new features only via the macro engine of the firmware is so much easier. 

I came up with the idea of macro events and making smart macros a first-class citizen in Agent, then implemented the smart macro sidebar. Karel has implemented the acceleration driver of the modules, macro events, and, nowadays, pretty much everything that has to be done with firmware logic. His work is hard to overstate.

As an interesting trivia, the macro command editor of Agent might feel familiar. This is because we use Monaco editor, which also powers Visual Studio Code. In a way, Agent became an integrated development environment, supporting a special keyboard language whose interpreter runs in the UHK firmware.

The future of smart macros

I eventually want to expose basic smart macro settings, such as module settings or the LED fade timeout, not only via the smart macro sidebar but dedicated Agent widgets for better usability.

Nonetheless, we’ll keep and extend the currently available smart macro commands and settings because they allow for advanced configuration scenarios.

I plan to gradually move the extended macro commands from the current markdown macro documentation into the smart macro sidebar of Agent to make them easier to digest and not hide them behind the set "macroEngine.extendedCommands 1" command.

Closing words

To this day, we’ve released 60 Agent versions and 66 firmware versions, and we’re still going strong. I’m excited about our progress and grateful to our wonderful customers for their support. We keep moving forward because of you.

Thank you for reading this update! As usual, we plan to publish a manufacturing update around the end of the month. Stay safe!

The comments are closed, but our forum is available for public discussion.

17 Comments

  1. Sascha 2022-11-21 at 10:34

    I like the macro-recoding feature very much, I wanted it for a long time an now it is there!

  2. André 2022-11-21 at 11:54

    Awesome work guys, but a little bit more documentation for the unaware would be great. For example, how do I get that pinch to zoom thing running on my touchpad? And what are good ways to make use of the fn layers? How does that axis locking stuff work?

    • László Monda 2022-11-23 at 21:34

      Thanks for the nice words! Please update Agent and your firmware, then check out the options in the smart macro sidebar according to this post and its screenshots.

  3. Laur 2022-11-21 at 14:48

    Is there a way to automatically activate a specific keymap based on OS? I'm using a kvm switch to change between linux & windows machines, and would prefer to use a non-default keymap for windows. Is it possible to achieve this via extended macros?

    • László Monda 2022-11-23 at 21:35

      Currently, you have to build Agent from source and use the $agentDir/packages/usb/switch-keymap.ts script to switch to any keymap from the host. Eventually, we'll provide a nicer way and a TypeScript library.

  4. Richard 2022-11-25 at 10:52

    Great news, I've been keen about this and great to see it released! :)

  5. Jakub 2022-11-25 at 11:33

    There really should be some kind of forum or other way of community communicating together to sell tips and tricks.
    I for instant have a lot of problems with defining simple thing: I want on mod layer for 'x' to act as delete, except when holding left shift since then it should act as backspace.
    Is it possible with current UHK agent?

  6. JY 2022-11-28 at 03:34

    Hello,

    I have some trouble because of your new update.
    In the middle of updating, there were some error messages and my pc(Windows 10) cannot find my UHK.
    I rebooted my pc and ran the UHK agent app.
    The UHK agent app said that "Agent can fix it".
    But my pc cannot find my UHK keyboard any more.
    My UHK keyboard is still connected to my pc but the Led lights are off and not working on the UHK keyboard.
    I think there must be some error in the middle of writing the firmware of the keyboard.
    What do I have to do?
    Please let me know as soon as possible.
    Thanks.

    Regards
    JY.

    • László Monda 2022-11-28 at 12:40

      Hi there!

      Please follow the instructions at https://ultimatehackingkeyboard.com/knowledgebase?q=unbrick

      If you have further issues, please contact us at https://ultimatehackingkeyboard.com/contact-us

      • JY 2022-11-28 at 13:15

        Thanks for your rapid support!
        I could fix my UHK and have finish the firmware update succefully.
        I would like to mention that Nora Dollenstein who is support staff has helped me every time with great kindness.
        Thank you very much.

        Regards,
        JY.

        P.S.
        How about making a "Hard Reset Button" in next version?

        • László Monda 2022-11-28 at 14:16

          Thanks for your kind words and suggestion!

          We don't plan to add a hard reset button because this issue is very rare, but the capability will be available the same way as for the current version.

  7. MightyHase 2022-11-28 at 17:32

    Can i change the color of a key to something else via macros? Haven't figured that one out yet.

    Like set A to blue instead of that white/purplish color on the FN layer.

  8. Josh P 2023-02-18 at 00:10

    I'm don't understand the modification layers. Normal layers make sense, and I'm assuming that the new fn2-fn5 layers are intended to be alternative FN layers for your FN key that you only use one at a time of... But I don't understand how modification layers work. A short post detailing how to use them would be great!

    • László Monda 2023-02-20 at 09:56

      Let's say you bind a macro to the ` key of the Shift layer. Then you can trigger the macro by hitting Shift + `

      Fn layers work just like normal layers, such as Mod, Mouse, and Fn.

Comments are closed.