本文整理汇总了Python中evdev.UInput方法的典型用法代码示例。如果您正苦于以下问题:Python evdev.UInput方法的具体用法?Python evdev.UInput怎么用?Python evdev.UInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evdev
的用法示例。
在下文中一共展示了evdev.UInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import evdev [as 别名]
# 或者: from evdev import UInput [as 别名]
def __init__(self, can_id):
self.can_id = can_id
axis_cap = AbsInfo(-32700,32700,0,0,0,0)
self._ev = UInput(name='vjoy',
events={
ecodes.EV_ABS: [
(ecodes.ABS_X, axis_cap),
(ecodes.ABS_Y, axis_cap),
(ecodes.ABS_Z, axis_cap)
],
ecodes.EV_KEY: [
ecodes.BTN_TRIGGER,
ecodes.BTN_TOP,
ecodes.BTN_TOP2
]
}
)
示例2: register_device
# 需要导入模块: import evdev [as 别名]
# 或者: from evdev import UInput [as 别名]
def register_device(device):
for value in registered_devices.values():
if device == value['device']:
return value['future']
input = find_input(device)
if input is None:
return None
input.grab()
caps = input.capabilities()
# EV_SYN is automatically added to uinput devices
del caps[ecodes.EV_SYN]
remappings = device['remappings']
extended = set(caps[ecodes.EV_KEY])
modifier_groups = []
if 'modifier_groups' in device:
modifier_groups = device['modifier_groups']
def flatmap(lst):
return [l2 for l1 in lst for l2 in l1]
for remapping in flatmap(remappings.values()):
if 'code' in remapping:
extended.update([remapping['code']])
for group in modifier_groups:
for remapping in flatmap(modifier_groups[group].values()):
if 'code' in remapping:
extended.update([remapping['code']])
caps[ecodes.EV_KEY] = list(extended)
output = UInput(caps, name=device['output_name'])
print('Registered: %s, %s, %s' % (input.name, input.path, input.phys), flush=True)
future = asyncio.ensure_future(
handle_events(input, output, remappings, modifier_groups))
registered_devices[input.path] = {
'future': future,
'device': device,
}
return future