-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from cuesdk import (CueSdk, CorsairDeviceFilter, CorsairDeviceType, | ||
CorsairError, CorsairSessionState, CorsairDeviceInfo) | ||
import sys | ||
|
||
COLS = ["Device type", "Model name", "LED count", "Channel count"] | ||
COL_WIDTH = 28 | ||
|
||
|
||
def hr(): | ||
print("—" * COL_WIDTH * len(COLS)) | ||
|
||
|
||
def print_device(device: CorsairDeviceInfo): | ||
print(f"{str(device.type)[18:]:{COL_WIDTH-2}} |" | ||
f" {device.model:{COL_WIDTH-3}} |" | ||
f" {device.led_count:{COL_WIDTH-3}} |" | ||
f" {device.channel_count:{COL_WIDTH-2}}") | ||
|
||
|
||
def main(): | ||
sdk = CueSdk() | ||
|
||
def on_state_changed(evt): | ||
print(evt.state) | ||
# the app must wait for CSS_Connected event before proceeding | ||
if evt.state == CorsairSessionState.CSS_Connected: | ||
details, err = sdk.get_session_details() | ||
print(details) | ||
|
||
devices, err = sdk.get_devices( | ||
CorsairDeviceFilter( | ||
device_type_mask=CorsairDeviceType.CDT_All)) | ||
if err == CorsairError.CE_Success and devices: | ||
hr() | ||
print("|".join([f"{col:^{COL_WIDTH-1}}" for col in COLS])) | ||
hr() | ||
for d in devices: | ||
device, err = sdk.get_device_info(d.device_id) | ||
if device: | ||
print_device(device) | ||
hr() | ||
else: | ||
print(err) | ||
|
||
err = sdk.connect(on_state_changed) | ||
if err != CorsairError.CE_Success: | ||
print("\nERROR: Unable to connect to iCUE") | ||
print(err) | ||
sys.exit() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
input() # wait for <Enter> |