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

will this work with Multi-pointers? #35

Open
leleleSDX opened this issue Jul 16, 2023 · 2 comments
Open

will this work with Multi-pointers? #35

leleleSDX opened this issue Jul 16, 2023 · 2 comments

Comments

@leleleSDX
Copy link

Xorg servers starting from version 1.7 have a feature called "multi-pointer". Basically it allows to have multiple mouse cursors (each with its own keyboard focus) on the screen and control them with separate physical input devices.

Multi-Pointer X on ArchWiki

  • can you capture the kbd's numpad to output it to a second mouse pointer?
  • can you use this to make a gamepad control two on-screen mice? each stick controls it's own cursor.
  • will this work with steaminput/steamdeck? imagine using two mice to play an rts or arpg
@KarsMulder
Copy link
Owner

As for the first question, I suppose it can work by mapping the key-down and key-repeat events to EV_REL events that move your mouse. Of particular interest here is the --output name=... clause that allows you to give your output devices a name that xinput recognises. The following script could turn a keyboard into a mouse:

        --map key:up:1~    rel:y:-20 \
        --map key:down:1~  rel:y:20  \
        --map key:left:1~  rel:x:-20 \
        --map key:right:1~ rel:x:20  \
        --output rel name=fancy-mouse

... at least, that is what was supposed to work, but it turns out that some part of the xinput stack refuses to recognize something as a mouse unless it supports rel:x, rel:y and rel:hwheel. My keyboard apparently has a scrolling wheel which mad the above work for me, but it may not work for others unless you map another key to the scrolling wheel.

evsieve --input /dev/input/by-id/keyboard \
        --map key:up:1~    rel:y:-20 \
        --map key:down:1~  rel:y:20  \
        --map key:left:1~  rel:x:-20 \
        --map key:right:1~ rel:x:20  \
        --map key:pageup:1~    rel:hwheel:1 \
        --map key:pagedown:1~  rel:hwheel:-1 \
        --output  name=fancy-mouse

Assuming that you can create something xinput recognises as a mouse, you can then assign it its own pointer using the following xinput commands:

xinput create-master "Fancy"
xinput reattach pointer:fancy-mouse "Fancy pointer"

I was further investigating the possibility of mapping a gamepad to a mouse, but then I ran into the above issue of needing to get a scrolling wheel from somewhere, and another issue that my the rate at which my gamepad emits events reporting the state of the sticks is inconsistent (lots of events if you move the stick a lot, zero events if you keep the stick at a stationary position).

Which means that a script that smoothly maps sticks to mice is probably not going to happen until I add some way to smooth out the rate of event reporting.

(Below is the script I was working on for the stick-to-mice map. It suffers from both of the aforementioned issues.)

evsieve --input /dev/input/by-id/usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick \
        --map abs:x rel:x@mouse1 \
        --map abs:y rel:y@mouse1 \
        --map abs:rx rel:x@mouse2 \
        --map abs:ry rel:y@mouse2 \
        `# Multiply the value of all EV_REL events by 0.25 and subtract 32.` \
        `# These values were designed for a controller that outputs values in the range 0~255 with value 127 being the rest stand.` \
        --map rel ::0.25x-32 \
        `# Remove small movements to avoid jitter.` \
        --block rel::-2~2 \
        --output @mouse1 name=first-mouse \
        --output @mouse2 name=second-mouse 

@leleleSDX
Copy link
Author

thanks for the sample scripts. i will try it further on my end to see what works.

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