(self)
Wait for new DS4 devices to appear.
Wait for new DS4 devices to appear.
Wait for new DS4 devices to appear .
def devices(self):
        """Wait for new DS4 devices to appear."""
        context = Context()

        existing_devices = context.list_devices(subsystem="hidraw")
        future_devices = self._get_future_devices(context)

        for hidraw_device in itertools.chain(existing_devices, future_devices):
            hid_device = hidraw_device.parent
            if hid_device.subsystem != "hid":
                continue

            cls = HID_DEVICES.get(hid_device.get("HID_NAME"))
            if not cls:
                continue

            for child in hid_device.parent.children:
                event_device = child.get("DEVNAME", "")
                if event_device.startswith("/dev/input/event"):
                    break
            else:
                continue


            try:
                device_addr = hid_device.get("HID_UNIQ", "").upper()
                if device_addr:
                    device_name = "{0} {1}".format(device_addr,
                                                   hidraw_device.sys_name)
                else:
                    device_name = hidraw_device.sys_name

                yield cls(name=device_name,
                          addr=device_addr,
                          type=cls.__type__,
                          hidraw_device=hidraw_device.device_node,
                          event_device=event_device)

            except DeviceError as err:
                self.logger.error("Unable to open DS4 device: {0}", err)
def devices ( self ) : context = Context ( ) existing_devices = context . list_devices ( subsystem = "hidraw" ) future_devices = self . _get_future_devices ( context ) for hidraw_device in itertools . chain ( existing_devices , future_devices ) : hid_device = hidraw_device . parent if hid_device . subsystem != "hid" : continue cls = HID_DEVICES . get ( hid_device . get ( "HID_NAME" ) ) if not cls : continue for child in hid_device . parent . children : event_device = child . get ( "DEVNAME" , "" ) if event_device . startswith ( "/dev/input/event" ) : break else : continue try : device_addr = hid_device . get ( "HID_UNIQ" , "" ) . upper ( ) if device_addr : device_name = "{0} {1}" . format ( device_addr , hidraw_device . sys_name ) else : device_name = hidraw_device . sys_name yield cls ( name = device_name , addr = device_addr , type = cls . __type__ , hidraw_device = hidraw_device . device_node , event_device = event_device ) except DeviceError as err : self . logger . error ( "Unable to open DS4 device: {0}" , err )