Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScanHardware bPressed clarity #341

Open
redmoncoreyl opened this issue Jul 26, 2023 · 0 comments
Open

ScanHardware bPressed clarity #341

redmoncoreyl opened this issue Jul 26, 2023 · 0 comments

Comments

@redmoncoreyl
Copy link

I believe the line

pKeys[i].bPressed = !pKeys[i].bHeld;

should be changed to

pKeys[i].bPressed = true;

This improves clarity and results in the same functionality.

Proof that functionality does not change:
(1) the referenced line of code is only reachable when the two if conditions are met: pStateNew[i] != pStateOld[i] && pStateNew[i]
(2) therefore, the line of code is reached when the button was not active on the previous frame but active on the current frame
(3) therefore, since the button was not active on the previous frame, pKeys[i].bHeld == false
(4) therefore, !pKeys[i].bHeld == true always

The step I might be wrong is (3). Let me know if I am missing some way where pKeys[i].bHeld == true and the button be inactive on the previous frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant