cotis-utils 0.1.0-alpha

Modular Rust UI framework core
Documentation
use indexmap::IndexSet;

/// Normalized keyboard key identifiers used by Cotis input providers.
///
/// Values intentionally match platform/backend key tables used by Cotis
/// integrations (GLFW/raylib style codes, plus Android keys).
#[repr(i32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum KeyboardKey {
    KeyNull = 0,
    KeyApostrophe = 39,
    KeyComma = 44,
    KeyMinus = 45,
    KeyPeriod = 46,
    KeySlash = 47,
    KeyZero = 48,
    KeyOne = 49,
    KeyTwo = 50,
    KeyThree = 51,
    KeyFour = 52,
    KeyFive = 53,
    KeySix = 54,
    KeySeven = 55,
    KeyEight = 56,
    KeyNine = 57,
    KeySemicolon = 59,
    KeyEqual = 61,
    KeyA = 65,
    KeyB = 66,
    KeyC = 67,
    KeyD = 68,
    KeyE = 69,
    KeyF = 70,
    KeyG = 71,
    KeyH = 72,
    KeyI = 73,
    KeyJ = 74,
    KeyK = 75,
    KeyL = 76,
    KeyM = 77,
    KeyN = 78,
    KeyO = 79,
    KeyP = 80,
    KeyQ = 81,
    KeyR = 82,
    KeyS = 83,
    KeyT = 84,
    KeyU = 85,
    KeyV = 86,
    KeyW = 87,
    KeyX = 88,
    KeyY = 89,
    KeyZ = 90,
    KeyLeftBracket = 91,
    KeyBackslash = 92,
    KeyRightBracket = 93,
    KeyGrave = 96,
    KeySpace = 32,
    KeyEscape = 256,
    KeyEnter = 257,
    KeyTab = 258,
    KeyBackspace = 259,
    KeyInsert = 260,
    KeyDelete = 261,
    KeyRight = 262,
    KeyLeft = 263,
    KeyDown = 264,
    KeyUp = 265,
    KeyPageUp = 266,
    KeyPageDown = 267,
    KeyHome = 268,
    KeyEnd = 269,
    KeyCapsLock = 280,
    KeyScrollLock = 281,
    KeyNumLock = 282,
    KeyPrintScreen = 283,
    KeyPause = 284,
    KeyF1 = 290,
    KeyF2 = 291,
    KeyF3 = 292,
    KeyF4 = 293,
    KeyF5 = 294,
    KeyF6 = 295,
    KeyF7 = 296,
    KeyF8 = 297,
    KeyF9 = 298,
    KeyF10 = 299,
    KeyF11 = 300,
    KeyF12 = 301,
    KeyLeftShift = 340,
    KeyLeftControl = 341,
    KeyLeftAlt = 342,
    KeyLeftSuper = 343,
    KeyRightShift = 344,
    KeyRightControl = 345,
    KeyRightAlt = 346,
    KeyRightSuper = 347,
    KeyKbMenu = 348,
    KeyKp0 = 320,
    KeyKp1 = 321,
    KeyKp2 = 322,
    KeyKp3 = 323,
    KeyKp4 = 324,
    KeyKp5 = 325,
    KeyKp6 = 326,
    KeyKp7 = 327,
    KeyKp8 = 328,
    KeyKp9 = 329,
    KeyKpDecimal = 330,
    KeyKpDivide = 331,
    KeyKpMultiply = 332,
    KeyKpSubtract = 333,
    KeyKpAdd = 334,
    KeyKpEnter = 335,
    KeyKpEqual = 336,
    KeyBack = 4,
    KeyMenu = 5,
    KeyVolumeUp = 24,
    KeyVolumeDown = 25,
}
use KeyboardKey::*;
/// Full key list for integrations that poll every key each frame.
pub const KEYBOARD_LIST: [KeyboardKey; 110] = [
    KeyNull,
    KeyApostrophe,
    KeyComma,
    KeyMinus,
    KeyPeriod,
    KeySlash,
    KeyZero,
    KeyOne,
    KeyTwo,
    KeyThree,
    KeyFour,
    KeyFive,
    KeySix,
    KeySeven,
    KeyEight,
    KeyNine,
    KeySemicolon,
    KeyEqual,
    KeyA,
    KeyB,
    KeyC,
    KeyD,
    KeyE,
    KeyF,
    KeyG,
    KeyH,
    KeyI,
    KeyJ,
    KeyK,
    KeyL,
    KeyM,
    KeyN,
    KeyO,
    KeyP,
    KeyQ,
    KeyR,
    KeyS,
    KeyT,
    KeyU,
    KeyV,
    KeyW,
    KeyX,
    KeyY,
    KeyZ,
    KeyLeftBracket,
    KeyBackslash,
    KeyRightBracket,
    KeyGrave,
    KeySpace,
    KeyEscape,
    KeyEnter,
    KeyTab,
    KeyBackspace,
    KeyInsert,
    KeyDelete,
    KeyRight,
    KeyLeft,
    KeyDown,
    KeyUp,
    KeyPageUp,
    KeyPageDown,
    KeyHome,
    KeyEnd,
    KeyCapsLock,
    KeyScrollLock,
    KeyNumLock,
    KeyPrintScreen,
    KeyPause,
    KeyF1,
    KeyF2,
    KeyF3,
    KeyF4,
    KeyF5,
    KeyF6,
    KeyF7,
    KeyF8,
    KeyF9,
    KeyF10,
    KeyF11,
    KeyF12,
    KeyLeftShift,
    KeyLeftControl,
    KeyLeftAlt,
    KeyLeftSuper,
    KeyRightShift,
    KeyRightControl,
    KeyRightAlt,
    KeyRightSuper,
    KeyKbMenu,
    KeyKp0,
    KeyKp1,
    KeyKp2,
    KeyKp3,
    KeyKp4,
    KeyKp5,
    KeyKp6,
    KeyKp7,
    KeyKp8,
    KeyKp9,
    KeyKpDecimal,
    KeyKpDivide,
    KeyKpMultiply,
    KeyKpSubtract,
    KeyKpAdd,
    KeyKpEnter,
    KeyKpEqual,
    KeyBack,
    KeyMenu,
    KeyVolumeUp,
    KeyVolumeDown,
];

/// Provides the current set of pressed keys for the active frame.
///
/// The returned set is state-based (keys currently down), not edge-triggered.
pub trait SimpleKeyboardProvider {
    /// Returns keys currently pressed.
    fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>;
}

/// Provides the characters typed during the current frame.
pub trait SimpleTextProvider {
    /// Returns entered characters in backend-provided order.
    fn get_pressed_chars(&self) -> Vec<char>;
}