本文整理汇总了Python中Event.attach方法的典型用法代码示例。如果您正苦于以下问题:Python Event.attach方法的具体用法?Python Event.attach怎么用?Python Event.attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event.attach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Event [as 别名]
# 或者: from Event import attach [as 别名]
def __init__(self, filename):
self.filename = filename
self.fd = os.open(filename, os.O_RDWR | os.O_NONBLOCK)
Controller.__init__(self, LinuxInput.iocGetName(self.fd))
Event.attach(self, "onDisconnect")
# Store all the bitfields in a dictionary of lists
self.evdevBits = {}
for name in LinuxInput.iocGetBitNames(self.fd, None):
try:
self.evdevBits[name] = LinuxInput.iocGetBitNames(self.fd, name)
except KeyError:
pass
# Store info on each absolute axis
self.absAxisInfo = {}
for name in self.evdevBits['EV_ABS']:
self.absAxisInfo[name] = LinuxInput.iocGetAbs(self.fd, name)
# Create actuators
for bitName, cls in (
('EV_ABS', Axis),
('EV_REL', Axis),
('EV_KEY', Button),
):
if bitName in self.evdevBits:
for itemName in self.evdevBits[bitName]:
self.addActuator(cls(itemName))
# Join pairs of axes into joysticks where appropriate
for jsName, axisPrefix in (
('JS_ABS', 'ABS_'),
('JS_ABS_RIGHT', 'ABS_R'),
('JS_ABS_HAT0', 'ABS_HAT0'),
('JS_ABS_HAT1', 'ABS_HAT1'),
('JS_ABS_HAT2', 'ABS_HAT2'),
('JS_ABS_HAT3', 'ABS_HAT3'),
('JS_REL', 'REL_'),
):
x, y = axisPrefix + 'X', axisPrefix + 'Y'
if x in self.actuators and y in self.actuators:
self.addActuator(Joystick(jsName, self.actuators[x], self.actuators[y]))