def __init__(self, keyboardHandler=None, mouseHandler=None, joystickHandler=None, synHandler=None, unhandledHandler=None, wantKeyboard=True, wantMouse=True, wantJoystick=True): self.unhandledHandler = unhandledHandler self.streams = [] if wantKeyboard: keyboards = find_devices("kbd") for x in keyboards: self.streams.append(EventStream(x, "keyboard")) else: keyboards = [] print("keyboards =", keyboards) if wantMouse: mice = find_devices("mouse", butNot=keyboards) for x in mice: self.streams.append(EventStream(x, "mouse")) print("mice = ", mice) else: mice = [] if wantJoystick: joysticks = find_devices("js", butNot=keyboards + mice) for x in joysticks: self.streams.append(EventStream(x, "joystick")) print("joysticks =", joysticks) for x in self.streams: x.acquire_abs_info() self.handler = EventHandler.EventHandler(keyboardHandler, mouseHandler, joystickHandler, synHandler)
def __init__(self, keyboardHandler=None, mouseHandler=None, joystickHandler=None, synHandler=None, unhandledHandler=None, wantKeyboard=True, wantMouse=True, wantJoystick=True): self.unhandledHandler = unhandledHandler self.streams = [ ] if wantKeyboard: keyboards = find_devices("kbd") self.streams += map(lambda x: EventStream(x, "keyboard"),keyboards) else: keyboards = [ ] print "keyboards =", keyboards if wantMouse: mice = find_devices("mouse", butNot=keyboards) print "mice = ", mice self.streams += map(lambda x: EventStream(x, "mouse"), mice) else: mice = [ ] if wantJoystick: joysticks = find_devices("js", butNot=keyboards+mice) print "joysticks =", joysticks js_streams = map(lambda x: EventStream(x, "joystick"), joysticks) self.streams += js_streams for x in self.streams: x.acquire_abs_info() self.handler = EventHandler.EventHandler( keyboardHandler, mouseHandler, joystickHandler, synHandler)