@@ -167,6 +167,32 @@ def read(self):
167167 finally :
168168 self .lock .release ()
169169 self .callback (device_id , packet_type , utils .parse_list (utils .Profile , idata , self ._protocol_version ))
170+ elif packet_type == utils .PacketType .REQUEST_PLUGIN_LIST :
171+ try :
172+ data = bytes ()
173+ while len (data ) < packet_size :
174+ data += self .sock .recv (packet_size - len (data ))
175+ idata = iter (data )
176+ for _ in range (4 ):
177+ next (idata )
178+ except utils .CONNECTION_ERRORS as e :
179+ self .stop_connection ()
180+ raise utils .OpenRGBDisconnected () from e
181+ finally :
182+ self .lock .release ()
183+ self .callback (device_id , packet_type , utils .parse_list (utils .Plugin , idata , self ._protocol_version ))
184+ elif packet_type == utils .PacketType .PLUGIN_SPECIFIC :
185+ try :
186+ data = bytes ()
187+ while len (data ) < packet_size :
188+ data += self .sock .recv (packet_size - len (data ))
189+ idata = iter (data )
190+ except utils .CONNECTION_ERRORS as e :
191+ self .stop_connection ()
192+ raise utils .OpenRGBDisconnected () from e
193+ finally :
194+ self .lock .release ()
195+ self .callback (device_id , packet_type , idata )
170196
171197 def requestDeviceData (self , device : int ):
172198 '''
@@ -194,7 +220,14 @@ def requestProfileList(self):
194220 self .send_header (0 , utils .PacketType .REQUEST_PROFILE_LIST , 0 )
195221 self .read ()
196222
197- def send_header (self , device_id : int , packet_type : utils .PacketType , packet_size : int ):
223+ def requestPluginList (self ):
224+ '''
225+ Sends the request for the available plugins
226+ '''
227+ self .send_header (0 , utils .PacketType .REQUEST_PLUGIN_LIST , 0 )
228+ self .read ()
229+
230+ def send_header (self , device_id : int , packet_type : utils .PacketType , packet_size : int , release_lock : bool = True ):
198231 '''
199232 Sends a header to the SDK
200233
@@ -215,10 +248,12 @@ def send_header(self, device_id: int, packet_type: utils.PacketType, packet_size
215248 if sent != len (data ):
216249 self .stop_connection ()
217250 raise utils .OpenRGBDisconnected ()
218- if packet_size == 0 and packet_type not in (utils .PacketType .REQUEST_CONTROLLER_COUNT ,
219- utils .PacketType .REQUEST_CONTROLLER_DATA ,
220- utils .PacketType .REQUEST_PROTOCOL_VERSION ,
221- utils .PacketType .REQUEST_PROFILE_LIST ):
251+ if release_lock and packet_size == 0 and packet_type not in (utils .PacketType .REQUEST_CONTROLLER_COUNT ,
252+ utils .PacketType .REQUEST_CONTROLLER_DATA ,
253+ utils .PacketType .REQUEST_PROTOCOL_VERSION ,
254+ utils .PacketType .REQUEST_PROFILE_LIST ,
255+ utils .PacketType .REQUEST_PLUGIN_LIST ,
256+ utils .PacketType .PLUGIN_SPECIFIC ):
222257 self .lock .release ()
223258 except utils .CONNECTION_ERRORS as e :
224259 self .stop_connection ()
@@ -257,6 +292,9 @@ def check_version(self, packet_type: utils.PacketType):
257292 raise utils .SDKVersionError ("Profile controls not supported on protocol versions < 2. You probably need to update OpenRGB" )
258293 elif self ._protocol_version < 3 and packet_type == utils .PacketType .RGBCONTROLLER_SAVEMODE :
259294 raise utils .SDKVersionError ("Saving modes not supported on protocol versions < 3. You probably need to update OpenRGB" )
295+ elif self ._protocol_version < 4 and packet_type in (utils .PacketType .REQUEST_PLUGIN_LIST ,
296+ utils .PacketType .PLUGIN_SPECIFIC ):
297+ raise utils .SDKVersionError ("Plugin controls not supported on protocol versions < 4. You probably need to update OpenRGB" )
260298
261299 @property
262300 def connected (self ) -> bool :
0 commit comments