Last active
October 24, 2021 04:14
-
-
Save versusvoid/e3c30e75c91354fb4d8cb1734490ad76 to your computer and use it in GitHub Desktop.
Revisions
-
versusvoid revised this gist
Oct 24, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # installed in /etc/udev/hwdb.d/ # after installing run # $ sudo udevadm hwdb --update # $ sudo udevadm control --reload -
versusvoid created this gist
May 10, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # installed in /lib/udev/hwdb.d/ # after installing run # $ sudo udevadm hwdb --update # $ sudo udevadm control --reload # Microsoft Natural Ergonomic Keyboard 4000 evdev:input:b0003v045Ep00DB* KEYBOARD_KEY_c022d=scrollup # zoomin KEYBOARD_KEY_c022e=scrolldown # zoomout This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env python3 # start as root (I run as systemd service) # or from group with access to input devices import sys import glob # python-libevdev package on ArchLinux import libevdev for f in glob.glob('/dev/input/event*'): f = open(f, 'rb') d = libevdev.Device(f) if 'Microsoft Natural' in d.name and d.has(libevdev.EV_REL.REL_HWHEEL): break f.close() else: print("Can't find Microsoft Natural device with wheel event") sys.exit(1) fake_mouse = libevdev.Device() fake_mouse.name = 'fake mouse' fake_mouse.enable(libevdev.EV_REL.REL_WHEEL) uinput = fake_mouse.create_uinput_device() for e in d.events(): fake_events = [] if e.matches(libevdev.EV_KEY.KEY_SCROLLUP) and e.value in (1, 2): fake_events.append(libevdev.InputEvent(libevdev.EV_REL.REL_WHEEL, value=1)) if e.matches(libevdev.EV_KEY.KEY_SCROLLDOWN) and e.value in (1, 2): fake_events.append(libevdev.InputEvent(libevdev.EV_REL.REL_WHEEL, value=-1)) if fake_events: fake_events.append(libevdev.InputEvent(libevdev.EV_SYN.SYN_REPORT, value=0)) uinput.send_events(fake_events)