Gaming Config (Tips & Tricks?)

I’d like to start a thread for gaming config ideas.
If anyone has any other tips/tricks, I’d love to hear 'em…

I’ll list & update anything I find useful here:


• MAX-TAP macro •

:warning: WARNING!!! :warning:
This macro probably shouldn’t be used on the UHK80, as it tends to push it to the Max (pun intended). It can cause some pretty heavy lag, stuck keys, and who knows what else. It seems stable on the UHK60 though. If anyone finds a suitable replacement for this version, let me know, and I’ll update this section.


Of course, I’ll start with @maexxx’s version of the Snap-Tap (null movement) workaround; tweaked to use the A & D keys instead of J & L. BIG help, for sure:

First, add setVar snap_running 0 to your $onInit.

Then create a macro titled snap-leftright with the following, and place it on both the A & D (strafing) keys of your gaming keymap:

if ($thisKeyId == $keyId.a) setVar snap_mode 1
else if ($thisKeyId == $keyId.d) setVar snap_mode 2
else setVar snap_mode 0
if ($snap_running == 0) fork snap-leftright-worker
delayUntilRelease
ifKeyActive $keyId.a final setVar snap_mode 1
ifKeyActive $keyId.d final setVar snap_mode 2
setVar snap_mode 0

Then create another macro titled snap-leftright-worker with the following (no need to assign to a key, just create the macro in the macro list):

setVar snap_running 1
setVar snap_state 0
setLedTxt 0 '<->'
loop:
if ($snap_state == 0) {
    if ($snap_mode == 1) {
        releaseKey d
        pressKey a
    }
    else if ($snap_mode == 2) {
        releaseKey a
        pressKey d
    }
}
else if ($snap_state == 1) {
    if ($snap_mode == 0) {
        releaseKey a
        releaseKey d
    }
    else if ($snap_mode == 2) {
        releaseKey a
        pressKey d
    }
}
else if ($snap_state == 2) {
    if ($snap_mode == 0) {
        releaseKey d
        releaseKey a
    }
    else if ($snap_mode == 1) {
        releaseKey d
        pressKey a
    }
}
setVar snap_state $snap_mode
if ($snap_mode != 0) goTo loop
ifNotPlaytime 5000 goTo loop
setVar snap_running 0
setLedTxt 1 '<->'

For more info on what the Snap-Tap (null movement) stuff is all about, as well as the evolution of Max’s macro, you can read through this thread here.


• Dual use keys •

Triggering two different actions with one key can be useful.

This is @mlac’s DOOM: Shotguns usecase.
The following will select the super shotgun upon single-tap, and* the combat shotgun when double-tapping:

ifDoubletap final tapKey 1 // combat shotgun
tapKey 5 // super shotgun

*Potential quirk with the above macro…
Double-tapping that macro outputs both a 5 and a 1 for every double-tap. That might not be the desired behavior if your usecase is to select an in-game item. It might be fine for switching shotguns in DOOM, but not so much if you’re trying to select instant-use items.

e.g., Imagine you have grenades mapped to the 5 key (single-tap), and health potions mapped to the 1 key (double-tap). If you need to replenish your health, it doesn’t help much if you dropped a grenade on your toe while reaching for a health potion… :bomb: :face_with_peeking_eye: :collision: :skull_and_crossbones: :test_tube:


• Double-Tap to sprint/crouch etc. • For games that don't include toggle options for sprinting/crouching, etc., here's a macro that allows you to use LShift like normal when tapping/holding, but double-tapping toggles it on, and single-tapping it again toggles it back off:
ifDoubletap final pressKey persistent LS
releaseKey persistent LS
holdKey LS

If you want to use the same actions on a different key, then replace the LS with the key you want.

e.g., LCtrl to crouch:

ifDoubletap final pressKey persistent LC
releaseKey persistent LC
holdKey LC

Here’s another example usecase for games with no option to toggle holding right-click.

Hold Right-click:

ifDoubletap final pressKey persistent mouseBtnRight
releaseKey persistent mouseBtnRight
holdKey mouseBtnRight

Potential quirk with the above macro…
•The double-tap to lock macro outputs the specified keys twice on double-tap, and again on single-tap to release. Since my current usecase is only for locking LShift, LCtrl, or mouseBtnRight, it’s not really a big deal, but could be problematic if implemented differently.


• Auto-Walk •

Here’s a couple of methods for adding Auto-Walk to games that don’t have it baked-in…

