kareltucek / firmware

This is fork of UHK's firmware featuring extended macro engine.
Other
82 stars 9 forks source link

interrupting running macro #44

Closed bistabil closed 4 years ago

bistabil commented 4 years ago

Is this possible? Since macros are executed asynchronously is there any way to stop them? My use case is following: I want to repeat some keystrokes indefinitely or until I interrupt it manually. So far I've managed to repeat keystrokes indefinitely by reseting register's state. Actually I can interrupt it by powering off the keyboard but that's only way I've found.

kareltucek commented 4 years ago

So far I've managed to repeat keystrokes indefinitely by reseting register's state.

I don't understand this, would you clarify?

Regular way would be to use $goTo E.g.

$tapKey a
$tapKey b
$goTo 0

Since macros are executed asynchronously is there any way to stop them?

Yes, you can signal using a register.

E.g. InterruptionKey:

$setReg 5 1 

Macro:

$setReg 5 0
$tapKey a
$tapKey b
$ifRegEq 5 1 break
$goTo 1

Also, there is a set of diagnostic commands which reset the keyboard state including hard interrupt of all running macros. But you do not want to use that.

bistabil commented 4 years ago

I will test this today. So if I understood it, registers are not "created" for different instances of macros? I didn't expected this to be the case as macros themselves can run in parallel so I assumed that these registers would be created for each macro instance.

kareltucek commented 4 years ago

Correct. "registers" are simply global variables.

kareltucek commented 4 years ago

Also, thinking about it again, the shortest variant is probably to use the conditional for modifiers. This variant would not need any signaling via registers...

E.g.:

$tapKey a
$tapKey b
$ifAnyMod break
$goTo 0
bistabil commented 4 years ago

And how about longer action sequences? Let's say that there are a lot of actions before $ifAnyMod break - commands such as delays and mouse movements. Is there another way to stop it other than using $ifAnyMod break after every action?

kareltucek commented 4 years ago

There is diagnose, which will however do more than that and should not be used as a regular way.

But I think I can add a new command like stopAllMacros. However, it might have to wait until situation around secondary roles is resolved.

kareltucek commented 4 years ago

Done.

Could you please test that it works as expected?

bistabil commented 4 years ago

I've tested it while I was running a single macro and it worked!

kareltucek commented 4 years ago

Thanks!

kareltucek commented 4 years ago

So I guess this can be closed. (Ofc., feel free to follow up.)