forked from gvalkov/python-evdev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfftest-uinput-test.py
More file actions
executable file
·43 lines (34 loc) · 927 Bytes
/
fftest-uinput-test.py
File metadata and controls
executable file
·43 lines (34 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
evdev example - uinput force feedback event monitor
'''
from __future__ import print_function
import time, sys, select
from evdev import UInput, UInputError, ecodes
cap = {
ecodes.EV_FF: [
ecodes.FF_CONSTANT,
ecodes.FF_PERIODIC,
ecodes.FF_RAMP,
ecodes.FF_SPRING,
ecodes.FF_FRICTION,
ecodes.FF_DAMPER,
# ecodes.FF_RUMBLE,
ecodes.FF_INERTIA,
]
}
def ffcb(event):
import ipdb ; ipdb.set_trace()
print(event)
ui = UInput(cap, ff_effects_max=10, ff_callback=ffcb)
try:
print('uinput device created - run "fftest %s" to test' % ui.device.fn)
except AttributeError:
print('error: could not find corresponding /dev/input/eventXX device - check permissions')
sys.exit(1)
print('waiting for events:')
while True:
r, w, x = select.select([ui.fd], [], [])
if r:
ui.read()