Expand description
Library for enabling rumble functionality on the Game Boy Advance.
This crate supports rumble through both the cartridge itself using general purpose I/O (GPIO) and the Game Boy Player’s rumble functionality. Functionality is provided for detecting available rumble features and using them fully.
The library is designed to be usable regardless of what other GBA development libraries may be
in use. It is usable with popular libraries like gba and
agb.
§Usage
There are two ways to use this library: by using a cartridge’s built-in rumble through Gpio
and by using the Game Boy Player’s rumble functionality through GameBoyPlayer. These two
can also both be used to enable Game Boy Player rumble with cartridge rumble as a fallback.
§Cartridge (GPIO) Rumble
To use a cartridge’s built-in rumble through general purpose I/O (GPIO), use the Gpio
struct. No detection logic is available, as there is no reliable way to detect GPIO rumble.
Calling these functions when rumble is not available will do nothing.
let gpio = gba_rumble::Gpio;
// Activate the cartridge's rumble. This will continue until `stop()` is called.
gpio.start();
// Deactivate the cartridge's rumble.
gpio.stop();§Game Boy Player
To use the Game Boy Player’s rubmle functionality, you must detect the Game Boy Player by
calling GameBoyPlayer::detect() at the beginning of your program. If the program is being
run on a Game Boy Player, a GameBoyPlayer object will be returned, through which you can
start and stop rumble.
Communication with the Game Boy Player is done through the serial point. This is done by
calling game_boy_player_interrupt() when a serial interrupt is received. Setting this up
will be specific to your own code and any frameworks you may be using; for examples using the
gba or agb crates, see
/examples.
if let Some(game_boy_player) = gba_rumble::GameBoyPlayer::detect() {
// When a Game Boy Player is detected, you can interact with it through the returned
// `GameBoyPlayer` object.
//
// To actually use it, you must also call `game_boy_player_interrupt()` when a serial
// interrupt is received. This will be specific to your own code and any frameworks you may
// be using.
// Update the serial connection once a frame.
game_boy_player.update();
// Activate rumble in the controller. This will continue until `stop()` or `hard_stop()`
// is called.
game_boy_player.start();
// Deactivate rumble in the controller.
game_boy_player.stop();
// You can also deactivate rumble in the controller with a hard stop. This has a different
// feel than `stop()`.
game_boy_player.hard_stop();
}Structs§
- Game
BoyPlayer - Game Boy Player rumble functionality.
- Gpio
- Cartridge rumble functionality.
Functions§
- game_
boy_ player_ interrupt - Handles SIO interrupts for every stage of the Game Boy Player communication process.