Skip to content

Commit f2eb04b

Browse files
Fix zone parsing desync on OpenRGB 1.0rc3+ servers- #1 (#93)
* Fix zone parsing desync on OpenRGB 1.0rc3+ servers Servers with SDK protocol >= 5 serialize a matrix map block for every zone, not just MATRIX zones. ZoneData.unpack only consumed it when zone_type == MATRIX, leaving the parser 8 bytes behind on LINEAR/SINGLE zones and producing garbage values (e.g. "256 is not a valid ZoneType") during device discovery. Consume the matrix block whenever matrix_zone_size > 0, which is backward compatible since the size is 0 when no map exists. Also widen ZoneType to the current server values (LINEAR_LOOP, MATRIX_LOOP_X, MATRIX_LOOP_Y, SEGMENTED).
1 parent dbbe583 commit f2eb04b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎openrgb/utils.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class ZoneType(IntEnum):
6666
SINGLE = 0
6767
LINEAR = 1
6868
MATRIX = 2
69+
LINEAR_LOOP = 3
70+
MATRIX_LOOP_X = 4
71+
MATRIX_LOOP_Y = 5
72+
SEGMENTED = 6
6973

7074

7175
class PacketType(IntEnum):
@@ -468,7 +472,7 @@ def unpack(cls, data: Iterator[int], version: int, *args) -> ZoneData:
468472
leds_max = parse_var('I', data)
469473
num_leds = parse_var('I', data)
470474
matrix_zone_size = parse_var('H', data)
471-
if zone_type == ZoneType.MATRIX:
475+
if matrix_zone_size > 0:
472476
height = parse_var('I', data)
473477
width = parse_var('I', data)
474478
matrix: list[list[Optional[int]]] = [[] for x in range(height)]

0 commit comments

Comments
 (0)