comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:63a872056503
1 from pynput.mouse import Button, Controller
2 import evdev
3
4 # to stop knob from setting volume:
5
6 # xinput list
7 # ↳ HID 8808:660c Keyboard id=17 [slave keyboard (3)]
8
9 # xinput disable 17
10
11 devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
12 for device in devices:
13 if device.name == 'HID 8808:660c Keyboard':
14 break
15 else:
16 raise ValueError('not found')
17
18 device = evdev.InputDevice(device.path)
19 mouse = Controller()
20
21 scroll_per_step = 2
22
23 for event in device.read_loop():
24 if event.value == 1:
25 if event.code == 114:
26 mouse.scroll(0, 1 * scroll_per_step)
27 elif event.code == 115:
28 mouse.scroll(0, -1 * scroll_per_step)