•METHOD 1
One way would be to bind the following to a key (most games use backtick for auto-walk nowadays). This will just toggle a continuous w (obviously):

toggleKey persistent w

You’ll also probably want to cancel auto-walk when you tap w or s, like most games would…

To do that, replace your w & s keys with the following macros (These will make the w & s keys work normally, but releases persistent w when pressed.):

Auto-walk Release W

pressKey w
releaseKey persistent w
holdKey w

and

Auto-walk Release S

pressKey s
releaseKey persistent w
holdKey s

•METHOD 2
You can just place this on the actual w key. It will make w work normally when single-tapped/held, but double-tapping will make it persistent until pressed again (a little tricky to use in some games):

ifDoubletap final pressKey persistent w
releaseKey persistent w
holdKey w

Again, you’ll likely want to add the ability to cancel auto-walk when tapping s by placing the “Auto-walk Release S” macro on your s key.


The above examples can also be combined with the following to lock LShift (sprint) while auto-walking:

ifDoubletap final pressKey persistent LS
releaseKey persistent LS
holdKey LS

Also, it’s probably a good idea to add releaseKey persistent w and releaseKey persistent LS to certain $onKeymapChange, $onLayerChange events, etc..


• Keystroke Delay auto-disable • For anyone who uses a keystroke delay, it's probably a good idea to set it to 0ms (off) when gaming. In Windows OS, I set a keystroke delay of 10ms by default because some apps can't handle the UHK's output speed. (e.g., Notepad will have scrambled/missing output when pasting text via macros.)

I added set keystrokeDelay 0 to a macro titled $onKeymapChange GAM (my gaming keymap) That automatically disables the keystroke delay when switching to my gaming keymap. Then I added set keystrokeDelay 10 to $onKeymapChange any. That turns it back on (10ms) for all other keymaps.


• Mouse Left/Right click on keyboard • The other day I decided to add mouse left & right click keys to the left thumb buttons on the base layer of my gaming keymap (Fn2 = right-click and Fn = left-click). This makes ADS (aim down sights) a dream. It’s so much more comfortable to hold down right-click to ADS with the left hand. Using your keyboard to shoot (left-click) will also improve your accuracy because you don’t have micro-jumps on your real mouse. It’s gonna take a bit of practice before it feels natural, but I can already tell it’s helping me a lot. Right now, it kinda feels like I’m trying to play the guitar left-handed.😵‍💫

Question for the devs:
Is there ANY WAY to control an external mouse with the UHK’s mouse acceleration/deceleration keys? That would be the icing on the cake for me.:shortcake: I’m thinking it would have a similar effect as the sniper/DPI changer button on some gaming mice.

If that’s not possible, does anyone know of another way to control mouse speed on-the-fly with a keyboard? Preferably not with AutoHotkey, or anything that would trip anti-cheat stuff. I’m not looking for anything to be super sneaky here; just looking for solutions. I despise being trolled by cheaters just as much as the next guy… :innocent:


2 Likes

s there ANY WAY to control an external mouse with the UHK’s mouse acceleration/deceleration keys? That would be the icing on the cake for me.:shortcake: I’m thinking it would have a similar effect as the sniper/DPI changer button on some gaming mice.

Obviously not a direct one.

Sure you can trigger some shortcut, catch it in your window manager and alter system settings, but I cant tell whether it will work smoothly enough, or if it will work at all.

Dangit. I was afraid that would be your answer.:face_with_diagonal_mouth:
I imagine that would be pretty disruptive for most games.

So another question-
What exactly do Agent’s mouse buttons 6-20 do? They don’t seem to do anything when I assign them to a key in Agent, or when using them in macros. I have a few mice with a bunch of extra buttons, and I thought (naively) that using Agent’s extra mouse button bindings would trigger my non-UHK mouse buttons, or maybe the OS would handle them in some way. Do they have no effect in Windows?

I have no idea. I suppose it ahould be possible to bind them to whatever you like on OS/software side.

Agent’s extra mouse buttons should work like the extra buttons of mice, and applications, including games, should support them alike.

As a casual Doom player, I use a couple of such macros to access my weapon arsenal with half the number of keys than normally needed.

However, it doesn’t work perfectly. When I hold W to move forward in the game and tap the key assigned to the macro, Doomguy still moves forward for about a second even if I release W immediately after tapping the macro key.

1 Like

I tried mapping the mouse 6-20 buttons in a few games, but none of them were recognized. Only scroll, the three main buttons, and back/forward are recognized. So, I guess it’s either borked in the UHK80 FW (I’m on v14.1.0), or maybe Windows just doesn’t recognize more than five mouse buttons without a driver, or whatever?

That seems useful. :slightly_smiling_face: I guess it would be nice to set up quicker ways to select items.


I’d like to create a few macros for games that don’t offer remapping, or have missing common features.

Some examples:

  1. Make a key work normally when held, but toggle when tapped. (e.g., LShift to sprint, or LCtrl to crouch)

  2. Make an auto-walk/sprint macro:
    -When tapped, toggles holding W (forward movement) until either tapped again, and/or also releases when either the W or S key is pressed.

I’d really love to have the above two macro examples, but Idk what I’m doing. I’m macro language illiterate. :sweat_smile: I go cross-eyed trying to read the docs.:face_with_spiral_eyes: If anyone could help with those, I’d appreciate it…

Currently, all reports are cleared when macro exits, which means that you will have to use active waiting.

Something like:

ifHold final holdKey LS
if $running setVar running 0
else {
    pressKey LS
    setVar running 1
    while ($running) delayUntil 10
}

But admittedly this is a recurring usecase and the above is an absurdly hackish way to do it → will implement a better variant → Global macro report states · Issue #1264 · UltimateHackingKeyboard/firmware · GitHub .

1 Like

The only quick and reliable way I can think of to test whether the 6+ UHK mouse buttons are supposed to work is to use a MOBA mouse to compare.

Thanks! I suppose I should use different $running variables per macro, such as $running1, $running2, …, right?

1 Like

Yes.

ifHold final holdKey 1
if $running setVar running 0
else {
    pressKey 5  
    setVar running 1
    while ($running) delayUntil 10
}

Keeps outputting 5 forever upon tapping.

Do you want pressKey or tapKey here?

What are you trying to achieve?

Concratulations! You have found a bug!

2 Likes

Fixed in Fix update of last report when macro ends. by kareltucek · Pull Request #1269 · UltimateHackingKeyboard/firmware · GitHub

1 Like

AAAAAAAHHH!!!
Dangit guys, I just spent most of my night trying to wrap my head around this, and right before I was about to ask why I couldn’t get it working, you go and say there’s a bug! :rofl: :zany_face:

Oh well, I guess I’ll start again tomorrow. I gotta get some sleep now.:sleeping_face: I hope I don’t have Tetris-shaped macro nightmares… :face_with_peeking_eye:

Phil, you know the firmware is falling apart ever since the uhk80 / eventloop refactor :smiley:. Please shoot any questions about any suspicious behavior straight away ;-).

Also, you know, badly written docs, or non-intuitive features are bugs (of documentation or specification) too, and hard to uncover unless people actually complain :sweat_smile:.

2 Likes

I think you underestimate my lack of understanding. :sweat_smile: Just about everything is unintuitive when you’re as derpy as I am. :grimacing:

Well, here’s what I was going to post before I saw the stuff about bugs:

Ok, I had some time to try the new: https://github.com/UltimateHackingKeyboard/firmware/actions/runs/15537557961

I ended up going with a Double-tap to toggle LShift, as it’s less disruptive when trying to type normally. In addition to being a toggle for sprinting in games, it’s also an awesome substitute for combining Shift/CapsLock.:blush:

So here’s what I’m using now; does this look right?:

ifDoubletap toggleKey persistent LS
else holdKey LS

For some reason, that macro seems to be more responsive than the following couple of macros, which have a slight delay when using holdKey LS:

ifHold final holdKey LS
else toggleKey persistent LS

And the same delay with holdKey LS when using Karel’s macro above: Gaming Config (Tips & Tricks?) - #9 by kareltucek

ifHold final holdKey LS
if $runningLS setVar runningLS 0
else {
    pressKey LS
    setVar runningLS 1
    while ($runningLS) delayUntil 10
}

Any insights on what causes the delay on those two, vs the first?

A couple of quirks:
•If LShift is toggled on when performing a reboot, all the above macros have a stuck LShift afterwards (until tapping LShift again).
•All the above macros persist across keymap changes (expected?). Of course, adding setVar runningLS 0 to $onKeymapChange fixes it for Karel’s original macro, but is there a way to fix it for the new toggleKey macros as well?


Anyway, I really gotta go to bed now, but I’ll try to catch up later tonight/tomorrow. :yawning_face:

1 Like

I suspect ifHold.

To determine whether a key is held down, it has to wait for a key release to see how long it has been held. ifDoubleTap on the other hand only reacts on taps, so the presses are relevant, not the releases.

1 Like