当前位置: 首页>>代码示例>>Python>>正文


Python Thread.controller方法代码示例

本文整理汇总了Python中threading.Thread.controller方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.controller方法的具体用法?Python Thread.controller怎么用?Python Thread.controller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading.Thread的用法示例。


在下文中一共展示了Thread.controller方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_controller_thread

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import controller [as 别名]
def create_controller_thread(index, controller_options, dynamic=False):
    controller = DS4Controller(index, controller_options, dynamic=dynamic)

    thread = Thread(target=controller.run)
    thread.controller = controller
    thread.start()

    return thread
开发者ID:Marteon,项目名称:ds4drv,代码行数:10,代码来源:__main__.py

示例2: main

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import controller [as 别名]
def main():
    options = load_options()

    if options.hidraw:
        backend = HidrawBackend(Daemon.logger)
    else:
        backend = BluetoothBackend(Daemon.logger)

    try:
        backend.setup()
    except BackendError as err:
        Daemon.exit(err)

    if options.daemon:
        Daemon.fork(options.daemon_log, options.daemon_pid)

    controllers = []
    threads = []

    for index, options in enumerate(options.controllers):
        controller = DS4Controller(index + 1, options)
        controllers.append(controller)

    for device in backend.devices:
        for thread in threads:
            # Reclaim the joystick device if the controller is gone
            if not thread.is_alive():
                if not thread.controller.dynamic:
                    controllers.insert(0, thread.controller)
                threads.remove(thread)

        # No pre-configured controller available,
        # create one with default settings
        if not controllers:
            index = len(threads) + 1
            options = ControllerAction.default_controller()
            controller = DS4Controller(index, options, dynamic=True)
        else:
            controller = controllers.pop(0)

        controller.logger.info("Connected to {0}", device.name)

        thread = Thread(target=controller.read_device, args=(device,))
        thread.daemon = True
        thread.controller = controller
        thread.start()
        threads.append(thread)
开发者ID:Vash63,项目名称:ds4drv,代码行数:49,代码来源:__main__.py

示例3: main

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import controller [as 别名]
def main():
    options = parser.parse_args(sys.argv[1:] + ["--next-controller"])

    bluetooth_check()

    if options.daemon:
        Daemon.fork(options.daemon_log, options.daemon_pid)

    controllers = []
    threads = []

    for index, options in enumerate(options.controllers):
        controller = create_controller(index + 1, options)
        controllers.append(controller)

    for device in find_devices():
        for thread in threads:
            # Reclaim the joystick device if the controller is gone
            if not thread.is_alive():
                if not thread.controller.dynamic:
                    controllers.insert(0, thread.controller)
                threads.remove(thread)

        # No pre-configured controller available,
        # create one with default settings
        if not controllers:
            index = len(threads) + 1
            options = ControllerAction.default_controller()
            controller = create_controller(index, options, dynamic=True)
        else:
            controller = controllers.pop(0)

        Daemon.info("Connected to {0}", device.bdaddr,
                    subprefix=CONTROLLER_LOG.format(controller.id))

        thread = Thread(target=read_device, args=(device, controller))
        thread.daemon = True
        thread.controller = controller
        thread.start()
        threads.append(thread)
开发者ID:Tosta-Mixta,项目名称:ds4drv,代码行数:42,代码来源:ds4drv.py

示例4: main

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import controller [as 别名]
def main():
    try:
        options = load_options()
    except ValueError as err:
        Daemon.exit("Failed to parse options: {0}", err)

    if options.hidraw:
        backend = HidrawBackend(Daemon.logger)
    else:
        backend = BluetoothBackend(Daemon.logger)

    try:
        backend.setup()
    except BackendError as err:
        Daemon.exit(err)

    if options.daemon:
        Daemon.fork(options.daemon_log, options.daemon_pid)

    controllers = []
    devices = {}
    threads = []

    for index, controller_options in enumerate(options.controllers):
        controller = DS4Controller(index + 1, controller_options)
        controllers.append(controller)

    for device in backend.devices:
        for thread in threads:
            # Reclaim the joystick device if the controller is gone
            if not thread.is_alive():
                if not thread.controller.dynamic:
                    controllers.insert(0, thread.controller)
                threads.remove(thread)

                if thread.controller.device:
                    devices.pop(thread.controller.device.device_addr, None)

        if device.device_addr in devices:
            backend.logger.warning("Ignoring already connected device: {0}",
                                   device.device_addr)
            continue

        # No pre-configured controller available,
        # create one with default settings
        if not controllers:
            index = len(threads) + 1
            controller_options = ControllerAction.default_controller()
            controller_options.parent = options
            controller = DS4Controller(index, controller_options, dynamic=True)
        else:
            controller = controllers.pop(0)

        controller.logger.info("Connected to {0}", device.name)

        thread = Thread(target=controller.read_device, args=(device,))
        thread.daemon = True
        thread.controller = controller
        thread.start()
        threads.append(thread)
        devices[device.device_addr] = device
开发者ID:petretRaf,项目名称:ds4drv,代码行数:63,代码来源:__main__.py


注:本文中的threading.Thread.controller方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。