Mercurial > code > home > repos > wheel
view usb_wheel_to_scroll.py @ 0:63a872056503 default tip
start
author | drewp@bigasterisk.com |
---|---|
date | Sat, 25 Feb 2023 15:29:18 -0800 |
parents | |
children |
line wrap: on
line source
from pynput.mouse import Button, Controller import evdev # to stop knob from setting volume: # xinput list # ↳ HID 8808:660c Keyboard id=17 [slave keyboard (3)] # xinput disable 17 devices = [evdev.InputDevice(path) for path in evdev.list_devices()] for device in devices: if device.name == 'HID 8808:660c Keyboard': break else: raise ValueError('not found') device = evdev.InputDevice(device.path) mouse = Controller() scroll_per_step = 2 for event in device.read_loop(): if event.value == 1: if event.code == 114: mouse.scroll(0, 1 * scroll_per_step) elif event.code == 115: mouse.scroll(0, -1 * scroll_per_step)