device: read profiles from ROM if none in Flash
This commit is contained in:
parent
1fcff028fe
commit
88f549f66c
|
@ -1439,11 +1439,15 @@ class OnboardProfiles:
|
||||||
i = 0
|
i = 0
|
||||||
headers = []
|
headers = []
|
||||||
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0, 0, 0, i)
|
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
|
||||||
|
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0x01, 0, 0, i)
|
||||||
|
s = 0x01
|
||||||
while chunk[0:2] != b'\xff\xff':
|
while chunk[0:2] != b'\xff\xff':
|
||||||
sector, enabled = _unpack('!HB', chunk[0:3])
|
sector, enabled = _unpack('!HB', chunk[0:3])
|
||||||
headers.append((sector, enabled))
|
headers.append((sector, enabled))
|
||||||
i += 1
|
i += 1
|
||||||
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0, 0, 0, i * 4)
|
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, s, 0, 0, i * 4)
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1454,14 +1458,12 @@ class OnboardProfiles:
|
||||||
return
|
return
|
||||||
count, oob, buttons, sectors, size, shift = _unpack('!BBBBHB', response[3:10])
|
count, oob, buttons, sectors, size, shift = _unpack('!BBBBHB', response[3:10])
|
||||||
gbuttons = buttons if (shift & 0x3 == 0x2) else 0
|
gbuttons = buttons if (shift & 0x3 == 0x2) else 0
|
||||||
i = 0
|
headers = OnboardProfiles.get_profile_headers(device)
|
||||||
profiles = {}
|
profiles = {}
|
||||||
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0, 0, 0, i)
|
i = 0
|
||||||
while chunk[0:2] != b'\xff\xff':
|
for sector, enabled in headers:
|
||||||
sector, enabled = _unpack('!HB', chunk[0:3])
|
|
||||||
profiles[i + 1] = OnboardProfile.from_dev(device, i, sector, size, enabled, buttons, gbuttons)
|
profiles[i + 1] = OnboardProfile.from_dev(device, i, sector, size, enabled, buttons, gbuttons)
|
||||||
i += 1
|
i += 1
|
||||||
chunk = device.feature_request(FEATURE.ONBOARD_PROFILES, 0x50, 0, 0, 0, i * 4)
|
|
||||||
return cls(count=count, buttons=buttons, gbuttons=gbuttons, sectors=sectors, size=size, profiles=profiles)
|
return cls(count=count, buttons=buttons, gbuttons=gbuttons, sectors=sectors, size=size, profiles=profiles)
|
||||||
|
|
||||||
def to_bytes(self):
|
def to_bytes(self):
|
||||||
|
|
Loading…
Reference in New Issue