Semantic input library for games in Rust

Related tags

Miscellaneous keybee
Overview

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, modified, and not well tested.

Keybee is built around straightforward core primitives:

  • Session holds all state for an application
  • Action defines anything a player can do, like jump or move
  • ActionSet groups together related actions
  • Bindings assigns inputs to actions

Features

  • winit: Enable support for winit events
  • gilrs: Enable support for gil-rs events

Getting Started

use keybee::{Session, EventAction, Clamped, Axis2dAction};

let session = keybee::Session::new();

let gameplay = session.create_action_set("gameplay");
let jump = gameplay.create_action("jump", EventAction);
let movement = gameplay.create_action("movement", Clamped(Axis2dAction));

// Keybee will have support for deserializing bindings from files, but for now,
// this isn't quite done.
session.use_bindings(todo!("load bindings from somewhere"));

loop {
    // Enable the `winit` or `gilrs` features to pass their events like this:
    session.handle_event(some_event);

    if jump.get() {
        println!("Player jumped!");
    }

    let translate = movement.get();
    if translate != [0.0, 0.0] {
        println!("Player movement vector: {:?}", translate);
    }

    // At the end of every game tick, run `end_update` to reset relative axis
    // movements and button presses.
    session.end_update();
}

Future Improvements

  • Support for multiple players
  • Other backends: SDL, others

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
An asynchronous Rust client library for the Hashicorp Vault API

vaultrs An asynchronous Rust client library for the Hashicorp Vault API The following features are currently supported: Auth AppRole JWT/OIDC Token Us

Culture ship names in a rust library.

General Systems Vehicles Culture Ships In case you ever needed Iain M. Banks's Culture ship names as a service. Names sourced from the pleasingly exte

Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects

Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects. It uses reqwest as its HTTP(S) client and deserialises responses to typed structs using serde.

Wrapper library for utilizing DigitalOcean API v2 in Rust

doapi-rs Wrapper library for utilizing DigitalOcean API v2 in Rust Disclaimer This library is in alpha - it may do anything up to, and including, eati

Rust LZ4 bindins library

lz4 This repository contains binding for lz4 compression library (https://github.com/Cyan4973/lz4). LZ4 is a very fast lossless compression algorithm,

Noto-sans-mono-bitmap (Rust library)
Noto-sans-mono-bitmap (Rust library)

noto-sans-mono-bitmap (Rust library) Pre-rasterized bitmap font from "Noto Sans Mono", an open font from Google. Original font files taken from: https

Serenity is a Rust library for the Discord API
Serenity is a Rust library for the Discord API

serenity Serenity is a Rust library for the Discord API. View the examples on how to make and structure a bot. Serenity supports bot login via the use

Deser: an experimental serialization and deserialization library for Rust

deser: an experimental serialization and deserialization library for Rust Deser is an experimental serialization system for Rust. It wants to explore

An (unofficial) Rust library for querying db-ip.com data

db_ip An (unofficial) library for querying db-ip.com CSV databases in safe Rust. This library is not affiliated with or endorsed by db-ip.com. Be advi

Comments
  • Support gamepad virtual cursor

    Support gamepad virtual cursor

    Some games like Destiny 2 have a virtual cursor that can be moved with a gamepad. We should make changes to our state management to make this sorta thing possible.

    opened by LPGhatguy 0
  • Multiple input keys

    Multiple input keys

    We should be able to bind keys like shift+P. If a binding like this is set, then anything bound to just P should not trigger if shift is held down. This is how WoW works. Maybe there are cases where it shouldn't work this way?

    opened by LPGhatguy 1
  • Semantic action type names

    Semantic action type names

    Action type names should reflect the meaning of the action, not the mechanism used to trigger it (which may vary). For example, ButtonAction and ButtonHeldAction might be more descriptively named EventAction and BooleanAction to reflect their behavior rather than one possible input device. This should preempt confusion about e.g. why ButtonAction might yield false while a button is pressed.

    opened by Ralith 0
Owner
Lucien Greathouse
Previously @Roblox, @UpliftGames.
Lucien Greathouse
Easier joystick, mouse and keyboard input handling in Bevy

Easier joystick, mouse and keyboard input handling in Bevy

Pedro Henrique 31 Dec 20, 2022
A highly modular Bitcoin Lightning library written in Rust. Its Rust-Lightning, not Rusty's Lightning!

Rust-Lightning is a Bitcoin Lightning library written in Rust. The main crate, lightning, does not handle networking, persistence, or any other I/O. Thus, it is runtime-agnostic, but users must implement basic networking logic, chain interactions, and disk storage. More information is available in the About section.

Lightning Dev Kit 850 Jan 3, 2023
Rust library that can be reset if you think it's slow

GoodbyeKT Rust library that can be reset if you think it's slow

null 39 Jun 16, 2022
Notion Offical API client library for rust

Notion API client library for rust.

Jake Swenson 65 Dec 26, 2022
SE3 Rust library for Robotics

Algebraic Robots A small Rust Library for SE3 Supported: Twist Screw SE3 Group se3 algebra Adjoint SE3 Twist Chains Wrenches Future plans: Jacobians V

Pau Carré Cardona 4 Jul 18, 2021
Rust library for emulating RISC-V rv32imac

This library can execute instructions against any memory and register file that implements the required primitives in the traits lib_rv32::traits::{Memory, RegisterFile}. This is to encourage usage with whatever frontend you desire.

Trevor McKay 14 Dec 7, 2022
Yet another ROS2 client library written in Rust

RclRust Target CI Status Document Foxy (Ubuntu 20.04) Introduction This is yet another ROS2 client library written in Rust. I have implemented it inde

rclrust 42 Dec 1, 2022
A boiler plate code to create dynamic link library in rust.

?? rust-dll-bp This is a boiler plate code that will be generated as a dll binary. I personally cache this here for me but if you're intend to create

s3pt3mb3r 9 Nov 7, 2022
Rust telegram bot library for many runtimes

Telbot Telbot provides telegram bot types and api wrappers. Specifically, telbot now supports: telbot-types: basic telegram types / requests / respons

kiwiyou 17 Dec 3, 2022
Strongly typed Gura library for Rust

Serde Gura This crate is a Rust library for using the Serde serialization framework with data in Gura file format. This library does not re-implement

Gura Config Lang 12 Nov 14, 2022