4JX / L5P-Keyboard-RGB

Cross platform software to control the RGB/lighting of the 4 zone keyboard included in the 2020, 2021, 2022 and 2023 lineup of the Lenovo Legion laptops. Works on Windows and Linux.
GNU General Public License v3.0
308 stars 39 forks source link

Make a library #43

Closed heckert-gamedev closed 11 months ago

heckert-gamedev commented 2 years ago

It would be really nice if there was a library for this one could use in one's own projects without the performance hit of running a separate program for each effect. (My intended target platform would be Unity on Linux and Windows)

4JX commented 2 years ago

https://github.com/4JX/L5P-Keyboard-RGB/blob/main/src/keyboard_utils.rs

Is actually all you really need to get started, I'll see about uploading it to crates.io as a standalone thing. Really curious about what it could be used for 😁

I'll look into adding proper documentation though.

4JX commented 2 years ago

Hmm, I'm having trouble with coming up with a meaningful enough name for the library. Any ideas?

On another note Unity uses C#, so I guess bindings need to be a thing.

heckert-gamedev commented 2 years ago

As for the Rust vs. C# issue, I actually came across this one the other day: "Rust and Unity game development" https://youtu.be/L7M_vbo1N2g

I added Rust support for the Unity game engine. Is it really possible? YES it is! I managed to make a game 100% coded in Rust, but using Unity as editor and runtime. This has to be one of my craziest projects yet!

I utilized a library called Bevy game framework/engine, to handle the gameplay programming. Utilizing Bevy systems I was able to hide the Foreign Function interfacing code from the gameplay code.

Runity Source code: https://github.com/TanTanDev/runity

It sounds like this would be a good starting point, at least... (I haven't looked into it yet, it's just something I came across and found interesting enough to bookmark, probably because the idea for this suggestion was already brewing somewhere in my head)

As for a name... Maybe it's the Rusty Blinken-Keyboard? The Legionary Keyboard-Blinker? Disco-Keys for Unity?

4JX commented 2 years ago

I've been fiddling around with this for a while now but I cannot wrap my head around implementing this with my current (lacking) knowledge of the language (It gets especially finicky when having to handle the AtomicBool stop signal and whatnot).

You can try your luck with it:

heckert-gamedev commented 2 years ago

Since I don't have any knowledge of Rust (nor the underlying system level APIs) all I can give are just suggestions...

4JX commented 2 years ago

I may revisit this at a latter date, but for now I'd rather keep improving my level in the language.

You could also try translating the code to native C#, its mostly a matter of seeing if there's a hidapi library available and the rest should be pretty straight forward (can ask questions if you get stuck).