예제 #1
0
파일: input.py 프로젝트: adaptee/synaptiks
    def all_devices(cls, display, master_only=False):
        """
        Iterate over all input devices registered on the given ``display``.

        ``display`` is a :class:`~synaptiks.x11.Display` object.  If
        ``master_only`` is ``True``, only master devices are returned.  In this
        case, the returned iterator yields only two devices in most cases, a
        master keyboard and a master slave (the exact order is undefined).

        Return an iterator over :class:`InputDevice` objects.

        Raise :exc:`XInputVersionError`, if the XInput version isn't sufficient
        to support input device management.

        .. seealso:: :attr:`is_master`
        """
        assert_xinput_version(display)
        if master_only:
            device_id = xinput.ALL_MASTER_DEVICES
        else:
            device_id = xinput.ALL_DEVICES
        number_of_devices, devices = xinput.query_device(display, device_id)
        with scoped_pointer(devices, xinput.free_device_info) as devices:
            if not devices:
                raise EnvironmentError('Failed to query devices')
            for i in xrange(number_of_devices):
                yield cls(display, devices[i].deviceid)
예제 #2
0
파일: input.py 프로젝트: adaptee/synaptiks
    def all_devices(cls, display, master_only=False):
        """
        Iterate over all input devices registered on the given ``display``.

        ``display`` is a :class:`~synaptiks.x11.Display` object.  If
        ``master_only`` is ``True``, only master devices are returned.  In this
        case, the returned iterator yields only two devices in most cases, a
        master keyboard and a master slave (the exact order is undefined).

        Return an iterator over :class:`InputDevice` objects.

        Raise :exc:`XInputVersionError`, if the XInput version isn't sufficient
        to support input device management.

        .. seealso:: :attr:`is_master`
        """
        assert_xinput_version(display)
        if master_only:
            device_id = xinput.ALL_MASTER_DEVICES
        else:
            device_id = xinput.ALL_DEVICES
        number_of_devices, devices = xinput.query_device(display, device_id)
        with scoped_pointer(devices, xinput.free_device_info) as devices:
            if not devices:
                raise EnvironmentError('Failed to query devices')
            for i in xrange(number_of_devices):
                yield cls(display, devices[i].deviceid)
예제 #3
0
파일: input.py 프로젝트: adaptee/synaptiks
    def _query_device(self):
        """
        Query this device from the X11 server.

        Return a pointer to the device info struct
        (:class:`~synaptiks._bindings.xinput.XIDeviceInfo`).
        """
        _, device = xinput.query_device(self.display, self.id)
        if not device:
            raise InputDeviceNotFoundError(self.id)
        yield device
        xinput.free_device_info(device)
예제 #4
0
파일: input.py 프로젝트: adaptee/synaptiks
    def _query_device(self):
        """
        Query this device from the X11 server.

        Return a pointer to the device info struct
        (:class:`~synaptiks._bindings.xinput.XIDeviceInfo`).
        """
        _, device = xinput.query_device(self.display, self.id)
        if not device:
            raise InputDeviceNotFoundError(self.id)
        yield device
        xinput.free_device_info(device)