Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

while_single macro or ignore_release parameter #382

Open
supertriodo opened this issue Apr 28, 2022 · 14 comments
Open

while_single macro or ignore_release parameter #382

supertriodo opened this issue Apr 28, 2022 · 14 comments

Comments

@supertriodo
Copy link

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

@jonasBoss
Copy link
Collaborator

Not yet. But there is a feature request for that already:
#378

@sezanzeb
Copy link
Owner

I'll close this since it's a duplicate

@jonasBoss
Copy link
Collaborator

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)
)

@sezanzeb
Copy link
Owner

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

@supertriodo
Copy link
Author

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.

@sezanzeb
Copy link
Owner

sezanzeb commented May 2, 2022

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

?

@supertriodo
Copy link
Author

Yes

@sezanzeb
Copy link
Owner

sezanzeb commented May 3, 2022

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 sezanzeb changed the title Bind to righ click infinite hold while_single macro May 3, 2022
@sezanzeb sezanzeb reopened this May 3, 2022
@sezanzeb
Copy link
Owner

sezanzeb commented May 3, 2022

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
Copy link
Owner

sezanzeb commented May 3, 2022

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 sezanzeb changed the title while_single macro while_single macro or ignore_release parameter May 3, 2022
@jonasBoss
Copy link
Collaborator

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

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

@supertriodo
Copy link
Author

My problem was solved with your solution

@sezanzeb
Copy link
Owner

sezanzeb commented May 4, 2022

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?

@jonasBoss
Copy link
Collaborator

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

This was referenced May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants