Struct Input

Source
pub struct Input;
Expand description

Input from the system come from this class! Hands, eyes, heads, mice and pointers! https://stereokit.net/Pages/StereoKit/Input.html

§Examples

use stereokit_rust::{system::{Input, InputSource, Handed},
                     maths::{Vec2, Vec3, Quat, Pose}};

let controller = Input::controller(Handed::Left);
assert_eq!(controller.is_tracked(), false);

let hand = Input::hand(Handed::Right);
assert_eq!(hand.is_tracked(), false);

let head = Input::get_head();
assert_eq!(head , Pose::IDENTITY);

let mouse = Input::get_mouse();
assert_eq!(mouse.is_available(), false);

assert_eq!(Input::pointer_count(None), 0);
let pointer = Input::pointer(0, Some(InputSource::Hand));
assert_eq!(pointer.source, InputSource::None);

Implementations§

Source§

impl Input

Source

pub fn set_controller_model(handed: Handed, model: Option<Model>)

When StereoKit is rendering the input source, this allows you to override the controller Model SK uses. The Model SK uses by default may be provided from the OpenXR runtime depending on extension support, but if not, SK does have a default Model. Setting this to None will restore SK’s default. https://stereokit.net/Pages/StereoKit/Input/ControllerModelSet.html

  • handed - The hand to assign the Model to.
  • model - The Model to use to represent the controller. None is valid, and will restore SK’s default model.

see also input_controller_model_set Input::get_controller_model

§Examples
use stereokit_rust::{system::{Input, Handed}, model::Model};

assert_eq!(Input::get_controller_model(Handed::Left).get_id(), "default/model_controller_l");

let model_left = Model::from_file("center.glb", None)
                    .expect("mobiles.gltf should be a valid model");

Input::set_controller_model(Handed::Left, Some(model_left));
assert_eq!(Input::get_controller_model(Handed::Left).get_id(), "center.glb");

Input::set_controller_model(Handed::Left, None);
assert_eq!(Input::get_controller_model(Handed::Left).get_id(), "default/model_controller_l");
Source

pub fn controller(handed: Handed) -> Controller

Gets raw controller input data from the system. Note that not all buttons provided here are guaranteed to be present on the user’s physical controller. Controllers are also not guaranteed to be available on the system, and are never simulated. https://stereokit.net/Pages/StereoKit/Input/Controller.html

  • handed - The handedness of the controller to get the state of.

Returns a reference to a class that contains state information about the indicated controller. see also input_controller

§Examples
use stereokit_rust::system::{Input, Handed, TrackState};

let controller = Input::controller(Handed::Right);

assert_eq!(controller.tracked_pos, TrackState::Lost);
assert_eq!(controller.tracked_rot, TrackState::Lost);
Source

pub fn fire_event( event_source: InputSource, event_types: BtnState, pointer: &Pointer, )

👎Deprecated since 0.4.0: Not working anymore

This function allows you to artifically insert an input event, simulating any device source and event type you want. https://stereokit.net/Pages/StereoKit/Input/FireEvent.html

  • event_source - The event source to simulate, this is a bit flag.
  • event_types - The event type to simulate, this is a bit flag.
  • pointer - The pointer data to pass along with this simulated input event.

see also input_fire_event

§Examples
use stereokit_rust::{system::{Input, InputSource, Pointer, BtnState, Handed, TrackState},
                     maths::{Vec3, Quat, Pose, Ray}};

let pointer = Input::pointer(0, None);
assert_eq!(pointer.source, InputSource::None);

test_steps!( // !!!! Get a proper main loop !!!!
    assert_eq!(pointer.state, BtnState::Inactive);
    assert_eq!(pointer.tracked, BtnState::Inactive);
    if iter == 0 {    
        Input::fire_event(InputSource::CanPress, BtnState::Active, &pointer);
    } else if iter == 1 {
        Input::fire_event(InputSource::Hand | InputSource::HandLeft, BtnState::JustInactive, &pointer);
    }
);
Source

