我希望使用python evdev向设备发送隆隆效果。
这应该通过upload_effect()
函数来实现,该函数需要缓冲区对象作为输入。
这是capabilities()
揭示的内容:
('EV_FF', 21L): [
(['FF_EFFECT_MIN', 'FF_RUMBLE'], 80L),
('FF_PERIODIC', 81L),
(['FF_SQUARE', 'FF_WAVEFORM_MIN'], 88L),
('FF_TRIANGLE', 89L),
('FF_SINE', 90L),
('FF_GAIN', 96L),
],
如何创建缓冲区?
答案 0 :(得分:1)
Python-evdev 1.1.0支持强制反馈效果上传。这是文档中的示例:
from evdev import ecodes, InputDevice, ff
# Find first EV_FF capable event device (that we have permissions to use).
for name in evdev.list_devices():
dev = InputDevice(name)
if ecodes.EV_FF in dev.capabilities():
break
rumble = ff.Rumble(strong_magnitude=0x0000, weak_magnitude=0xffff)
effect_type = ff.EffectType(ff_rumble_effect=rumble)
duration_ms = 1000
effect = ff.Effect(
ecodes.FF_RUMBLE, -1, 0,
ff.Trigger(0, 0),
ff.Replay(duration_ms, 0),
ff.EffectType(ff_rumble_effect=rumble)
)
repeat_count = 1
effect_id = dev.upload_effect(effect)
dev.write(e.EV_FF, effect_id, repeat_count)
dev.erase_effect(effect_id)