panzi/qjoypad

[Feature Request] Change Mouse Speed based on another Button

dginovker opened this issue · 2 comments

When trying to control the mouse pointer via some joysticks, accurate precision is almost impossible. One solution is the speed could being decreased while a key is held down.

Because QJoyPad calls xtestfakerelativemotionevent, it's not possible to manually decrease pointer speed via hotkeys through other applications to achieve this effect, since decreasing pointer speed has no effect on xtestfakerelativemotionevent.

From the code:

//signal handler for SIGUSR2
//SIGUSR2 means that a new layout should be loaded. It is saved in
// ~/.qjoypad/layout, where the last used layout is put.
void catchSIGUSR2( int sig ) {
    if (layoutManagerPtr) layoutManagerPtr->load();
    //remember to catch this signal again next time.
    signal( sig, catchSIGUSR2 );
}

If I can swap out the default configuration file on the fly with another identical one but lower mouse sensitivity, I can reload it with kill -USR2 $(pgrep qjoypad). Maybe I can do something with that

Got a workaround if anyone is curious:

  • I've got a KDE shortcut that makes F12 call a script decreasespeed.sh
  • One of my controller buttons maps to F12
  • decreasespeed.sh contents:
#! /bin/bash

cd $HOME/.config/qjoypad4 # depends on https://github.com/panzi/qjoypad/pull/50

cp "My Layout.lyt" temp
cp "My Layout 2.lyt" "My Layout.lyt"
cp temp "My Layout 2.lyt"

kill -USR2 $(pgrep qjoypad)                                 

My Layout.lyt and My Layout 2.lyt are identical except for the maxSpeed on their Axis 1 and 2