pub fn hand(handed: Handed) -> Hand

Retrieves all the information about the user’s hand! StereoKit will always provide hand information, however sometimes that information is simulated, like in the case of a mouse, or controllers.

Note that this is a pointer to the hand information, and it’s a good chunk of data, so it’s a good idea to grab it once and keep it around for the frame, or at least function, rather than asking for it again and again each time you want to touch something. https://stereokit.net/Pages/StereoKit/Input/Hand.html

  • handed - Do you want the left or the right hand? 0 is left, and 1 is right.

Returns a copy of the entire set of hand data! see also input_hand

§Examples
use stereokit_rust::system::{Input, Handed, Hand, HandJoint, FingerId, JointId};
use stereokit_rust::maths::{Vec3, Quat, Pose};

let hand = Input::hand(Handed::Left);
let thumb_tip = hand.get(FingerId::Thumb, JointId::Tip);
assert_eq!(thumb_tip.position, Vec3 { x: -0.072, y: 0.028, z: -0.055 });

let hand = Input::hand(Handed::Right);
let thumb_tip = hand.get(FingerId::Thumb, JointId::Tip);
assert_eq!(thumb_tip.position, Vec3 { x: 0.072, y: 0.028, z: -0.055 });
Source

pub fn hand_clear_override(hand: Handed)

Clear out the override status from Input::hand_override, and restore the user’s control over it again. https://stereokit.net/Pages/StereoKit/Input/HandClearOverride.html

  • hand - Which hand are we clearing the override on?

see also input_hand_override

§Examples
use stereokit_rust::{system::{Input, Handed, HandJoint, FingerId, JointId},
                     maths::{Vec3, Quat}};

let mut hand_joints = [HandJoint { position: Vec3::ZERO, orientation: Quat::IDENTITY, radius: 0.0 }; 25];

Input::hand_override(Handed::Left, &hand_joints);


test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        let hand = Input::hand(Handed::Left);
        let thumb_tip = hand.get(FingerId::Thumb, JointId::Tip);
        assert_eq!(thumb_tip.position, Vec3::ZERO);
    } else if iter == 1 {
        Input::hand_clear_override(Handed::Left);
    }
);
Source

pub fn hand_override(hand: Handed, joints: &[HandJoint])

This allows you to completely override the hand’s pose information! It is still treated like the user’s hand, so this is great for simulating input for testing purposes. It will remain overridden until you call Input::hand_clear_override. https://stereokit.net/Pages/StereoKit/Input/HandOverride.html

  • hand - Which hand should be overridden?
  • joints - A 2D array of 25 joints that should be used as StereoKit’s hand information. See Hand.fingers for more information.

see also input_hand_override see example in Input::hand_clear_override

Source

pub fn hand_material(hand: Handed, material: Option<Material>)

Set the Material used to render the hand! The default material uses an offset of 10 to ensure it gets drawn overtop of other elements. https://stereokit.net/Pages/StereoKit/Input/HandMaterial.html

  • hand - The hand to assign the Material to. If Handed::Max, this will set the value for both hands.
  • material - The new material. If None, will reset to the default value

see also input_hand_material Material::hand

§Examples
use stereokit_rust::{system::{Input, Handed}, util::named_colors,
                     material::Material};

let mut hand_material = Material::hand().copy();
hand_material.color_tint(named_colors::YELLOW).id("My_hand_material");
Input::hand_material(Handed::Left, Some(hand_material));

test_steps! ( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        // Of course, Material::hand() is not modified.
        assert_eq!(Material::hand().get_id(), "default/material_hand");
    } else if iter == 1 {
        // The reason why Material::hand() should not be modified:
        Input::hand_material(Handed::Left, None);
    }
);
Source

pub fn hand_sim_pose_add( hand_joints_palm_relative_25: &[Pose], button1: ControllerKey, and_button2: ControllerKey, or_hotkey1: Key, and_hotkey2: Key, ) -> HandSimId

StereoKit will use controller inputs to simulate an articulated hand. This function allows you to add new simulated poses to different controller or keyboard buttons! https://stereokit.net/Pages/StereoKit/Input/HandSimPoseAdd.html

  • hand_joints_palm_relative_25 - 25 joint poses, thumb to pinky, and root to tip with two duplicate poses for the thumb root joint. These should be right handed, and relative to the palm joint.
  • button1 - Controller button to activate this pose, can/ be None if this is a keyboard only pose.
  • and_button2 - Second controller button required to activate this pose. First must also be pressed. Can be None if it’s only a single button pose.
  • or_hotkey1 - Keyboard key to activate this pose, can be None if this is a controller only pose.
  • and_hotkey2 - Second keyboard key required to activatethis pose. First must also be pressed. Can be None if it’s only a single key pose.

Returns the id of the hand sim pose, so it can be removed later. see also input_hand_sim_pose_add

§Examples
use stereokit_rust::{system::{Input, Handed, HandJoint, FingerId, JointId, ControllerKey, Key},
                     maths::{Vec3, Quat, Pose}};

let hand_joints = [Pose::IDENTITY;25];

let id = Input::hand_sim_pose_add(&hand_joints, ControllerKey::Trigger, ControllerKey::None_, Key::None, Key::None);
assert_eq!(id, 5);

let hand = Input::hand(Handed::Left);

Input::hand_sim_pose_remove(id);

let id = Input::hand_sim_pose_add(&hand_joints, ControllerKey::Grip, ControllerKey::None_, Key::None, Key::None);
assert_eq!(id, 6);

Input::hand_sim_pose_clear();

let id = Input::hand_sim_pose_add(&hand_joints, ControllerKey::X1, ControllerKey::None_, Key::None, Key::None);
assert_eq!(id, 7);
Source

pub fn hand_sim_pose_clear()

This clears all registered hand simulation poses, including the ones that StereoKit registers by default! https://stereokit.net/Pages/StereoKit/Input/HandSimPoseClear.html

see also input_hand_sim_pose_clear
see example in Input::hand_sim_pose_add

Source

pub fn hand_sim_pose_remove(id: HandSimId)

Lets you remove an existing hand pose. https://stereokit.net/Pages/StereoKit/Input/HandSimPoseRemove.html

  • id - Any valid or invalid hand sim pose id.

see also input_hand_sim_pose_remove
see example in Input::hand_sim_pose_add

Source

pub fn hand_source(hand: Handed) -> HandSource

This gets the current source of the hand joints! This allows you to distinguish between fully articulated joints, and simulated hand joints that may not have the same range of mobility. Note that this may change during a session, the user may put down their controllers, automatically switching to hands, or visa versa. https://stereokit.net/Pages/StereoKit/Input/HandSource.html

  • hand - Do you want the left or right hand?

Returns information about hand tracking data source. see also input_hand_source

§Examples
use stereokit_rust::system::{Input, Handed, HandSource};

// These are the normal values for Offscreen tests:

let hand_source = Input::hand_source(Handed::Left);
assert_eq!(hand_source, HandSource::None);

let hand_source = Input::hand_source(Handed::Right);
assert_eq!(hand_source, HandSource::None);
Source

pub fn hand_visible(hand: Handed, visible: bool)

Sets whether or not StereoKit should render the hand for you. Turn this to false if you’re going to render your own, or don’t need the hand itself to be visible. https://stereokit.net/Pages/StereoKit/Input/HandVisible.html

  • hand - If Handed.Max, this will set the value for both hands.
  • visible - True, StereoKit renders this. False, it doesn’t.

see also input_hand_visible

§Examples
use stereokit_rust::system::{Input, Handed, HandSource};

Input::hand_visible(Handed::Right, false);
Input::hand_visible(Handed::Max, false);
Input::hand_visible(Handed::Left, true);
Source

pub fn finger_glow(visible: bool)

This controls the visibility of StereoKit’s finger glow effect on the UI. When true, SK will fill out global shader variable sk_fingertip[2] with the location of the pointer finger’s tips. When false, or the hand is untracked, the location will be set to an unlikely faraway position. https://stereokit.net/Pages/StereoKit/Input/FingerGlow.html

  • visible - True, StereoKit renders this. False, it doesn’t.

see also input_set_finger_glow

§Examples
use stereokit_rust::system::{Input, Handed, HandSource};

assert_eq!(Input::get_finger_glow(), true);

Input::finger_glow(false);

assert_eq!(Input::get_finger_glow(), false);

Input::finger_glow(true);
assert_eq!(Input::get_finger_glow(), true);
Source

pub fn key(key: Key) -> BtnState

Keyboard key state! On desktop this is super handy, but even standalone MR devices can have bluetooth keyboards, or even just holographic system keyboards! https://stereokit.net/Pages/StereoKit/Input/Key.html

  • key - The key to get the state of. Any key!

Returns a BtnState with a number of different bits of info about whether or not the key was pressed or released this frame. see also input_key

§Examples
use stereokit_rust::system::{Input, Key, BtnState};

let key_state = Input::key(Key::A);

assert_eq!(key_state, BtnState::Inactive);
assert_eq!(key_state.is_active(), false);
assert_eq!(key_state.is_just_active(), false);
assert_eq!(key_state.is_just_inactive(), false);
assert_eq!(key_state.is_changed(), false);
Source

pub fn key_inject_press(key: Key)

This will inject a key press event into StereoKit’s input event queue. It will be processed at the start of the next frame, and will be indistinguishable from a physical key press. Remember to release your key as well!

This will not submit text to StereoKit’s text queue, and will not show up in places like UI.Input. For that, you must submit a TextInjectChar call. https://stereokit.net/Pages/StereoKit/Input/KeyInjectPress.html

  • key - The key to press.

see also input_key_inject_press

§Examples
use stereokit_rust::{system::{Input, Key, BtnState}};


test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {    
        assert_eq!(Input::key(Key::A).is_just_active(), false);
        Input::key_inject_press(Key::A);
    } else if iter == 1 {
        assert_eq!(Input::key(Key::A).is_just_active(), true);
        Input::key_inject_release(Key::A);
    } else if iter == 2 {
        Input::key_inject_release(Key::A);
        assert_eq!(Input::key(Key::A).is_just_inactive(), true);
        Input::key_inject_press(Key::A);
    } else if iter == 3 {
        assert_eq!(Input::key(Key::A).is_active(), true);
    }
);
assert_eq!(Input::key(Key::A).is_active(), true);
Source

pub fn key_inject_release(key: Key)

This will inject a key release event into StereoKit’s input event queue. It will be processed at the start of the next frame, and will be indistinguishable from a physical key release. This should be preceded by a key press!

This will not submit text to StereoKit’s text queue, and will not show up in places like UI.Input. For that, you must submit a TextInjectChar call. https://stereokit.net/Pages/StereoKit/Input/KeyInjectRelease.html

  • key - The key to release.

see also input_key_inject_release
see example Input::key_inject_press

Source

pub fn pointer(index: i32, filter: Option<InputSource>) -> Pointer

This gets the pointer by filter based index. https://stereokit.net/Pages/StereoKit/Input/Pointer.html

  • index - Index of the Pointer.
  • filter - Filter used to search for the Pointer. If None has default value of ANY.

Returns the Pointer data. see also input_pointer

§Examples
use stereokit_rust::{system::{Input, InputSource, Pointer, BtnState, Handed, TrackState},
                     maths::{Vec3, Quat, Pose, Ray}};

// By default we only have the 2 hands.
assert_eq!(Input::pointer_count(None), 0);
let pointer = Input::pointer(0, None);

assert_eq!(pointer.source, InputSource::None);
assert_eq!(pointer.state, BtnState::Inactive);
assert_eq!(pointer.tracked, BtnState::Inactive);
assert_eq!(pointer.orientation, Quat::ZERO);
assert_eq!(pointer.ray, Ray::ZERO);
assert_eq!(pointer.get_pose(), Pose::ZERO);
Source

pub fn pointer_count(filter: Option<InputSource>) -> i32

The number of Pointer inputs that StereoKit is tracking that match the given filter. https://stereokit.net/Pages/StereoKit/Input/PointerCount.html

  • filter - You can filter input sources using this bit flat. If None has default value of ANY

Returns the number of Pointers StereoKit knows about that matches the given filter. see also input_pointer_count
see example in Input::pointer

Source

pub fn text_consume() -> Option<char>

Returns the next text character from the list of characters that have been entered this frame! Will return \0 if there are no more characters left in the list. These are from the system’s text entry system, and so can be unicode, will repeat if their ‘key’ is held down, and could arrive from something like a copy/paste operation.

If you wish to reset this function to begin at the start of the read list on the next call, you can call Input::text_reset. https://stereokit.net/Pages/StereoKit/Input/TextConsume.html

Returns the next character in this frame’s list, or ‘\0’ if none remain, or None if the value doesn’t match char. see also input_text_consume char::from_u32

§Examples
use stereokit_rust::system::Input;

// Simulate some text input
Input::text_inject_char('H');
Input::text_inject_char('i');

test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        assert_eq!(Input::text_consume(), Some('H'));
        assert_eq!(Input::text_consume(), Some('i'));
        Input::text_inject_char('!');
        assert_eq!(Input::text_consume(), Some('\0'));
    } else if iter == 1 {
        assert_eq!(Input::text_consume(), Some('!'));
    } else {
        assert_eq!(Input::text_consume(), Some('\0'));
    }
);
Source

pub fn text_reset()

Resets the Input::text_consume read list back to the start. For example, UI.Input will not call text_reset, so it effectively will consume those characters, hiding them from any TextConsume calls following it. If you wanted to check the current frame’s text, but still allow UI.Input to work later on in the frame, you would read everything with TextConsume, and then TextReset afterwards to reset the read list for the following UI.Input. https://stereokit.net/Pages/StereoKit/Input/TextReset.html

see also input_text_reset

§Examples
use stereokit_rust::system::Input;

// Simulate some text input
Input::text_inject_char('H');
Input::text_inject_char('i');

test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        assert_eq!(Input::text_consume(), Some('H'));
        assert_eq!(Input::text_consume(), Some('i'));
        Input::text_inject_char('!');
        assert_eq!(Input::text_consume(), Some('\0'));
        Input::text_reset();
        assert_eq!(Input::text_consume(), Some('H'));
        assert_eq!(Input::text_consume(), Some('i'));
        assert_eq!(Input::text_consume(), Some('\0'));
    } else if iter == 1 {
        assert_eq!(Input::text_consume(), Some('!'));
    } else {
        assert_eq!(Input::text_consume(), Some('\0'));
    }
);
Source

pub fn text_inject_char(character: char)

This will inject a UTF32 Unicode text character into StereoKit’s text input queue. It will be available at the start of the next frame, and will be indistinguishable from normal text entry.

This will not submit key press/release events to StereoKit’s input queue, use key_inject_press/_release for that. https://stereokit.net/Pages/StereoKit/Input/TextInjectChar.html

  • character - An unsigned integer representing a single UTF32 character.

see also input_text_inject_char

§Examples
use stereokit_rust::system::Input;

// Simulate some text input
Input::text_inject_char('H');
Input::text_inject_char('i');
Input::text_inject_char('!');
Input::text_inject_char('😬');

test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        assert_eq!(Input::text_consume(), Some('H'));
        assert_eq!(Input::text_consume(), Some('i'));
        assert_eq!(Input::text_consume(), Some('!'));
        assert_eq!(Input::text_consume(), Some('😬'));
    } else {
        assert_eq!(Input::text_consume(), Some('\0'));
    }
);
Source

pub fn text_inject_chars(str: impl AsRef<str>)

This will convert an str into a number of UTF32 Unicode text characters, and inject them into StereoKit’s text input queue. It will be available at the start of the next frame, and will be indistinguishable from normal text entry.

This will not submit key press/release events to StereoKit’s input queue, use key_inject_press/_release for that. https://stereokit.net/Pages/StereoKit/Input/TextInjectChar.html

  • chars - A collection of characters to submit as text input.

see also input_text_inject_char

§Examples
use stereokit_rust::system::Input;

// Simulate some text input
Input::text_inject_chars("Hi!❤");

test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {
        assert_eq!(Input::text_consume(), Some('H'));
        assert_eq!(Input::text_consume(), Some('i'));
        assert_eq!(Input::text_consume(), Some('!'));
        assert_eq!(Input::text_consume(), Some('❤'));
    } else {
        assert_eq!(Input::text_consume(), Some('\0'));
    }
);
Source

pub fn subscribe( event_source: InputSource, event_types: BtnState, on_event: Option<unsafe extern "C" fn(source: InputSource, input_event: BtnState, in_pointer: *const Pointer)>, )

👎Deprecated since 0.4.0: Not working anymore

You can subscribe to input events from Pointer sources here. StereoKit will call your callback and pass along a Pointer that matches the position of that pointer at the moment the event occurred. This can be more accurate than polling for input data, since polling happens specifically at frame start. https://stereokit.net/Pages/StereoKit/Input/Subscribe.html

  • event_source - What input sources do we want to listen for. This is a bit flag.
  • event_types - What events do we want to listen for. This is a bit flag.
  • on_event - The callback to call when the event occurs!

see also input_subscribe

§Examples
use stereokit_rust::system::{Input, InputSource, Pointer, BtnState, Handed};

let pointer_left  = Input::pointer(0, None);

unsafe extern "C" fn input_cb (source: InputSource, input_event: BtnState, in_pointer: *const Pointer) {
    let in_pointer = unsafe { *in_pointer };
    assert_eq!(source, InputSource::CanPress);
    assert_eq!(in_pointer.source, InputSource::None);
    assert_eq!(input_event, BtnState::JustActive);
}

number_of_steps = 8;
test_steps!( // !!!! Get a proper main loop !!!!
    if iter == 0 {    
        Input::subscribe (InputSource::CanPress, BtnState::JustActive, Some(input_cb));
    } if iter == 1 {
        Input::fire_event(InputSource::CanPress, BtnState::JustActive, &pointer_left);
    } else if iter == 8 {
        Input::unsubscribe(InputSource::Hand | InputSource::HandLeft, BtnState::JustInactive, Some(input_cb));
    }
);
Source

pub fn unsubscribe( event_source: InputSource, event_types: BtnState, on_event: Option<unsafe extern "C" fn(source: InputSource, input_event: BtnState, in_pointer: *const Pointer)>, )

👎Deprecated since 0.4.0: Not working anymore

Unsubscribes a listener from input events. https://stereokit.net/Pages/StereoKit/Input/Unsubscribe.html

  • event_source - The sources this listener was originally registered for.
  • event_types - The events this listener was originally registered for.
  • on_event - The callback this lisener originally used.

see also input_unsubscribe
see example in Input::subscribe

Source

pub fn get_controller_model(handed: Handed) -> Model

This retreives the Model currently in use by StereoKit to represent the controller input source. By default, this will be a Model provided by OpenXR, or SK’s fallback Model. This will never be null while SK is initialized. https://stereokit.net/Pages/StereoKit/Input.html

  • handed - The hand of the controller Model to retreive.

Returns the current controller Model. By default, his will be a Model provided by OpenXR, or SK’s fallback Model. This will never be null while SK is initialized. see also input_controller_model_get see example in Input::set_controller_model

Source

pub fn get_controller_menu_button() -> BtnState

This is the state of the controller’s menu button, this is not attached to any particular hand, so it’s independent of a left or right controller. https://stereokit.net/Pages/StereoKit/Input/ControllerMenuButton.html

see also input_controller_menu

§Examples
use stereokit_rust::system::{Input, BtnState};

assert_eq!(Input::get_controller_menu_button(), BtnState::Inactive);
assert_eq!(Input::get_controller_menu_button().is_just_active(), false);

let button_state = Input::get_controller_menu_button();
assert_eq!(button_state.is_active(), false);
assert_eq!(button_state.is_just_active(), false);
assert_eq!(button_state.is_just_inactive(), false);
assert_eq!(button_state.is_changed(), false);
Source

pub fn get_eyes() -> Pose

If the device has eye tracking hardware and the app has permission to use it, then this is the most recently tracked eye pose. Check Input.EyesTracked to see if the pose is up-to date, or if it’s a leftover!

You can also check Sk::System::eye_tracking_present to see if the hardware is capable of providing eye tracking.

On Flatscreen when the MR sim is still enabled, then eyes are emulated using the cursor position when the user holds down Alt. https://stereokit.net/Pages/StereoKit/Input/Eyes.html

see also input_eyes Input::get_eyes_tracked

§Examples
use stereokit_rust::{system::{Input, BtnState}, maths::Pose};

let eyes_pose = Input::get_eyes();

assert_eq!(eyes_pose, Pose::IDENTITY);
assert_eq!(Input::get_eyes_tracked(), BtnState::Inactive)
Source

pub fn get_eyes_tracked() -> BtnState

If eye hardware is available and app has permission, then this is the tracking state of the eyes. Eyes may move out of bounds, hardware may fail to detect eyes, or who knows what else!

On Flatscreen when MR sim is still enabled, this will report whether the user is simulating eye input with the Alt key.

Permissions:

  • You may need to add an entry to your AndroidManifest.xml (or Cargo.toml), refer to your device’s documentation for specifics.

https://stereokit.net/Pages/StereoKit/Input/EyesTracked.html

see also input_eyes_tracked

§Examples
use stereokit_rust::{system::{Input, BtnState}, maths::Pose};

let eyes_tracked = Input::get_eyes_tracked();

assert_eq!(eyes_tracked.is_active(), false);
assert_eq!(eyes_tracked, BtnState::Inactive);

assert_eq!(Input::get_eyes(),Pose::IDENTITY)
Source

pub fn get_head() -> Pose

The position and orientation of the user’s head! This is the center point between the user’s eyes, NOT the center of the user’s head. Forward points the same way the user’s face is facing. https://stereokit.net/Pages/StereoKit/Input/Head.html

see also input_head

§Examples
use stereokit_rust::{system::Input, maths::Pose};

let head_pose = Input::get_head();

assert_eq!(head_pose, Pose::IDENTITY);
Source

pub fn get_mouse() -> Mouse

Information about this system’s mouse, or lack thereof! https://stereokit.net/Pages/StereoKit/Input/Mouse.html

see also input_mouse

§Examples
use stereokit_rust::{system::Input, maths::{Vec2, Vec3}};

let mouse = Input::get_mouse();

assert_eq!(mouse.is_available(),false);
assert_eq!(mouse.pos,           Vec2::ZERO);
assert_eq!(mouse.pos_change,    Vec2::ZERO);
assert_eq!(mouse.scroll,        0.0);
assert_eq!(mouse.scroll_change, 0.0);

assert_eq!(mouse.get_ray().position, Vec3::ZERO);
// Warning: No ray if the mouse isn't available!
// assert_eq!(mouse.get_ray().direction, Vec3::new(f32::NAN, f32::NAN, f32::NAN));
Source

pub fn get_finger_glow() -> bool

This controls the visibility of StereoKit’s finger glow effect on the UI. When true, SK will fill out global shader variable sk_fingertip[2] with the location of the pointer finger’s tips. When false, or the hand is untracked, the location will be set to an unlikely faraway position. https://stereokit.net/Pages/StereoKit/Input/FingerGlow.html

Returns true if StereoKit renders this. False, it doesn’t. see also input_set_finger_glow see example in Input::finger_glow

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more