示例#1
0
def start_all():
    # just in case this it called twice in a row...
    stop_all()

    if _log.isEnabledFor(_INFO):
        _log.info('starting receiver listening threads')
    for device_info in _base.receivers():
        _process_receiver_event('add', device_info)
示例#2
0
def _receivers():
	from logitech_receiver import Receiver
	from logitech_receiver.base import receivers
	for dev_info in receivers():
		try:
			r = Receiver.open(dev_info)
			if _log.isEnabledFor(_DEBUG):
				_log.debug("[%s] => %s", dev_info.path, r)
			if r:
				yield r
		except Exception as e:
			_log.exception('opening ' + str(dev_info))
			_sys.exit("%s: error: %s" % (NAME, str(e)))
示例#3
0
def _receivers():
    from logitech_receiver import Receiver
    from logitech_receiver.base import receivers
    for dev_info in receivers():
        try:
            r = Receiver.open(dev_info)
            if _log.isEnabledFor(_DEBUG):
                _log.debug("[%s] => %s", dev_info.path, r)
            if r:
                yield r
        except Exception as e:
            _log.exception('opening ' + str(dev_info))
            _sys.exit("%s: error: %s" % (NAME, str(e)))
示例#4
0
文件: cli.py 项目: damsweb/Solaar
def _receiver(dev_path=None):
	from logitech_receiver import Receiver
	from logitech_receiver.base import receivers
	for dev_info in receivers():
		if dev_path is not None and dev_path != dev_info.path:
			continue
		try:
			r = Receiver.open(dev_info)
			if r:
				return r
		except Exception as e:
			_fail(str(e))
		return r
	_fail("Logitech receiver not found")
示例#5
0
def _receivers(dev_path=None):
    from logitech_receiver import Receiver
    from logitech_receiver.base import receivers
    for dev_info in receivers():
        if dev_path is not None and dev_path != dev_info.path:
            continue
        try:
            r = Receiver.open(dev_info)
            if _log.isEnabledFor(_DEBUG):
                _log.debug('[%s] => %s', dev_info.path, r)
            if r:
                yield r
        except Exception as e:
            _log.exception('opening ' + str(dev_info))
            _sys.exit('%s: error: %s' % (NAME, str(e)))
    def __init__ (self):
        device_info = next (r for r in receivers () if r.product_id == "c52b")
        print(device_info)
        assert device_info

        self.receiver = Receiver.open (device_info)
        assert self.receiver

        self.m720 = next (d for d in self.receiver if d.codename == "M720 Triathlon")
        assert self.m720
        assert self.m720.ping ()

        self.features = list (self.m720.features)

        # https://lekensteyn.nl/files/logitech/x1b04_specialkeysmsebuttons.html#divertedButtonsEvent
        # https://lekensteyn.nl/files/logitech/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf
        self.feature_index = self.features.index (0x1B04)
        self.software_id = 0xe # random number in [0x0;0xF]
示例#7
0
    share_lib = os.path.join(prefix, 'share', 'solaar', 'lib')
    for location in src_lib, share_lib:
        init_py = os.path.join(location, 'solaar', '__init__.py')
        if os.path.exists(init_py):
            sys.path[0] = location
            break


if __name__ == '__main__':
    init_paths()

    from logitech_receiver import Receiver, hidpp20
    from logitech_receiver.base import receivers

    receiver = None
    for dev_info in receivers():
        if dev_info.path == MY_RECEIVER:
            receiver = Receiver.open(dev_info)
    if receiver is None:
        print("Receiver not connected")
        exit()

    for dev in receiver:
        dev.ping()

        if dev.online:
            battery = hidpp20.get_voltage(dev)
            voltage, charging, charge_sts, charge_lvl, charge_type = battery

            charge_filepath = os.path.join(os.path.dirname(__file__),
                                           'g703_charge.csv')