{"id":17350364,"url":"https://github.com/meskill/mystic-light-sdk","last_synced_at":"2025-04-14T21:14:02.958Z","repository":{"id":39748816,"uuid":"482329742","full_name":"meskill/mystic-light-sdk","owner":"meskill","description":"Rust wrapper for the Mystic Light SDK - https://www.msi.com/Landing/mystic-light-rgb-gaming-pc/download","archived":false,"fork":false,"pushed_at":"2022-10-01T17:21:23.000Z","size":407,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T21:13:56.582Z","etag":null,"topics":["ffi","gh-backup","mystic-light","rgb","rgb-led","rust","sdk"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/mystic_light_sdk","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meskill.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-16T18:20:26.000Z","updated_at":"2025-02-10T19:01:28.000Z","dependencies_parsed_at":"2022-08-09T15:25:22.739Z","dependency_job_id":null,"html_url":"https://github.com/meskill/mystic-light-sdk","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meskill%2Fmystic-light-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meskill%2Fmystic-light-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meskill%2Fmystic-light-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meskill%2Fmystic-light-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meskill","download_url":"https://codeload.github.com/meskill/mystic-light-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961237,"owners_count":21189993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ffi","gh-backup","mystic-light","rgb","rgb-led","rust","sdk"],"created_at":"2024-10-15T17:06:38.853Z","updated_at":"2025-04-14T21:14:02.929Z","avatar_url":"https://github.com/meskill.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mystic_light_sdk ![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue) [![mystic_light_sdk on crates.io](https://img.shields.io/crates/v/mystic_light_sdk)](https://crates.io/crates/mystic_light_sdk) [![mystic_light_sdk on docs.rs](https://docs.rs/mystic_light_sdk/badge.svg)](https://docs.rs/mystic_light_sdk) [![Source Code Repository](https://img.shields.io/badge/Code-On%20github.com-blue)](https://github.com/meskill/mystic-light-sdk) [![mystic_light_sdk on deps.rs](https://deps.rs/repo/github/meskill/mystic-light-sdk/status.svg)](https://deps.rs/repo/github/meskill/mystic-light-sdk)\n\nRust SDK wrapper for the [Mystic Light SDK][__link0]\n\n\n## Requirements\n\n 1. Any MSI device with RGB support\n 2. Only Windows 7+\n 3. Dragon Center or Msi Center installed and running. You can download it [here][__link1]\n 4. Admin rights to run program with the `mystic_light_sdk`\n\n\n## Examples\n\n\n```rust\nuse mystic_light_sdk::{Color, CommonError, DeviceLedState, MysticLightSDK};\nuse std::thread;\nuse std::time::Duration;\n\nuse tracing::{info, warn, Level};\nuse tracing_subscriber::{fmt, fmt::format::FmtSpan};\n\nconst LIB_PATH: \u0026str = if cfg!(target_arch = \"x86_64\") {\n   \"../sdk/MysticLight_SDK_x64.dll\"\n} else {\n   \"../sdk/MysticLight_SDK.dll\"\n};\n\nfn main() -\u003e Result\u003c(), CommonError\u003e {\n   fmt()\n       .pretty()\n       .with_max_level(Level::DEBUG)\n       .with_span_events(FmtSpan::ACTIVE)\n       .init();\n\n   let sdk = MysticLightSDK::new(LIB_PATH)?;\n\n   let devices: Vec\u003c_\u003e = sdk.devices_iter().collect();\n\n   info!(?devices);\n\n   info!(second_device_name = devices[2].name());\n\n   let keyboard_leds: Vec\u003c_\u003e = devices[2].leds_iter().collect();\n\n   info!(?keyboard_leds);\n\n   info!(\n       \"First led has name: {} with max_bright: {} and max_speed: {}\",\n       keyboard_leds[0].name(),\n       keyboard_leds[0].max_bright(),\n       keyboard_leds[0].max_speed()\n   );\n\n   let state = keyboard_leds[0].get_state()?;\n\n   info!(\"Current device state: {:#?}\", state);\n\n   warn!(\"Disable lightning!\");\n\n   let new_state = DeviceLedState {\n       color: Color {\n           red: 0,\n           green: 0,\n           blue: 0,\n       },\n       style: String::from(\"NoAnimation\"),\n       ..state\n   };\n\n   keyboard_leds[0].set_state(\u0026new_state)?;\n\n   thread::sleep(Duration::from_secs(5));\n\n   warn!(\"Enable lightning\");\n\n   keyboard_leds[0].set_state(\u0026state)?;\n\n   Ok(())\n}\n\n```\n\n\n### Pass right dll file\n\nIt depends on the os architecture you are building the program to and the os architecture for the end users.\n\nCurrently, most of the PC’s are 64 bit architecture so you may just use MysticLight_SDK_x64.dll\n\nOr if you are targetting both architecture you may use code below\n\n\n```rust\nconst LIB_PATH: \u0026str = if cfg!(target_arch = \"x86_64\") {\n    \"sdk/MysticLight_SDK_x64.dll\" // path to the dll file that must be available in runtime\n} else {\n    \"sdk/MysticLight_SDK.dll\"\n};\n```\n\n\n### Copy dll files to the output dir\n\nAs sdk dll is required in runtime you must provide these files somehow in the runtime.\n\nYou may use build script included in the library itself to copy directory with sdk to the output directory. To do so provide environment variable `MYSTIC_LIGHT_SDK_PATH` with **absolute** path to directory with the sdk’s dll e.g. `MYSTIC_LIGHT_SDK_PATH=/workspaces/project/sdk`.\n\n\n## Panics\n\n - in case of any problems with conversion from and into WinApi types\n\n\n## How does it work\n\n\n### Parallelism\n\nUnderlying C++ SDK doesn’t support parallel access and trying to use sdk that way will lead to wrong data. To prevent such problems this wrapper wraps underlying library in Arc and Mutex. Arc is used to share the same library instance across wrapper structs. Mutex is used to prevent parallel access to the underlying library.\n\nThat all means you can safely use rust wrapper both in single-threaded and multi-threaded environments, but actual sdk calls will be executed in sequence anyway.\n\n\n## Usage\n\n\n### tracing\n\nTracing is implemented with library [`tracing`][__link2] - to see tracing logs follow the [instructions of tracing crate][__link3].\n\n\n## Features\n\n\n### serde\n\nEnables [serde][__link4] serialization/deserialization for some of the sdk structs\n\n\n### async-graphql\n\nEnables [async-graphql][__link5] support for sdk entities\n\nWhen this feature is enabled you can use [MysticLightGraphqlQuery][__link6] as async_graphql::Query and [MysticLightGraphqlMutation][__link7] as async_graphql::Mutation\n\n\n```rust\nuse async_graphql::{EmptySubscription, Schema};\nuse mystic_light_sdk::{build_graphql_schema, MysticLightSDK, MysticLightGraphqlMutation, MysticLightGraphqlQuery};\n\npub type MysticLightSchema = Schema\u003cMysticLightGraphqlQuery, MysticLightGraphqlMutation, EmptySubscription\u003e;\n\npub fn create_qraphql_schema(sdk: MysticLightSDK) -\u003e MysticLightSchema {\n    let (query, mutation) = build_graphql_schema(sdk);\n\n    Schema::build(query, mutation, EmptySubscription).finish()\n}\n\n```\n\n\n## Troubleshooting\n\n\n### Timeout error on initialization\n\nMake sure you have been fulfilled [requirements](#requirements) and you running the result program with the admin rights\n\n\n### NotSupported error when trying to set color\n\nSome of the device’s styles do not support colors. In this case this kind of error will be generated.\n\n\n [__cargo_doc2readme_dependencies_info]: ggGkYW0AYXSEG52uRQSwBdezG6GWW8ODAbr5G6KRmT_WpUB5G9hPmBcUiIp6YXKEGwZVjdq2ObFUG5iRsw2sZp7JGwtix7sRa4ihGxFVtj4lRduhYWSCgngaTXlzdGljTGlnaHRHcmFwaHFsTXV0YXRpb272gndNeXN0aWNMaWdodEdyYXBocWxRdWVyefY\n [__link0]: https://www.msi.com/Landing/mystic-light-rgb-gaming-pc/download\n [__link1]: https://www.msi.com/Landing/mystic-light-rgb-gaming-pc/download\n [__link2]: https://docs.rs/tracing/0.1.36/tracing/index.html\n [__link3]: https://docs.rs/tracing/0.1.36/tracing/index.html#in-executables\n [__link4]: https://crates.io/crates/serde\n [__link5]: https://crates.io/crates/async-graphql\n [__link6]: https://crates.io/crates/MysticLightGraphqlQuery\n [__link7]: https://crates.io/crates/MysticLightGraphqlMutation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeskill%2Fmystic-light-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeskill%2Fmystic-light-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeskill%2Fmystic-light-sdk/lists"}