NOTE* Kurinji is not being actively maintained/developed. Please try other plugins for newer Bevy versions. Reason for discontinuing is Bevy is still in its infacy and not very mature i.e. lot of breaking API change between releases requiring more time and effort. Combined with the lack of motivation on my part to continously update. I have decided to pause any development on Bevy plugins for the time being.
Input map plugin for bevy
(Note* Previously called bevy_prototype_input_map)
Decouples gameplay code from device specific input api. Converts user inputs from different input hardware into game specific actions, eg. keyboard "Space" or joystick "A" can be mapped to "Jump" Action.
Add to Cargo.toml dependencies
[dependencies]
kurinji = "*"
fn main() {
App::build()
.add_plugin(KurinjiPlugin::default())
.add_startup_system(setup.system())
.add_system(system.system())
.run();
}
fn setup(
mut kurinji: ResMut<Kurinji>,
) {
// with data
// refer "example/config/gamepad.ron"
let binding_ron = fs::read_to_string("example/config/gamepad.ron").unwrap()
kurinji.set_bindings_with_ron(&binding_ron);
// or
// via code
kurinji
.bind_keyboard_pressed(KeyCode::Return, "SHOOT")
.bind_mouse_motion(Axis::YNegative, "AIM_UP")
.set_dead_zone("AIM_UP", 0.1)
}
// system
fn system(kurinji: Res<Kurinji>) {
if input_map.is_action_active("SHOOT") {
println!("Bang...");
}
*Check out examples
Use commands
Via Code
cargo run --example keyboard_mouse_with_code
cargo run --example gamepad_with_code
Via JSON/RON
cargo run --example keyboard_mouse_with_json
cargo run --example gamepad_with_ron
For Action Events Usage
cargo run --example with_action_events
- Supports: Keyboard, Mouse and Joystick inputs
- Action Events: OnActionBegin, OnActionProgress, OnActionEnd
- Event Phase: Ability to set at which event phase an action is active
- JSON/RON Support: Ability to use serialised string to setup bindings
- Binding Stack: Ability to Push, Additive Push and Pop bindings
- Action Strength & Deadzone
- Custom Strength Curve
Note* Latest commit on master branch might be unstable. Use the release tags if you are looking for stable commits or grab crate from https://crates.io/crates/kurinji
https://github.com/PradeepKumarRajamanickam/kurinji/issues
- Upgrade to Bevy 0.4.0
- author: @Nolan Darilek
- fixed* clippy warnings
- fixed* Joystick axis inputs not detected
- fixed* Events not behaving as expected #36
- rebranded* as Kurinji
- Joystick Support
- Improved Documentations
- Event Phase
- Action Events
- Binding Stack
- JSON & RON Support
- New API
- Ability to set custom strength curve
- minor* Readme changes
- Had to bump the version to publish some readme changes
- Keyboard Key Mapping
- Key press can now be binded to action
- Mouse Button Mapping
- Mouse button press can now be binded to action
- Mouse Move Mapping
- Mouse move event can now be mapped to action
- Action Strength
- Can now query strength of an action.
- It will be in range of 0.0 - 1.0
- Useful for analog inputs like joystick
- Action Deadzone
- For analog inputs sometimes it is meaningful to have a min threshold to avoid small input noise and to reduce sensitivity
Pradeep Kumar Rajamanickam
Inspired by
- Godot Input Mapper [https://godotengine.org/article/handling-axis-godot]
- Unreal Action/Axis Mapping [https://docs.unrealengine.com/en-US/Gameplay/Input/index.html]