settings: get and use current host number for K375sFnSwap because of bug in firmware of MX Keys S
This commit is contained in:
parent
b4811f602d
commit
3ffa4e30f1
|
@ -231,12 +231,25 @@ _descriptors.get_usbid(0xC066).settings = [_PerformanceMXDpi, RegisterSmoothScro
|
||||||
|
|
||||||
|
|
||||||
# ignore the capabilities part of the feature - all devices should be able to swap Fn state
|
# ignore the capabilities part of the feature - all devices should be able to swap Fn state
|
||||||
# just use the current host (first byte = 0xFF) part of the feature to read and set the Fn state
|
# can't just use the first byte = 0xFF (for current host) because of a bug in the firmware of the MX Keys S
|
||||||
class K375sFnSwap(FnSwapVirtual):
|
class K375sFnSwap(FnSwapVirtual):
|
||||||
feature = _F.K375S_FN_INVERSION
|
feature = _F.K375S_FN_INVERSION
|
||||||
rw_options = {"prefix": b"\xFF"}
|
|
||||||
validator_options = {"true_value": b"\x01", "false_value": b"\x00", "read_skip_byte_count": 1}
|
validator_options = {"true_value": b"\x01", "false_value": b"\x00", "read_skip_byte_count": 1}
|
||||||
|
|
||||||
|
class rw_class(_FeatureRW):
|
||||||
|
def find_current_host(self, device):
|
||||||
|
if not self.prefix:
|
||||||
|
response = device.feature_request(_F.HOSTS_INFO, 0x00)
|
||||||
|
self.prefix = response[3:4] if response else b"\xFF"
|
||||||
|
|
||||||
|
def read(self, device, data_bytes=b""):
|
||||||
|
self.find_current_host(device)
|
||||||
|
return super().read(device, data_bytes)
|
||||||
|
|
||||||
|
def write(self, device, data_bytes):
|
||||||
|
self.find_current_host(device)
|
||||||
|
return super().write(device, data_bytes)
|
||||||
|
|
||||||
|
|
||||||
class FnSwap(FnSwapVirtual):
|
class FnSwap(FnSwapVirtual):
|
||||||
feature = _F.FN_INVERSION
|
feature = _F.FN_INVERSION
|
||||||
|
|
|
@ -119,6 +119,19 @@ simple_tests = [
|
||||||
hidpp.Response("FF0001", 0x0600, "FF"),
|
hidpp.Response("FF0001", 0x0600, "FF"),
|
||||||
hidpp.Response("FF0101", 0x0610, "FF01"),
|
hidpp.Response("FF0101", 0x0610, "FF01"),
|
||||||
),
|
),
|
||||||
|
Setup(
|
||||||
|
FeatureTest(settings_templates.K375sFnSwap, False, True, offset=0x06),
|
||||||
|
hidpp.Response("050001", 0x0000, "1815"), # HOSTS_INFO
|
||||||
|
hidpp.Response("FF0001", 0x0600, "FF"),
|
||||||
|
hidpp.Response("FF0101", 0x0610, "FF01"),
|
||||||
|
),
|
||||||
|
Setup(
|
||||||
|
FeatureTest(settings_templates.K375sFnSwap, False, True, offset=0x06),
|
||||||
|
hidpp.Response("050001", 0x0000, "1815"), # HOSTS_INFO
|
||||||
|
hidpp.Response("07050301", 0x0500), # current host is 0x01, i.e., host 2
|
||||||
|
hidpp.Response("010001", 0x0600, "01"),
|
||||||
|
hidpp.Response("010101", 0x0610, "0101"),
|
||||||
|
),
|
||||||
Setup(
|
Setup(
|
||||||
FeatureTest(settings_templates.FnSwap, True, False),
|
FeatureTest(settings_templates.FnSwap, True, False),
|
||||||
hidpp.Response("01", 0x0400),
|
hidpp.Response("01", 0x0400),
|
||||||
|
@ -474,6 +487,7 @@ def mock_gethostname(mocker):
|
||||||
@pytest.mark.parametrize("test", simple_tests)
|
@pytest.mark.parametrize("test", simple_tests)
|
||||||
def test_simple_template(test, mocker, mock_gethostname):
|
def test_simple_template(test, mocker, mock_gethostname):
|
||||||
tst = test.test
|
tst = test.test
|
||||||
|
print("TEST", tst.sclass.feature)
|
||||||
device = hidpp.Device(responses=test.responses, feature=tst.sclass.feature, offset=tst.offset, version=tst.version)
|
device = hidpp.Device(responses=test.responses, feature=tst.sclass.feature, offset=tst.offset, version=tst.version)
|
||||||
spy_request = mocker.spy(device, "request")
|
spy_request = mocker.spy(device, "request")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue