Crates.io | bevy_prototype_input_map |
lib.rs | bevy_prototype_input_map |
version | 0.1.6 |
source | src |
created_at | 2020-09-07 10:47:18.178247 |
updated_at | 2020-11-21 07:44:59.691829 |
description | **DISCONTINUED** Please use Kurinji |
homepage | |
repository | https://github.com/PradeepKumarRajamanickam/kurinji |
max_upload_size | |
id | 285668 |
size | 174,164 |
NOTE* bevy_prototype_input_map is now Kurinji. This crate has been discontinued. Please use Kurinji.
Kurinji v1.0.1 Now available on crate.io https://crates.io/crates/kurinji
** - DISCONTINUED - **
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]
bevy_prototype_input_map = "0.1"
In code
fn main() {
App::build()
.add_plugin(InputMapPlugin::default())
.add_startup_system(setup.system())
.add_system(system.system())
.run();
}
fn setup(
mut input_map: ResMut<InputMap>,
) {
input_map
.bind_keyboard_pressed(KeyCode::Return, "SHOOT")
.bind_mouse_motion(Axis::YNegative, "AIM_UP")
.set_dead_zone("AIM_UP", 0.1)
}
// system
fn system(input_map: Res<InputMap>) {
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
https://github.com/PradeepKumarRajamanickam/bevy_input_map/
Note* Latest commit on master branch might be unstable. Use the release tags if you are looking for stable commits or grab crate from crate.io
https://github.com/PradeepKumarRajamanickam/bevy_input_map/issues
Pradeep Kumar Rajamanickam
Inspired by