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

Generating scroll event from hook #40

Open
callegar opened this issue Jan 14, 2024 · 1 comment
Open

Generating scroll event from hook #40

callegar opened this issue Jan 14, 2024 · 1 comment

Comments

@callegar
Copy link

Hi,
I would like to generate a scroll event while catching a key sequence with a hook. I am trying the following:

--hook key:leftmeta key:d sequential period=0.001 send-key=rel:wheel_hi_res:-120@ms

but the command does not succeed, I get:

While parsing the arguments "--hook key:leftmeta key:d sequential period=0.001 send-key=rel:wheel_hi_res:-120@ms": While parsing the key "rel:wheel_hi_res:-120@ms": Invalid argument: only events of type EV_KEY (i.e. "key:something" or "btn:something") can be specified in this position.

Is there any reason why it is impossible to generate a wheel scroll event here? Or am I doing something wrong in trying to generate it?

@KarsMulder
Copy link
Owner

KarsMulder commented Jan 14, 2024

The reason that send-key requires an EV_KEY type event is because send-key sends two events: a key_down and a key_up event. This makes sense when working with EV_KEY-type events because any other approach would likely lead to some key getting stuck in the down position. It does not make sense for other types of events.

In the latest version of the main branch (commit 53d410a) I added another send-event clause which sends just one event when the hook activates:

    --hook key:leftmeta key:d sequential period=0.001 send-event=rel:wheel_hi_res:-120@ms

Design questions left:
Is send-event the right name for this new clause? Other options would be send, on-press or on-activate.

Do we need another clause that sends events when the hook is released (e.g. in the above example, when you release either the Ctrl or the D key after activating the hook?) If yes, what should its name be?

If we were to add a clause (e.g. send-event-on-release) that sends event when the hook is released, how would its order interact with the other send-key clauses? The send-key clauses press their keys in the order they're specified, and release them in the reverse order (i.e. the last key to be pressed is the first to be released). The send-event clauses follow the same order as the send-key clauses:

evsieve --input /dev/input/by-id/keyboard \
        --hook key:leftctrl key:a send-key=key:b send-event=rel:x:1 send-key=key:c send-event=rel:y:1 \
        --print
        
Event:  type:code = key:leftctrl   value = 1 (down)
Event:  type:code = key:a          value = 1 (down)
Event:  type:code = key:b          value = 1 (down)
Event:  type:code = rel:x          value = 1
Event:  type:code = key:c          value = 1 (down)
Event:  type:code = rel:y          value = 1
Event:  type:code = key:c          value = 0 (up)
Event:  type:code = key:b          value = 0 (up)
Event:  type:code = key:a          value = 0 (up)
Event:  type:code = key:leftctrl   value = 0 (up)

Now suppose that in the above example send-event were to be changed into send-event-on-release, in what order would the above events appear?

If send-event-on-release were to be interleaved with send-key, then they would have to send their events in the reverse order that they're specified, which would be quite confusing if there were no other send-key clauses present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants