README

Milky2018/selene/inputs does not have a README file

#
Code

pub(all) enum Code {
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
ArrowUp
ArrowDown
ArrowLeft
ArrowRight
Tab
ShiftLeft
Space
Enter
Escape
} derive(Eq, Hash,
Debug
)

Keyboard key code representing a specific key on the keyboard.

Example:

let key_code = @inputs.Code::from_string("KeyA")
inspect(key_code, content="Some(KeyA)")

// Check if a key is currently pressed
if @inputs.is_pressed(KeyW) {
println("W key is being held down")
}

// Check if a key was just pressed this frame
if @inputs.is_just_pressed(Space) {
println("Space was just pressed")
}

#
Code::from_string

fn Code::from_string(code : String) -> Code?

Converts a string representation of a keyboard key into its corresponding Code enum variant.

Parameters:

  • code : The string representation of the keyboard key (e.g., "KeyA", "Space", "ArrowUp").

Returns Some(Code) if the string matches a valid key code, or None if the string is not recognized.

Example:

let key_a = @inputs.Code::from_string("KeyA")
inspect(key_a, content="Some(KeyA)")

let space_key = @inputs.Code::from_string("Space")
inspect(space_key, content="Some(Space)")

let invalid_key = @inputs.Code::from_string("InvalidKey")
inspect(invalid_key, content="None")

#
Gamepad

pub(all) struct Gamepad {
id : Int
} derive(Eq, Hash,
Debug
)

Stable gamepad identifier.

#
Gamepad::Gamepad

fn Gamepad::Gamepad(id : Int) -> Gamepad

#
Gamepad::id

fn Gamepad::id(self : Gamepad) -> Int

#
GamepadAxis

pub(all) enum GamepadAxis {
LeftStickX
LeftStickY
RightStickX
RightStickY
LeftZ
RightZ
} derive(Eq, Hash,
Debug
)

Logical gamepad axis layout aligned with Bevy conventions.

#
GamepadAxisEvent

pub struct GamepadAxisEvent {
input : GamepadAxisInput
value : Double
delta : Double
}

#
GamepadAxisInput

pub(all) struct GamepadAxisInput {
gamepad : Gamepad
axis : GamepadAxis
} derive(Eq, Hash,
Debug
)

#
GamepadAxisInput::GamepadAxisInput

fn GamepadAxisInput::GamepadAxisInput(gamepad : Gamepad, axis : GamepadAxis) -> GamepadAxisInput

#
GamepadButton

pub(all) enum GamepadButton {
South
East
North
West
C
Z
LeftTrigger
LeftTrigger2
RightTrigger
RightTrigger2
Select
Start
Mode
LeftThumb
RightThumb
DPadUp
DPadDown
DPadLeft
DPadRight
} derive(Eq, Hash,
Debug
)

Logical gamepad button layout aligned with Bevy conventions.

#
GamepadButtonEvent

pub struct GamepadButtonEvent {
input : GamepadButtonInput
state : GamepadButtonInputState
}

#
GamepadButtonInput

pub(all) struct GamepadButtonInput {
gamepad : Gamepad
button : GamepadButton
} derive(Eq, Hash,
Debug
)

#
GamepadButtonInput::GamepadButtonInput

fn GamepadButtonInput::GamepadButtonInput(gamepad : Gamepad, button : GamepadButton) -> GamepadButtonInput

#
GamepadButtonInputState

pub(all) enum GamepadButtonInputState {
Pressed
Released
} derive(Eq,
Debug
)

#
GamepadConnectionEvent

pub struct GamepadConnectionEvent {
gamepad : Gamepad
connected : Bool
}

#
InputSnapshot

pub(all) struct InputSnapshot {
pressed_keys :
Set
[Code]
mouse : Mouse
mouse_relative_delta :
Vec2
?
mouse_wheel : MouseWheel
touches : Map[TouchId, TouchPoint]
touch_changes : Array[TouchEvent]
connected_gamepads :
Set
[Gamepad]
pressed_gamepad_buttons :
Set
[GamepadButtonInput]
gamepad_axis_values : Map[GamepadAxisInput, Double]
}

#
KeyInputEvent

pub struct KeyInputEvent {
key : Code
state : KeyInputState
}

#
KeyInputState

pub(all) enum KeyInputState {
Pressed
Released
} derive(Eq,
Debug
)

#
Mouse

pub(all) struct Mouse {
pos :
Vec2

left_button : Bool
right_button : Bool
middle_button : Bool
}

Mouse input state containing position and button states.

Fields:

  • pos : Current mouse cursor position as a 2D vector.
  • left_button : Whether the left mouse button is currently pressed.
  • right_button : Whether the right mouse button is currently pressed.
  • middle_button : Whether the middle mouse button is currently pressed.

Example:

// Access the global mouse state
inspect(@inputs.mouse.pos, content="Vec2(0, 0)")
inspect(@inputs.mouse.left_button, content="false")

#
MouseButton

pub(all) enum MouseButton {
Left
Right
Middle
} derive(Eq,
Debug
)

Mouse button identifier for input handling.

Constructors:

  • Left : The left mouse button
  • Right : The right mouse button
  • Middle : The middle mouse button (scroll wheel button)

#
MouseButtonEvent

pub struct MouseButtonEvent {
button : MouseButton
state : MouseButtonInputState
position :
Vec2

}

#
MouseButtonInputState

pub(all) enum MouseButtonInputState {
Pressed
Released
} derive(Eq,
Debug
)

#
MouseMotionEvent

pub struct MouseMotionEvent {
position :
Vec2

delta :
Vec2

}

#
MouseMovement

pub(all) struct MouseMovement {
movement :
Vec2

}

Mouse movement delta tracking container.

Fields:

  • movement : The movement vector representing the change in mouse position since the last frame.

Example:

// Access the global mouse movement
inspect(@inputs.mouse_movement.movement, content="Vec2(0, 0)")

// Update movement vector
@inputs.mouse_movement.movement = @math.Vec2(10.0, -5.0)

#
MouseWheel

pub(all) struct MouseWheel {
delta :
Vec2

}

#
MouseWheelEvent

pub struct MouseWheelEvent {
delta :
Vec2

}

#
PointerEvent

pub(all) struct PointerEvent {
id : PointerId
source : PointerSource
phase : PointerPhase
position :
Vec2

previous_position :
Vec2

delta :
Vec2

primary : Bool
}

#
PointerId

pub(all) struct PointerId {
source : PointerSource
value : Int
} derive(Eq, Hash,
Debug
)

#
PointerPhase

pub(all) enum PointerPhase {
Down
Move
Up
Cancel
} derive(Eq,
Debug
)

#
PointerSource

pub(all) enum PointerSource {
PointerMouse
PointerTouch
PointerPen
} derive(Eq, Hash,
Debug
)

#
TouchEvent

pub(all) struct TouchEvent {
id : TouchId
source : PointerSource
phase : TouchPhase
position :
Vec2

previous_position :
Vec2

delta :
Vec2

primary : Bool
}

#
TouchGestureEvent

pub(all) struct TouchGestureEvent {
kind : TouchGestureKind
primary_id : TouchId?
secondary_id : TouchId?
position :
Vec2

delta :
Vec2

scale : Double
distance : Double
duration : Double
}

#
TouchGestureKind

pub(all) enum TouchGestureKind {
Tap
LongPress
PanStart
PanMove
PanEnd
PanCancel
PinchStart
PinchMove
PinchEnd
PinchCancel
} derive(Eq,
Debug
)

#
TouchId

pub(all) struct TouchId {
value : Int
} derive(Eq, Hash,
Debug
)

#
TouchId::TouchId

fn TouchId::TouchId(value : Int) -> TouchId

#
TouchId::value

fn TouchId::value(self : TouchId) -> Int

#
TouchPhase

pub(all) enum TouchPhase {
Started
Moved
Ended
Cancelled
} derive(Eq,
Debug
)

#
TouchPoint

pub(all) struct TouchPoint {
id : TouchId
source : PointerSource
position :
Vec2

previous_position :
Vec2

delta :
Vec2

primary : Bool
}

#
VirtualAxis

pub(all) struct VirtualAxis {
name : String
} derive(Eq, Hash,
Debug
)

#
VirtualAxis::VirtualAxis

fn VirtualAxis::VirtualAxis(name : String) -> VirtualAxis

#
VirtualAxis::name

fn VirtualAxis::name(self : VirtualAxis) -> String

#
VirtualAxisEvent

pub(all) struct VirtualAxisEvent {
axis : VirtualAxis
value : Double
delta : Double
}

#
VirtualButton

pub(all) struct VirtualButton {
name : String
} derive(Eq, Hash,
Debug
)

#
VirtualButton::VirtualButton

fn VirtualButton::VirtualButton(name : String) -> VirtualButton

#
VirtualButton::name

fn VirtualButton::name(self : VirtualButton) -> String

#
VirtualButtonEvent

pub(all) struct VirtualButtonEvent {
button : VirtualButton
state : VirtualButtonInputState
}

#
VirtualButtonInputState

pub(all) enum VirtualButtonInputState {
Pressed
Released
} derive(Eq,
Debug
)

#
active_touches

fn active_touches() -> Map[TouchId, TouchPoint]

#
advanced_gamepad_system

fn advanced_gamepad_system(_delta : Double) -> Unit

#
advanced_key_system

fn advanced_key_system(_delta : Double) -> Unit

Updates the keyboard input state to track which keys were just pressed or released during the current frame.

Parameters:

  • delta : The time elapsed since the last frame update (currently unused but reserved for future timing-based features).

Example:

// This function is typically called once per frame by the game engine
@inputs.advanced_key_system(0.016) // 60 FPS = ~16ms per frame

// After calling advanced_key_system, you can check for just-pressed keys
if @inputs.is_just_pressed(@inputs.KeyW) {
println("W was just pressed this frame")
}

if @inputs.is_just_released(@inputs.Space) {
println("Space was just released this frame")
}

#
advanced_mouse_system

fn advanced_mouse_system(_delta : Double) -> Unit

Updates the mouse input system's state tracking for button press and release detection.

Parameters:

  • delta : The time elapsed since the last frame update (currently unused but reserved for future timing-based functionality).

Example:

inspect(@inputs.is_mouse_just_pressed(Left), content="false")
inspect(@inputs.is_mouse_pressed(Right), content="false")

#
advanced_pointer_system

fn advanced_pointer_system(_delta : Double) -> Unit

#
advanced_touch_system

fn advanced_touch_system(_delta : Double) -> Unit

#
apply_input_snapshot

fn apply_input_snapshot(snapshot : InputSnapshot) -> Unit

#
clear_touch_state

fn clear_touch_state() -> Unit

#
clear_virtual_controls

fn clear_virtual_controls() -> Unit

#
connected_gamepads

fn connected_gamepads() ->
Set
[Gamepad]

Connected gamepads in the current frame.

#
empty_input_snapshot

fn empty_input_snapshot() -> InputSnapshot

#
first_touch_change

fn first_touch_change(phase : TouchPhase) -> TouchEvent?

#
gamepad_axis_event_bus

#
gamepad_axis_value

fn gamepad_axis_value(gamepad : Gamepad, axis : GamepadAxis) -> Double

#
gamepad_axis_values

fn gamepad_axis_values() -> Map[GamepadAxisInput, Double]

Current axis values in the current frame.

#
gamepad_button_event_bus

#
gamepad_connection_event_bus

#
gamepad_left_stick

fn gamepad_left_stick(gamepad : Gamepad) ->
Vec2

#
gamepad_right_stick

fn gamepad_right_stick(gamepad : Gamepad) ->
Vec2

#
gamepad_triggers

fn gamepad_triggers(gamepad : Gamepad) ->
Vec2

#
is_gamepad_button_just_pressed

fn is_gamepad_button_just_pressed(gamepad : Gamepad, button : GamepadButton) -> Bool

#
is_gamepad_button_just_released

fn is_gamepad_button_just_released(gamepad : Gamepad, button : GamepadButton) -> Bool

#
is_gamepad_button_pressed

fn is_gamepad_button_pressed(gamepad : Gamepad, button : GamepadButton) -> Bool

#
is_gamepad_button_released

fn is_gamepad_button_released(gamepad : Gamepad, button : GamepadButton) -> Bool

#
is_gamepad_connected

fn is_gamepad_connected(gamepad : Gamepad) -> Bool

#
is_gamepad_just_connected

fn is_gamepad_just_connected(gamepad : Gamepad) -> Bool

#
is_gamepad_just_disconnected

fn is_gamepad_just_disconnected(gamepad : Gamepad) -> Bool

#
is_just_pressed

fn is_just_pressed(code : Code) -> Bool

Checks if a keyboard key was just pressed during the current frame.

Parameters:

  • code : The keyboard key code to check for recent press activity.

Returns true if the specified key was pressed this frame (transition from released to pressed state), false otherwise.

Example:

// Check if the space key was just pressed this frame
if @inputs.is_just_pressed(Space) {
println("Space key was just pressed!")
}

// Check for WASD movement keys
if @inputs.is_just_pressed(KeyW) {
println("Started moving forward")
}
if @inputs.is_just_pressed(KeyA) {
println("Started moving left")
}

#
is_just_released

fn is_just_released(code : Code) -> Bool

Checks if a keyboard key was just released during the current frame.

Parameters:

  • code : The keyboard key code to check for recent release activity.

Returns true if the specified key was released this frame (transition from pressed to released state), false otherwise.

Example:

// Check if the space key was just released this frame
if @inputs.is_just_released(Space) {
println("Space key was just released!")
}

// Check for WASD movement keys
if @inputs.is_just_released(KeyW) {
println("Stopped moving forward")
}
if @inputs.is_just_released(KeyA) {
println("Stopped moving left")
}

#
is_mouse_just_pressed

fn is_mouse_just_pressed(button : MouseButton) -> Bool

Checks if the specified mouse button was just pressed in the current frame.

Parameters:

  • button : The mouse button to check for just-pressed state.

Returns true if the specified mouse button was just pressed (transitioned from released to pressed) in the current frame, false otherwise.

Example:

inspect(@inputs.is_mouse_just_pressed(MouseButton::Left), content="false")

#
is_mouse_just_released

fn is_mouse_just_released(button : MouseButton) -> Bool

Checks if the specified mouse button was just released in the current frame.

Parameters:

  • button : The mouse button to check for just-released state.

Returns true if the specified mouse button was just released (transitioned from pressed to released) in the current frame, false otherwise.

Example:

inspect(@inputs.is_mouse_just_released(MouseButton::Left), content="false")

#
is_mouse_pressed

fn is_mouse_pressed(button : MouseButton) -> Bool

Checks if the specified mouse button is currently being pressed.

Parameters:

  • button : The mouse button to check the press state of.

Returns true if the specified mouse button is currently pressed, false if it is released.

Example:

inspect(@inputs.is_mouse_pressed(MouseButton::Left), content="false")

#
is_mouse_released

fn is_mouse_released(button : MouseButton) -> Bool

Checks if the specified mouse button is currently not being pressed (i.e., released).

Parameters:

  • button : The mouse button to check the release state of.

Returns true if the specified mouse button is currently released (not pressed), false if it is being pressed.

Example:

inspect(@inputs.is_mouse_released(Left), content="true")

#
is_pointer_active

fn is_pointer_active(id : PointerId) -> Bool

#
is_pressed

fn is_pressed(code : Code) -> Bool

Checks if a keyboard key is currently being pressed.

Parameters:

  • code : The keyboard key code to check for press status.

Returns true if the specified key is currently being held down, false otherwise.

Example:

// Check if the W key is currently pressed
if @inputs.is_pressed(@inputs.KeyW) {
println("W key is being held down")
}

// Check multiple keys
if @inputs.is_pressed(@inputs.Space) {
println("Space is pressed")
}

if @inputs.is_pressed(@inputs.ArrowUp) {
println("Up arrow is pressed")
}

#
is_released

fn is_released(code : Code) -> Bool

Checks if a keyboard key is currently not being pressed.

Parameters:

  • code : The keyboard key code to check for release status.

Returns true if the specified key is currently not being held down, false if it is being pressed.

Example:

// Check if the W key is currently released
inspect(@inputs.is_released(KeyW), content="true")

#
is_touch_active

fn is_touch_active(id : TouchId) -> Bool

#
is_virtual_button_pressed

fn is_virtual_button_pressed(button : VirtualButton) -> Bool

#
just_connected_gamepads

fn just_connected_gamepads() ->
Set
[Gamepad]

Gamepads that became connected in this frame.

#
just_disconnected_gamepads

fn just_disconnected_gamepads() ->
Set
[Gamepad]

Gamepads that became disconnected in this frame.

#
just_pressed_gamepad_buttons

fn just_pressed_gamepad_buttons() ->
Set
[GamepadButtonInput]

Buttons that transitioned to pressed in this frame.

#
just_pressed_mouse

let just_pressed_mouse : Mouse

Global mouse input state instance that tracks mouse button states for just-pressed detection.

This instance maintains the state of mouse buttons that were pressed in the current frame (transitioned from released to pressed). It is automatically updated by the input system through the advanced_mouse_system function and provides real-time information about button press transitions.

Fields:

  • pos : Mouse cursor position, initialized to (0.0, 0.0) by default.
  • left_button : Whether the left mouse button was just pressed in the current frame (false by default).
  • right_button : Whether the right mouse button was just pressed in the current frame (false by default).
  • middle_button : Whether the middle mouse button was just pressed in the current frame (false by default).

Example:

// Check if left mouse button was just pressed
if @inputs.just_pressed_mouse.left_button {
println("Left mouse button was just clicked!")
}

// Access the state directly
inspect(@inputs.just_pressed_mouse.left_button, content="false")
inspect(@inputs.just_pressed_mouse.right_button, content="false")

#
just_release_mouse

let just_release_mouse : Mouse

Global mouse input state instance that tracks mouse button states for just-released detection.

This instance maintains the state of mouse buttons that were released in the current frame (transitioned from pressed to released). It is automatically updated by the input system through the advanced_mouse_system function and provides real-time information about button release transitions.

Fields:

  • pos : Mouse cursor position, initialized to (0.0, 0.0) by default.
  • left_button : Whether the left mouse button was just released in the current frame (false by default).
  • right_button : Whether the right mouse button was just released in the current frame (false by default).
  • middle_button : Whether the middle mouse button was just released in the current frame (false by default).

Example:

// Check if left mouse button was just released
if @inputs.just_release_mouse.left_button {
println("Left mouse button was just released!")
}

// Access the state directly
inspect(@inputs.just_release_mouse.left_button, content="false")
inspect(@inputs.just_release_mouse.right_button, content="false")

#
just_released_gamepad_buttons

fn just_released_gamepad_buttons() ->
Set
[GamepadButtonInput]

Buttons that transitioned to released in this frame.

#
key_input_event_bus

#
key_vector

fn key_vector(up : Code, down : Code, left : Code, right : Code) ->
Vec2

Creates a directional vector based on the current state of four directional keys.

Parameters:

  • up : The keyboard key code for upward movement.
  • down : The keyboard key code for downward movement.
  • left : The keyboard key code for leftward movement.
  • right : The keyboard key code for rightward movement.

Returns a 2D vector representing the combined directional input, where x-component ranges from -1.0 (left) to 1.0 (right) and y-component ranges from -1.0 (up) to 1.0 (down).

Example:

// Get movement vector for WASD keys
let movement = @inputs.key_vector(KeyW, KeyS, KeyA, KeyD)
inspect(movement, content="Vec2(0, 0)")

// Get movement vector for arrow keys
let arrow_movement = @inputs.key_vector(ArrowUp, ArrowDown, ArrowLeft, ArrowRight)
inspect(arrow_movement, content="Vec2(0, 0)")

#
mouse

let mouse : Mouse

Global mouse input state instance that tracks the current mouse position and button states.

This is the primary interface for accessing mouse input in the application. The mouse state is automatically updated by the input system and provides real-time information about the cursor position and button press states.

Fields:

  • pos : Current mouse cursor position as a 2D vector with coordinates (0.0, 0.0) by default.
  • left_button : Whether the left mouse button is currently pressed (false by default).
  • right_button : Whether the right mouse button is currently pressed (false by default).
  • middle_button : Whether the middle mouse button is currently pressed (false by default).

Example:

// Access the global mouse state
inspect(@inputs.mouse.pos, content="Vec2(0, 0)")
inspect(@inputs.mouse.left_button, content="false")

#
mouse_button_event_bus

#
mouse_motion_event_bus

#
mouse_movement

let mouse_movement : MouseMovement

Global mouse movement delta tracking instance that stores the change in mouse position since the last frame.

This is the primary interface for accessing mouse movement information in the application. The mouse movement state is automatically updated by the input system and provides real-time information about how much the cursor has moved between frames.

Fields:

  • movement : The movement vector representing the change in mouse position since the last frame, initialized to (0.0, 0.0) by default.

Example:

// Access the global mouse movement
inspect(@inputs.mouse_movement.movement, content="Vec2(10, -5)")

// Update movement vector
@inputs.mouse_movement.movement = @math.Vec2(10.0, -5.0)

#
mouse_wheel

let mouse_wheel : MouseWheel

#
mouse_wheel_event_bus

#
pointer_changes_this_frame

fn pointer_changes_this_frame() -> Array[PointerEvent]

#
pointer_event_bus

#
pointer_event_from_touch

fn pointer_event_from_touch(event : TouchEvent) -> PointerEvent

#
pointer_id_from_touch

fn pointer_id_from_touch(touch : TouchPoint) -> PointerId

#
pressed_gamepad_buttons

fn pressed_gamepad_buttons() ->
Set
[GamepadButtonInput]

Buttons currently pressed in the current frame.

#
pressed_keys

A mutable set containing all keyboard keys that are currently being pressed.

This set is automatically updated by the input system to track the real-time state of keyboard input. Keys are added to this set when they are pressed down and removed when they are released. The set can be queried using functions like is_pressed() and is_released() to check the current state of specific keys.

Example:

// Check if a specific key is currently pressed
if @inputs.pressed_keys.contains(@inputs.KeyW) {
println("W key is being held down")
}

// Get all currently pressed keys
let current_keys = @inputs.pressed_keys.to_array()
inspect(current_keys, content="[]")

#
primary_pointer_down

fn primary_pointer_down() -> Bool

#
primary_pointer_position

fn primary_pointer_position() ->
Vec2

#
primary_touch

fn primary_touch() -> TouchPoint?

#
replace_touch_state

fn replace_touch_state(active : Map[TouchId, TouchPoint], changes : Array[TouchEvent]) -> Unit

#
set_virtual_axis_value

fn set_virtual_axis_value(axis : VirtualAxis, value : Double) -> Unit

#
set_virtual_button_pressed

fn set_virtual_button_pressed(button : VirtualButton, pressed : Bool) -> Unit

#
touch_changes_this_frame

fn touch_changes_this_frame() -> Array[TouchEvent]

#
touch_event_bus

#
touch_gesture_changes_this_frame

fn touch_gesture_changes_this_frame() -> Array[TouchGestureEvent]

#
touch_gesture_event_bus

#
touch_point

fn touch_point(id : TouchId) -> TouchPoint?

#
virtual_axis_event_bus

#
virtual_axis_value

fn virtual_axis_value(axis : VirtualAxis) -> Double

#
virtual_button_event_bus