Bnyro (81cd97f9) at 03 Nov 10:47
Add support for Lenovo Legion K510 keyboard
Yes, the mode is persisted. So I'll revert it to mode specific.
Currently, the information whether a mode supports UP/DOWN or LEFT/RIGHT is only known in the modes vec in LenovoK510_RGBController.
If we now want to set the current_mode.direction here, we would need that information either
modes vec in LenovoK510_RGBController, so we'd need to pass the modes vec to this method here (which we likely don't want to keep separation between the Controller´ and RGBController`UP/DOWN or LEFT/RIGHT a second time, so this would be duplicated information because it's already defined in RGBController so it'd perhaps make this code harder to maintain (at least from my experience).Since I like neither of the options, I chose to let RGBController handle this, but if you prefer one of the other options I'm okay with changing the code :)
I agree, the previous solution was a bit hacky
If that changes something in this discussion:
There's a keyboard shortcut to change the mode, and if you use that all modes also use the color you selected previously in a different mode. That means that the color is really stored per LED block (i.e. the keyboard) and not per animation mode.
Good idea, done.
Since our hidapi_write call always has to include the current mode and all other data as well (i.e. we can't send a call that specifically only modifies the color), I assume it's okay to just call DeviceUpdateMode from DeviceUpdateLEDs here as it's the same code that needs to be executed anyways?
Bnyro (bb057990) at 29 Oct 19:02
Add support for Lenovo Legion K510 keyboard
This feels a bit ugly now because we have to iterate over all modes to find the one that's selected and to update its values, but should work fine overall.
Possibly that's also because I've no experience with C++ yet, so perhaps there's a simpler way to accomplish that.
Bnyro (2d5f790e) at 29 Oct 16:15
Add support for Lenovo Legion K510 keyboard
It was, yes. I've applied your suggestion.
Bnyro (4a045a39) at 29 Oct 09:37
Add support for Lenovo Legion K510 keyboard
It returns all information about the current mode (e.g. its color and speed), but I didn't know how to set them in RGBController from this point without creating a custom data type that contains all the information so that we can return it in this method and RGBController can pick it up to update the modes.
Bnyro (e06d4578) at 29 Oct 09:01
Add support for Lenovo Legion K510 keyboard
Whoops, my bad