本文整理汇总了Python中evdev.UInput.from_device方法的典型用法代码示例。如果您正苦于以下问题:Python UInput.from_device方法的具体用法?Python UInput.from_device怎么用?Python UInput.from_device使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evdev.UInput
的用法示例。
在下文中一共展示了UInput.from_device方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from evdev import UInput [as 别名]
# 或者: from evdev.UInput import from_device [as 别名]
e.KEY_5: e.KEY_F5,
e.KEY_6: e.KEY_F6,
e.KEY_7: e.KEY_F7,
e.KEY_8: e.KEY_F8,
e.KEY_9: e.KEY_F9,
e.KEY_0: e.KEY_F10,
e.KEY_MINUS: e.KEY_F11,
e.KEY_EQUAL: e.KEY_F12,
e.KEY_BACKSPACE: e.KEY_DELETE,
}
# The names can be found with evtest or in evdev docs.
esc = False
intercepted = False
# Create a new keyboard mimicking the original one.
with UInput.from_device(kbd, name='kbdremap') as ui:
for ev in kbd.read_loop(): # Read events from original keyboard.
if ev.type == e.EV_KEY: # Process key events.
# ke = evdev.categorize(ev)
act = kbd.active_keys()
# print(act)
# print(ev.value)
if e.KEY_ESC in act:
esc = True
for k, v in REMAP_TABLE.items():
if k in act:
intercepted = True
ui.write(e.EV_KEY, v, 1)
ui.write(e.EV_KEY, v, 0)
ui.syn()
elif esc and not intercepted: