Skip to content

Commit

Permalink
device: handle a different signal for onboard profiles directory in ROM
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Apr 15, 2024
1 parent 86bab89 commit d7ce636
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/logitech_receiver/hidpp20.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ def get_profile_headers(cls, device):
headers = []
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0, 0, 0, i)
s = 0x00
if chunk[0:4] == b"\x00\x00\x00\x00": # look in ROM instead
if chunk[0:4] == b"\x00\x00\x00\x00" or chunk[0:4] == b"\xFF\xFF\xFF\xFF": # look in ROM instead
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0x01, 0, 0, i)
s = 0x01
while chunk[0:2] != b"\xff\xff":
Expand Down
22 changes: 22 additions & 0 deletions tests/logitech_receiver/hidpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,28 @@ def adjust_responses_index(index, responses): # change index-4 responses to ind
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "010100E0"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFF7C81AB", 0x0950, "010100EE"),
]
responses_profiles_rom_2 = [ # OnboardProfile in ROM
Response("0104010101020100FE0200", 0x0900),
Response("FFFFFFFF", 0x0950, "00000000"),
Response("010101FF", 0x0950, "01000000"),
Response("FFFFFFFF", 0x0950, "01000004"),
Response("01010290018003000700140028FFFFFF", 0x0950, "01010000"),
Response("FFFF0000000000000000000000000000", 0x0950, "01010010"),
Response("8000FFFF900aFF00800204548000FFFF", 0x0950, "01010020"),
Response("900aFF00800204548000FFFF900aFF00", 0x0950, "01010030"),
Response("800204548000FFFF900aFF0080020454", 0x0950, "01010040"),
Response("8000FFFF900aFF00800204548000FFFF", 0x0950, "01010050"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "01010060"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "01010070"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "01010080"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "01010090"),
Response("54004500370000000000000000000000", 0x0950, "010100A0"),
Response("00000000000000000000000000000000", 0x0950, "010100B0"),
Response("00000000000000000000000000000000", 0x0950, "010100C0"),
Response("0A01020300500407000000FFFFFFFFFF", 0x0950, "010100D0"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 0x0950, "010100E0"),
Response("FFFFFFFFFFFFFFFFFFFFFFFFFF7C81AB", 0x0950, "010100EE"),
]

complex_responses_1 = [ # COLOR_LED_EFFECTS
Response(4.2, 0x0010), # ping
Expand Down
21 changes: 21 additions & 0 deletions tests/logitech_receiver/test_hidpp20_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,33 @@ def test_button_bytes(hex, behavior, sector, address, typ, val, modifiers, data,
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFF27C9"
)
hex3 = (
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFF2307"
)


@pytest.mark.parametrize(
"hex, name, sector, enabled, buttons, gbuttons, resolutions, button, lighting",
[
(hex1, "TE7", 2, 1, 16, 0, [0x0190, 0x0380, 0x0700, 0x1400, 0x2800], "8000FFFF", "0A01020300500407000000"),
(hex2, "", 2, 1, 16, 0, [0x0190, 0x0380, 0x0700, 0x1400, 0x2800], "8000FFFF", "0A01020300500407000000"),
(hex3, "", 2, 1, 16, 0, [0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], "FFFFFFFF", "FFFFFFFFFFFFFFFFFFFFFF"),
],
)
def test_OnboardProfile_bytes(hex, name, sector, enabled, buttons, gbuttons, resolutions, button, lighting):
Expand All @@ -802,6 +822,7 @@ def test_OnboardProfile_bytes(hex, name, sector, enabled, buttons, gbuttons, res
[
(hidpp.responses_profiles, "ONB", 1, 2, 2, 1, 254),
(hidpp.responses_profiles_rom, "ONB", 1, 2, 2, 1, 254),
(hidpp.responses_profiles_rom_2, "ONB", 1, 2, 2, 1, 254),
],
)
def test_OnboardProfiles_device(responses, name, count, buttons, gbuttons, sectors, size):
Expand Down

0 comments on commit d7ce636

Please sign in to comment.