I play a lot of shmups, and one thing that has always bothered me about a lot of the older titles is that you’re literally holding down the fire key for essentially the entire run. I was thinking about making a macro that would hold down a key only while that key isnt being pressed. As in, the fire key is held down until i press it, and while im holding it, the macro releases that key until i let go of it. This would produce the behavior of firing continuously, and pressing the fire key to briefly stop firing.
I looked over the documentation for the macro scripting language but couldn’t find a good way to do this. Anyone have any ideas?
Hmm, I think this could work (not tested):
setVar keyReleased 1
delayUntilRelease
setVar keyReleased 0
pressKey a
while (!$keyReleased) delayUntil 10
2 Likes
And of course, another macro to activate and deactivate it (assuming that the previous macro is called flippedA
:
setVar keyFlipped !$keyFlipped
if ($keyFlipped) {
// map the a key to the flippedA macro
set keymapAction.base.a macro flippedA
// activate the macro immediately, instead of waiting for next a press
exec flippedA
}
else {
// map the key to regular a
set keymapAction.base.a keypress a
// deactivate all running instances of flippedA
setVar keyReleased 1
}
And you will probably want to initialize them in your $onInit
:
setVar keyFlipped 0
setVar keyReleased 0
(For more info see firmware/doc-dev/user-guide.md at master · UltimateHackingKeyboard/firmware · GitHub and firmware/doc-dev/reference-manual.md at master · UltimateHackingKeyboard/firmware · GitHub if you have not already.)
1 Like
This is interesting. I might give it a shot (pun intended) next time I play a shmup…
This worked pretty well. I couldn’t get the fire-key to work very well outside of the autofire state, so I ended up making a couple changes:
$onInit:
setVar zReleased 1
setter macro:
setVar zReleased !$zReleased
if (!$zReleased) exec th-autofire
autofire macro:
setVar zReleased !$zReleased
if ($zReleased) {
delayUntilRelease
setVar zReleased !$zReleased
pressKey z
while (!$zReleased) delayUntil 10
}
else {
setVar zReleased !$zReleased
holdKey z
}
and this properly makes it work like a normal key when the autofire script isn’t running. Thanks for the idea, this helps a lot
1 Like