input-remapper icon indicating copy to clipboard operation
input-remapper copied to clipboard

`while_single` macro or `ignore_release` parameter

Open supertriodo opened this issue 3 years ago • 14 comments

Is it possible to map a key single press(not hold) to continuously press right click, until I press another key?

supertriodo avatar Apr 28 '22 10:04 supertriodo

Not yet. But there is a feature request for that already: https://github.com/sezanzeb/input-remapper/issues/378

jonasBoss avatar Apr 29 '22 12:04 jonasBoss

I'll close this since it's a duplicate

sezanzeb avatar Apr 30 '22 09:04 sezanzeb

I just learned that there is also a macro solution for that:

if_eq(
    $a,
    1,
    event(EV_KEY, BTN_RIGHT, 0).set(a, 0),
    event(EV_KEY, BTN_RIGHT, 1).set(a, 1)
)

jonasBoss avatar Apr 30 '22 11:04 jonasBoss

as far as I can tell this issue is about pressing repeatedly until any other key is pressed

sezanzeb avatar Apr 30 '22 12:04 sezanzeb

as far as I can tell this issue is about pressing repeatedly until any other key is pressed

Not really, what I want is to let the right click down.

supertriodo avatar May 02 '22 16:05 supertriodo

so you want to have the right click pressed, until any other key is pressed

  • you click the left button once
  • it keeps holding down
  • you hit, for example, the middle mouse button
  • left button is released

?

sezanzeb avatar May 02 '22 17:05 sezanzeb

Yes

supertriodo avatar May 02 '22 17:05 supertriodo

I don't think this is possible right now.

If there was a while_eq macro maybe it would be possible to write something that continuously calls if_single to wait for another key press, which then sets a variable that stops while_eq. I wonder how well that would work, if a key is pressed between if_single calls it wouldn't work.

Or while_single of course, I guess that could be implemented. I'm not sure yet if that would work the way I think it would though. What would while_single do if the key is released

I'll rename this issue and add a feature-request label to keep track of the while_single idea

sezanzeb avatar May 03 '22 09:05 sezanzeb

if_single runs then when the key is released, or else when another key is pressed.

I think the potential future while_single macro would repeat a provided macro-parameter until another key is pressed or the key is released. To ignore the release, it would need an ignore_release parameter. The macro-parameter would just be something like wait(10) or something which makes it block for a while.

however, if_single could also receive a new ignore_release parameter and by doing so it would just block forever until another key is pressed. Arguably, blocking until an event arrives is better than looping and polling.

sezanzeb avatar May 03 '22 16:05 sezanzeb

This works already, but only if the "another key" is one of your mouse keys.

key_down(BTN_RIGHT).
# wait until key released
if_single(
        # released
        # wait for another key press
        if_single(None, None),
        # other key pressed before the release, just continue
        None
).
key_up(BTN_RIGHT)

Edit: updated with new key_down, key_up macros and None

and don't forget to set the dropdown to "Mouse"

sezanzeb avatar May 03 '22 16:05 sezanzeb

I think this issue (#382), #198 and #378 can all be solved with the mechanism I proposed in this https://github.com/sezanzeb/input-remapper/issues/378#issuecomment-1105156174

@sezanzeb It should also be simple to implement, so maybe a good candidate to work on the new injection system.

jonasBoss avatar May 04 '22 19:05 jonasBoss

My problem was solved with your solution

supertriodo avatar May 04 '22 19:05 supertriodo

I think this issue (#382), #198 and #378 can all be solved with the mechanism I proposed in this #378 (comment)

Maybe we do both. How would you propose to allow the user to enable the mapping handler?

sezanzeb avatar May 04 '22 21:05 sezanzeb

we can have a mapping parameter for that. Maybe call it input_mode with an default value of normal and for the new handler we can set it to toggle

jonasBoss avatar May 06 '22 12:05 jonasBoss