Easier joystick, mouse and keyboard input handling in Bevy

Overview

EZInput

Easier joystick, mouse and keyboard input handling in Bevy

Table of contents

  1. Getting started
  2. Examples

Getting Started

From GitHub

Add the following to your Cargo.toml:

[dependencies]
ezinput = { git = "https://github.com/HexaliteStudios/ezinput" }
ezinput_macros = { git = "https://github.com/HexaliteStudios/ezinput" }

From crates.io

version

Add the following to your Cargo.toml (replace x.y with the latest version):

[dependencies]
ezinput = "x.y"
ezinput_macros = "x.y"
You might also like...
A example bevy application using bevy-kajiya for its renderer
A example bevy application using bevy-kajiya for its renderer

☀️ bevy-kajiya playground A example bevy application using bevy-kajiya for its renderer NOTE: only tested on Windows. For more context, check out the

A collection of exponentially-smoothed camera controllers for the Bevy Engine.

smooth-bevy-cameras A collection of exponentially-smoothed camera controllers for the Bevy Engine. Look Transform All controllers are based on a LookT

Bevy plugin to help implement loading states

This is a plugin for the Bevy game engine, to help you implement loading states.

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap

bevy_ecs_ldtk An ECS-friendly ldtk plugin for bevy. Uses bevy_ecs_tilemap as a base. Not released yet, still in development. bevy_ecs_tilemap once sup

An ability / resource / cooldown management library for Bevy.

About leafwing-abilities is an opinionated, ready-to-use Bevy library and plugin for handling abilities. It features: cooldown tracking resource manag

Here are a few cargo-generate templates for use when creating bevy applications
Here are a few cargo-generate templates for use when creating bevy applications

Bevy-template-rs Here are a few cargo-generate templates for use when creating bevy applications. Templates Game This is a template for starting a new

Composable Alternatives to Bevy's RunCriteria, States, FixedTimestep

Composable Alternatives to Bevy's RunCriteria, States, FixedTimestep This crate offers alternatives to the Run Criteria, States, and FixedTimestep sch

Inverse kinematics plugin for Bevy implementing the FABRIK algorithm.

Inverse kinematics plugin for Bevy implementing the FABRIK algorithm.

A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

Comments
  • Not working with wasm

    Not working with wasm

    When I try to run in in WASM, the game freezes when I hit a key and I get this in the console:

    panicked at 'time not implemented on this platform', library/std/src/sys/wasm/../unsupported/time.rs:13:9
    
    Stack:
    
    init/imports.wbg.__wbg_new_693216e109162396@http://127.0.0.1:1334/api/wasm.js:402:11
    console_error_panic_hook::hook::hd43dab39c1b4d728@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[5232]:0x7382b4
    core::ops::function::Fn::call::hbcafa04924ac8fe3@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[30565]:0xa73366
    std::panicking::rust_panic_with_hook::h47a0e203360b6c10@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[10643]:0x91727b
    std::panicking::begin_panic::{{closure}}::h0a2ac8d8166919c8@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[21124]:0xa45a4c
    std::sys_common::backtrace::__rust_end_short_backtrace::h3b68e15c55c8ecfa@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[23824]:0xa5b9fe
    std::panicking::begin_panic::h11967a7fb7837f40@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[21303]:0xa479b4
    std::sys::wasm::time::Instant::now::h98dff29c0747cfdf@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[26731]:0xa68e54
    std::time::Instant::now::he732085a9da86d6b@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[30598]:0xa73471
    ezinput::tick::tick_system::{{closure}}::h42bf63e436677384@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[17445]:0xa0b612
    ezinput::tick::tick_system::update_time::h1f527bc26e94fa5d@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[22037]:0xa4f1d2
    ezinput::tick::tick_system::hc79dab676af0f3c2@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[3500]:0x636d03
    core::ops::function::FnMut::call_mut::had64b42826756baf@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[19870]:0xa35de3
    core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::he482dc8ace2d5404@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[19871]:0xa35e17
    <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,),()>>::run::call_inner::ha8f523b33f28f7cb@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[18051]:0xa18177
    <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,),()>>::run::hdac9d7adf3a961ed@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[16642]:0x9f7d3d
    <bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::h1310d6b28a33e78c@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[20967]:0xa43d92
    <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h2ee523cac9d87440@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[2286]:0x53c40c
    async_task::raw::RawTask<F,T,S>::run::he95d3c13f0abdc47@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[1486]:0x437f32
    async_task::runnable::Runnable::run::h169f4888c01aafa4@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[26668]:0xa68a84
    async_executor::LocalExecutor::try_tick::h7076019877a16c0d@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[9345]:0x8c7a27
    bevy_tasks::single_threaded_task_pool::TaskPool::scope::h31d7e491347f511d@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[3277]:0x60e5fd
    <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::h022b464f80f9a2dc@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[1215]:0x3c83dd
    <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::h516f05dc5ca94e48@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[382]:0xfbfdb
    <bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run::h68d5a2c1d54d961e@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[5698]:0x772b26
    bevy_app::app::App::update::he2df84884381384b@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[9160]:0x8bab1a
    winit::platform_impl::platform::event_loop::EventLoop<T>::run::{{closure}}::he7bb15fbd04f283f@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[421]:0x176ed3
    winit::platform_impl::platform::event_loop::runner::Shared<T>::handle_event::h57dac68780f61f30@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[2937]:0x5cd29c
    winit::platform_impl::platform::event_loop::runner::Shared<T>::run_until_cleared::h57d424e418c6d456@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[2655]:0x592212
    winit::platform_impl::platform::backend::timeout::AnimationFrameRequest::new::{{closure}}::hdda506bb48b4610c@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[18655]:0xa22f48
    <dyn core::ops::function::FnMut<()>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::he00844d1a1abf775@http://127.0.0.1:1334/api/wasm.wasm:wasm-function[22486]:0xa52949
    __wbg_adapter_51@http://127.0.0.1:1334/api/wasm.js:243:6
    real@http://127.0.0.1:1334/api/wasm.js:200:32
    
    
    wasm.js:414:9
    
    opened by idanarye 6
  • just_pressed does not work correctly

    just_pressed does not work correctly

    How to reproduce:

    1. Copy the setup from examples/singleplayer.rs
    2. Replace the code in check_input with this
    use EnumeratedBinding::*;
    use EnumeratedMovementBinding::*;
    
    if let Some(vertical) = query.single().axis(&Movement(Vertical)).first() {
        if vertical.press.just_pressed() {
            println!("just pressed");
        }
    }
    

    Issues:

    1. This code will print "just pressed" more than once when a key for the Vertical axis is pressed.
    2. If the key is held down and auto-repeat is enabled in the OS (it's enabled for me in Windows 10) it will print every frame once auto-repeat starts.

    I believe that 1. is caused by using a fixed value of 75ms in src/press_state.rs instead of something like deltaTime

    // just_pressed
    if let Some(instant) = started_pressing_instant {
        instant.elapsed().as_millis() <= 75
    } else {
        true
    }
    

    but I don't know what would cause 2. (the auto-repeat issue)

    opened by dis-da-moe 3
  • Close #2 - update Bevy version to 0.7

    Close #2 - update Bevy version to 0.7

    Looks like it works just like that - no code changes required.

    I did not change the crate's version - that's your job to decide (e.g. - should the macro crate's version change too?)

    opened by idanarye 1
Owner
Pedro Henrique
🌠 Lead developer at @HexaliteStudios. Backend developer, freelancer and software engineering student.
Pedro Henrique
CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a "plotable" format.

Lighthouse Groupie CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a "plotable" form

Polestar 1 Jan 12, 2022
Tool to make Solus packaging even easier.

A small tool to make packaging for Solus even easier. Features Remove all packages from the local solbuild repo.

null 5 Oct 19, 2022
A firmware for the Clueboard 66% Low Profile keyboard implemented in Rust.

Rust Firmware for Clueboard 66% Low Profile Keyboard A firmware for the Clueboard 66% Low Profile keyboard (also known as 66% hotswap) implemented in

Wesley Moore 10 Nov 2, 2022
A keyboard layout optimizer for layouts of the

Keyboard Layout Optimizer Neo variant layout optimizer written in rust. The optimizer is based on the "evolve-keyboard-layout" scripts by ArneBab. It

Dario Götz 29 Jan 4, 2023
Linux Advanced keyboard customizer

A multi-mode, rule-based keyboard customizer Features Key Remapping Execute command Install

秋葉 3 Apr 4, 2022
69-key split mechanical keyboard (PCB, case, firmware)

ErgoNICE An open source 69-key column-staggered split mechanical keyboard with a rotary knob, extra connectors, a 3D printed case with "floating key"

null 12 Oct 1, 2022
ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust)

ESP32-C3 interfacing to a PS/2 Keyboard (bare-metal Rust) Very simplified example of connecting a PS/2 keyboard to ESP32-C3 You need to build it with

Björn Quentin 3 Dec 5, 2022
`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

fugit fugit provides a comprehensive library of Duration and Instant for the handling of time in embedded systems, doing all it can at compile time. T

Emil Fresk 40 Oct 2, 2022
Rust library for program synthesis of string transformations from input-output examples 🔮

Synox implements program synthesis of string transformations from input-output examples. Perhaps the most well-known use of string program synthesis in end-user programs is the Flash Fill feature in Excel. These string transformations are learned from input-output examples.

Anish Athalye 21 Apr 27, 2022
Semantic input library for games in Rust

Keybee Keybee is a semantic input binding library. It's currently an early proof of concept that has been extracted from a larger game project, modifi

Lucien Greathouse 7 Aug 27, 2022