本文整理匯總了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]))