Skip to main content

yog_event/
key_binding.rs

1//! Key bindings mods declare: keys the player sees and rebinds in the
2//! game's controls; presses come as `client::input::Binding`.
3
4use yog_data::Schema;
5
6/// A key binding (the `key_binding/declare` service, declared while the mod registers; the game keeps the key).
7#[derive(Debug, Clone, PartialEq, Schema)]
8pub struct KeyBindingSpec {
9    /// Its id (`mymod:xray`), the key of its presses.
10    pub id: String,
11    /// Its label's translation key.
12    pub name: String,
13    /// A GLFW key code; `-1`: unbound.
14    pub default_key: i32,
15}
16
17/// Every declared key binding, for the host.
18#[derive(Debug, Clone, Schema)]
19pub struct Declared {}
20
21/// A declared key binding as the host registers it: under its mod's category.
22#[derive(Debug, Clone, PartialEq, Schema)]
23pub struct CategorizedBinding {
24    pub id: String,
25    pub name: String,
26    pub default_key: i32,
27    /// The category's label: its mod's name (its namespace when no mod has it).
28    pub category: String,
29}