Skip to content

Commit 40dd9b4

Browse files
committed
Also document is_(just_)?(pressed|released)
There is a bug here which we'll fix at some later point.
1 parent 8e8d9d3 commit 40dd9b4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

agb/src/input.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,20 @@ impl ButtonController {
249249
}
250250

251251
#[must_use]
252-
/// Returns `true` if the provided keys are all pressed, and `false` if not.
252+
/// Returns `true` if any of the provided keys are pressed.
253253
pub fn is_pressed(&self, keys: Button) -> bool {
254254
let currently_pressed = u32::from(self.current);
255255
let keys = keys.bits();
256256
(currently_pressed & keys) != 0
257257
}
258258

259-
/// Returns true if all the buttons specified in `keys` are not pressed. Equivalent to `!is_pressed(keys)`.
259+
/// Returns true if all of the buttons specified in `keys` are not pressed. Equivalent to `!is_pressed(keys)`.
260260
#[must_use]
261261
pub fn is_released(&self, keys: Button) -> bool {
262262
!self.is_pressed(keys)
263263
}
264264

265-
/// Returns true if all the buttons specified in `keys` went from not pressed to pressed in the last frame.
265+
/// Returns true the buttons specified in `keys` went from not pressed to pressed in the last frame.
266266
/// Very useful for menu navigation or selection if you want the players actions to only happen for one frame.
267267
///
268268
/// # Example
@@ -285,6 +285,11 @@ impl ButtonController {
285285
/// }
286286
/// # }
287287
/// ```
288+
///
289+
/// ## Bug
290+
///
291+
/// This has confusing behaviour if you pass more than one button to `keys` (via the `|` operator). This will be
292+
/// fixed in the next release of `agb`.
288293
#[must_use]
289294
pub fn is_just_pressed(&self, keys: Button) -> bool {
290295
let current = u32::from(self.current);
@@ -293,8 +298,13 @@ impl ButtonController {
293298
((current & keys) != 0) && ((previous & keys) == 0)
294299
}
295300

296-
/// Returns true if all the buttons specified in `keys` went from pressed to not pressed in the last frame.
301+
/// Returns true if the button specified in `keys` went from pressed to not pressed in the last frame.
297302
/// Very useful for menu navigation or selection if you want players actions to only happen for one frame.
303+
///
304+
/// # Bug
305+
///
306+
/// This has confusing behaviour if you pass more than one button to `keys` (via the `|` operator). This will be
307+
/// fixed in the next release of `agb`.
298308
#[must_use]
299309
pub fn is_just_released(&self, keys: Button) -> bool {
300310
let current = u32::from(self.current);

0 commit comments

Comments
 (0)