Example #1
0
    def register_handlers(self, profiles, wnd):
        keyboard = util.Keyboard()
        mouse = Mouse()

        def _create_handler(name, maps, options):
            mappings = util.resolve_mappings(maps)

            if name == "default":
                return Handler(mappings, keyboard, mouse)

            __import__("sc_desktop.handlers", fromlist=[name.encode("latin-1")])
            mod = getattr(sc_desktop.handlers, name)
            logging.info('handler "{}" created'.format(name))
            return mod.Handler(
                mappings, keyboard, mouse, wnd=wnd, haptic_fb=self.sc_thread.haptic_feedback_pad, **options
            )

        for name, profile in profiles.items():
            handler_config = profile["handler"]
            if isinstance(handler_config, basestring):
                handler = _create_handler(handler_config, profile["maps"], profile["options"])
            else:
                mappings = util.resolve_mappings(profile["maps"])
                handler = HandlerAggregate(mappings, keyboard, mouse)
                for typ, sub_handler_config in handler_config.items():
                    methods = {
                        "pad_left": ["pad_touch_left", "first_pad_touch_left"],
                        "pad_right": ["pad_touch_right", "first_pad_touch_right"],
                    }.get(typ, [typ])
                    h = _create_handler(
                        sub_handler_config["handler"], profile["maps"], sub_handler_config.get("options", {})
                    )
                    handler.register_handler(methods, h)
            self.register(name, handler)
Example #2
0
        def _create_handler(name, maps, options):
            mappings = util.resolve_mappings(maps)

            if name == "default":
                return Handler(mappings, keyboard, mouse)

            __import__("sc_desktop.handlers", fromlist=[name.encode("latin-1")])
            mod = getattr(sc_desktop.handlers, name)
            logging.info('handler "{}" created'.format(name))
            return mod.Handler(
                mappings, keyboard, mouse, wnd=wnd, haptic_fb=self.sc_thread.haptic_feedback_pad, **options
            )