Closed joshgoebel closed 8 years ago
readButtonState() // ?
readButtons() // ?
I could imagine read used here.
Like I said in PR #23, I kind of like just buttonState()
.
It certainly works with:
boolean Arduboy::pressed(uint8_t buttons)
{
return (buttonState() & buttons) == buttons;
}
and pretty much every other use I can think of.
You can't write to buttons, so read is implied.
The word state is very programmery, but so is poll. Condition is silly though. Is there much better word I'm not thinking of?
The word state is very programmery
I don't know if I agree about that. State has pretty much the same meaning outside of programming. E.g. "State of the Union", "In a confused state". So, I think buttonState is fairly descriptive. Even the Doxygen comments for getInput currently begin with:
// get current state of buttons (bitmask)
And @yyyc514, you yourself used button_state = getInput()
when you wrote function pressed().
Besides, people using the function will be programmers, or if they're "programmers in training" they should be expected to become familiar with the meaning of state in this context.
I agree that condition doesn't sound right. The only other I can think of is buttonPositions(), which I'm not too keen on.
It's maybe a bit more descriptive to use the plural buttonsState(), but that reads kind of strange.
buttonsState()
I like. It's clear that it's polling multiple buttons (not just returning one) and again this is low-level and people using it should understand what it does.
buttonsState()
I like
That's fine with me then. :smile:
Or pollButtonState()? pollButtonStatus()? getInput is too generic and makes me write library code like:
I do that because to me getInput is opaque and I want clarity. What input exactly am I getting? But then I realized the real problem is the name of the method, it could be more descriptive.
Not many should use this directly but we should still have the best name possible