Skip to content

[FEATURE] Added a speed modifier#23

Open
Janneske2001 wants to merge 5 commits into
DeviceIoControl:masterfrom
Janneske2001:master
Open

[FEATURE] Added a speed modifier#23
Janneske2001 wants to merge 5 commits into
DeviceIoControl:masterfrom
Janneske2001:master

Conversation

@Janneske2001

@Janneske2001 Janneske2001 commented Jun 10, 2026

Copy link
Copy Markdown

I looked into the code and together with AI I got speed modification to work with only small changes.

Speed can be changed by adding -speed [number], where the number stands for the percentage of speed.
So -speed 10 will set the speed to 10%, -speed 250 will set the speed to 250%.

image

@Janneske2001 Janneske2001 changed the title I added a speed modifier [FEATURE] Added a speed modifier Jun 10, 2026
@DeviceIoControl DeviceIoControl added the enhancement New feature or request label Jun 10, 2026
}

void Keyboard::SetSpeedFactor(float factor)
{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some checks to ensure that factor isn't an unreasonably high or unnecessarily low number. (Lets say >= 1 && <= 250)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a reasonable thing to add. Do you think 250 is a good upper limit? I think there is a limit anyways with how fast it can even switch colour. And I personally think that people would rarely have it play even faster than the animations are right now. For now I think I will add 250 as limit, as you suggested, but it can always be changed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image

Also, when opened from a non-elevated terminal, it will reopen in an elevated separate terminal window. But when an error would happen, it would instantly close. I added a little Press Enter to exit... thing too. It gives users the ability to read the errors in this specific edge case.

image

Comment thread CppKeyboardColour/Keyboard.cpp Outdated
{
m_ptrKbComms->SetKBColour(frame->zone, frame->colour);
// MODIFIED: apply speed factor to the sleep duration
uint32_t sleepMs = static_cast<uint32_t>(frame->ms_time / m_speedFactor);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the sleepMs variable outside of the loop to avoid re-calculating on each frame.

@DeviceIoControl

DeviceIoControl commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Other than a few minor comments, the changes look good to me. Once those are sorted, I'm happy to approve and merge this change 👍

Comment thread CppKeyboardColour/Keyboard.cpp Outdated
if (const auto frame = animation.GetFrame(i))
{
m_ptrKbComms->SetKBColour(frame->zone, frame->colour);
// MODIFIED: apply speed factor to the sleep duration

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the "MODIFIED" from this comment. Just make it Apply speed factor to the sleep duration.
(And move this comment to outside of the loop like the sleepMs variable)

@Janneske2001

Copy link
Copy Markdown
Author

I pushed changes to my repo, but it also included this reworked error handling I talked about. Should I remove that, and then push again and do another merge request?

@DeviceIoControl

Copy link
Copy Markdown
Owner

I pushed changes to my repo, but it also included this reworked error handling I talked about. Should I remove that, and then push again and do another merge request?

Hi @Janneske2001,

It's fine, keep the changes. I didn't see that you had already done the changes in GitHub.

@Janneske2001

Copy link
Copy Markdown
Author

Hi @Janneske2001,

It's fine, keep the changes. I didn't see that you had already done the changes in GitHub.

No problem, Do I need to do a new Pull Request?

@DeviceIoControl

Copy link
Copy Markdown
Owner

@Janneske2001 - How big is the change?

@Janneske2001

Copy link
Copy Markdown
Author

@DeviceIoControl

image

There are 8 changed files in total. Each file doesn't have many changes. However, there was one file that I basically didn't "change", but it seemed "corrupted" on my laptop. I copy-pasted the original content back in it and it worked for me, but it gets treated as a modified file (stdafx.cpp).

@DeviceIoControl

Copy link
Copy Markdown
Owner

@Janneske2001 - OK, so just to understand, what is it that you would need a "New Pull Request" for? That looks like the current change? or am I mistaken in someway?

@Janneske2001

Copy link
Copy Markdown
Author

@DeviceIoControl Honestly, I don't really know how Github works with pull requests and all. Sorry for that. Basically I finished my modifications, so it's ready from my side.

@DeviceIoControl

DeviceIoControl commented Jun 11, 2026

Copy link
Copy Markdown
Owner

@Janneske2001 - Thanks for clarifying, I'm going to do a bit of testing on my system, just to ensure everything works and I will approve this PR once it is done.

Thanks!

@Janneske2001

Copy link
Copy Markdown
Author

@DeviceIoControl Alright nice! I couldn't test with a 3-zone keyboard, but all the single-zone themes work (At least on my device 😅)

You're welcome, and I'm glad I could help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants