kermitfrog / inputmangler

Inputmangler is a daemon that intercepts and transforms linux input events, depending on the active window. It aims to be highly configurable, reliable and not too hard to use. You can use it to remap those extra mouse buttons, properly utilize a footswitch or even remap your second keyboard to trigger all kinds of shortcuts! If you are left-handed, you can switch left and right mouse buttons for applications that ignore your Desktops settings (like dosbox and fs-uae). And you can have a different configuration for each window! It is also capable of translating Text from the network to key presses.
Other
5 stars 1 forks source link

Is it possible to use it to debounce a worn-out mouse switches? #1

Closed trappedinspacetime closed 7 years ago

trappedinspacetime commented 7 years ago

First of all congrats on your project, it looks promising.

I wonder if I can use it to fix my faulty mouse. In Windows I use an Autohotkey script , which is very efficient to debounce my mouse. I post the algorithm here in case it gives an idea:

 LButton::  ;sets the left button as a hotkey and intercepts the functions of the left button switch events 
    If (A_TimeSincePriorHotkey < 150) ;A_TimeSincePriorHotkey is a built-in variable it counts the time between two clicks  
       Return ;if the elapsed time is less than 150ms then it`s a hyperclick and ignore the clicks
    Click Down ; if it gets decent events which lasts longer than 150ms, it simulates a click down event
    KeyWait, LButton ; waits for another left button press 
    Click Up ; finishes up a decent click
 Return

May your code can be used for that purpose?

Regards. Kenn

kermitfrog commented 7 years ago

Thanks! :)

Debouncing isn't possible yet, but i was planning to implement tracking the state of keys/buttons anyway. Once that's done, it should be easy to grant your wish - can't say when that will be though. I expect something between a few days and the end of January.

Just to make sure, i understand the Algorithm: KeyWait, LButton ; waits for an press or release, which in this case should be a release, right?

trappedinspacetime commented 7 years ago

Thank you for responding. It can be any left button event, either a button up or button down.
Once upon a time I studied Autohotkey scripts a bit. It's easy to use, you can try it, here is the download link: https://autohotkey.com/download/ahk-install.exe After you install it in Windows open notepad and try this :)

    RButton::

save it with blok_rclick.ahk extension and run it. It blocks your right button completely. To quit it: double click H icon in systray and exit from menu item. You can remap any key like

  h::b
trappedinspacetime commented 7 years ago

by the way I forgot to mention Click Up sends left click button up event.

kermitfrog commented 7 years ago

Ok... the current version here should do it :) There are some not yet documented changes in the conf format, but the following minimal config.xml should do the trick. just insert your mouses vendor and product values.

<?xml version="1.0" encoding="UTF-8"?>
<inputmanglerConf configVersion="2">
        <handlers>
                <device name="Mouse" vendor="" product="" id="M">
                        <signal key="BTN_LEFT" default="~D(BTN_LEFT, 150~)" />
                </device>
        </handlers>
</inputmanglerConf>

Can you test it and tell me if it works like you expected?

trappedinspacetime commented 7 years ago

Hi, thank you for quick fix. I am on Ubuntu 14.04.5 i386 platform. I did a debian compilation like debuild -i -us -uc -b, compilation passed successfully but when I try to install it, I get inputdummy-dkms dependency error.

trappedinspacetime commented 7 years ago

I'm sorry, it's my ignorance, I just noticed inputdummy directory in cloned repo, I just compiled the driver.

trappedinspacetime commented 7 years ago

By the way, when I attempted to compile inputdummy in its directory with debuild -i -us -uc -b my compiler fails

   Makefile:614: Cannot use CONFIG_CC_STACKPROTECTOR: -fstack-protector not supported by compiler

I don't know how to suppress it.

kermitfrog commented 7 years ago

Hm.. i don't remember ever having that problem... Have you tried the package? https://tarbos.adhara.uberspace.de/pub/inputmangler/ubuntu/14.04/inputdummy-dkms_1.1_all.deb

trappedinspacetime commented 7 years ago

Thank you again. I did

 mkdir -p ~/.config/inputMangler/

and put the config.xml with the content you posted above. I ll test it tomorrow I hope, because I need to get back faulty mouse from my brother :)

kermitfrog commented 7 years ago

You're welcome :)

mkdir -p ~/.config/inputMangler/

So far i assumed that you executed the setupHelper.sh script to set up your configuration directory. If you haven't, you should do so, as inputmangler won't know what BTN_LEFT means without at least the keymap file in its config dir.

trappedinspacetime commented 7 years ago

Good afternoon,

I am sorry I am late at feedback. You know, on the way to a dentist your toothache relieves, the same happened to me, when I inserted my faulty old mouse it began to run smoothly, I thought your driver fixed the debouncing but I had not added mouse verdor and product ids, so as to make sure, I tried another died mouse but in that case hyperclicks occured again though I added mouse verdor and product ids into config.xml. When I lost my hope, I noticed that the last plugged mouse was not in the list in /etc/udev/rules.d/80-inputmangler.rules, so I had to reinstall inputmangler. I need to test it a while in order to make sure if it works.

By the way, does your driver act on top of mouse driver? I don't know how it works.

kermitfrog commented 7 years ago

No problem - i know what you mean^^ I'll be gone from tomorrow until Wednesday, so take your time.

By the way, does your driver act on top of mouse driver? I don't know how it works.

Not exactly on top.. The driver creates 4 virtual input devices (keyboard, mouse, tablet, joystick - in /dev/input/) and 4 device files (/dev/virtual*) which inputmangler can write to. Then inputmangler grabs your configured devices (so no output is sent to other applications), processes everything coming from them and sends new events to the driver via the appropriate /dev/virtual device. These events are then generated by the kernel on the corresponding virtual input device and read by Xorg, your tty or whatever. This approach is unfortunately a bit tricky to set up (i'm working on a first run wizard to help with this), but in my experience a lot more reliable than other applications like gizmod.