Code Monkey home page Code Monkey logo

Comments (2)

KarsMulder avatar KarsMulder commented on June 12, 2024

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 

from evsieve.

leleleSDX avatar leleleSDX commented on June 12, 2024

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

from evsieve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.