コード例 #1
0
ファイル: listener.py プロジェクト: xgdsmileboy/Solaar
def _start(device_info):
    assert _status_callback
    receiver = Receiver.open(device_info)
    if receiver:
        rl = ReceiverListener(receiver, _status_callback)
        rl.start()
        _all_listeners[device_info.path] = rl
        return rl

    _log.warn("failed to open %s", device_info)
コード例 #2
0
ファイル: listener.py プロジェクト: 3v1n0/Solaar
def _start(device_info):
	assert _status_callback
	receiver = Receiver.open(device_info)
	if receiver:
		rl = ReceiverListener(receiver, _status_callback)
		rl.start()
		_all_listeners[device_info.path] = rl
		return rl

	_log.warn("failed to open %s", device_info)
コード例 #3
0
ファイル: __init__.py プロジェクト: cctsao1008/Solaar
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
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)))
コード例 #5
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")
コード例 #6
0
ファイル: __init__.py プロジェクト: mjes2113/gggggsssd
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)))
コード例 #7
0
def _start(device_info):
    assert _status_callback
    isDevice = device_info.isDevice
    if not isDevice:
        receiver = Receiver.open(device_info)
    else:
        receiver = Device.open(device_info)
        configuration.attach_to(receiver)

    if receiver:
        rl = ReceiverListener(receiver, _status_callback)
        rl.start()
        _all_listeners[device_info.path] = rl
        return rl

    _log.warn('failed to open %s', device_info)
コード例 #8
0
    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]
コード例 #9
0
        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')
            with open(charge_filepath) as file:
                charge_table = list(csv.DictReader(file))