pub struct Device;
Expand description
This class describes the device that is running this application! It contains identifiers, capabilities, and a few adjustable settings here and there. https://stereokit.net/Pages/StereoKit/Device.html
§Examples
use stereokit_rust::{util::{Device, DisplayType, DeviceTracking}, sk::DisplayBlend};
// These are the expected results for tests on a PC:
let display_type = Device::get_display_type();
assert_eq!(display_type, DisplayType::Flatscreen);
let display_blend = Device::get_display_blend();
assert_eq!(display_blend, DisplayBlend::Opaque);
let device_tracking = Device::get_tracking();
assert_eq!(device_tracking, DeviceTracking::None);
let device_name = Device::get_name().unwrap();
assert_eq!(device_name, "Offscreen");
let device_runtime = Device::get_runtime().unwrap();
assert_eq!(device_runtime, "None");
let device_gpu = Device::get_gpu().unwrap();
assert_ne!(device_gpu, "Name of your GPU");
assert_eq!(Device::has_eye_gaze(), false);
assert_eq!(Device::has_hand_tracking(), false);
assert_eq!(Device::valid_blend(DisplayBlend::None), false);
assert_eq!(Device::display_blend(DisplayBlend::None), false);
Implementations§
Source§impl Device
impl Device
Sourcepub fn display_blend(blend: DisplayBlend) -> bool
pub fn display_blend(blend: DisplayBlend) -> bool
Allows you to set and get the current blend mode of the device! Setting this may not succeed if the blend mode is not valid. https://stereokit.net/Pages/StereoKit/Device/DisplayBlend.html
see also device_display_set_blend
§Examples
use stereokit_rust::{util::Device, sk::DisplayBlend};
// These are the expected results for tests on a PC:
assert_eq!(Device::get_display_blend(), DisplayBlend::Opaque);
assert_eq!(Device::display_blend(DisplayBlend::AnyTransparent), false);
assert_eq!(Device::display_blend(DisplayBlend::None), false);
assert_eq!(Device::display_blend(DisplayBlend::Additive), false);
Sourcepub fn get_display_blend() -> DisplayBlend
pub fn get_display_blend() -> DisplayBlend
Allows you to set and get the current blend mode of the device! Setting this may not succeed if the blend mode is not valid. https://stereokit.net/Pages/StereoKit/Device/DisplayBlend.html
see also device_display_get_blend
see example in Device::display_blend
Sourcepub fn get_display_type() -> DisplayType
pub fn get_display_type() -> DisplayType
What type of display is this? Most XR headsets will report stereo, but the Simulator will report flatscreen. https://stereokit.net/Pages/StereoKit/Device/DisplayType.html
see also device_display_get_type
§Examples
use stereokit_rust::util::{Device, DisplayType};
// These are the expected results for tests on a PC:
assert_eq!(Device::get_display_type(), DisplayType::Flatscreen);
Sourcepub fn get_runtime<'a>() -> Result<&'a str, StereoKitError>
pub fn get_runtime<'a>() -> Result<&'a str, StereoKitError>
This is the name of the OpenXR runtime that powers the current device! This can help you determine which implementation quirks to expect based on the codebase used. On the simulator, this will be “Simulator”, and in other non-XR modes this will be “None”. https://stereokit.net/Pages/StereoKit/Device/Runtime.html
see also device_get_runtime
§Examples
use stereokit_rust::util::Device;
// These are the expected results for tests on a PC:
assert_eq!(Device::get_runtime().unwrap(), "None");
Sourcepub fn get_gpu<'a>() -> Result<&'a str, StereoKitError>
pub fn get_gpu<'a>() -> Result<&'a str, StereoKitError>
The reported name of the GPU, this will differ between D3D and GL. https://stereokit.net/Pages/StereoKit/Device/GPU.html
see also device_get_gpu
Sourcepub fn has_eye_gaze() -> bool
pub fn has_eye_gaze() -> bool
Does the device we’re on have eye tracking support present for input purposes? This is not an indicator that the user has given the application permission to access this information. See Input.Gaze for how to use this data. https://stereokit.net/Pages/StereoKit/Device/HasEyeGaze.html
see also device_has_eye_gaze
§Examples
use stereokit_rust::util::Device;
// These are the expected results for tests on a PC:
assert_eq!(Device::has_eye_gaze(), false);
Sourcepub fn has_hand_tracking() -> bool
pub fn has_hand_tracking() -> bool
Tells if the device is capable of tracking hands. This does not tell if the user is actually using their hands for input, merely that it’s possible to! https://stereokit.net/Pages/StereoKit/Device/HasHandTracking.html
see also device_has_hand_tracking
§Examples
use stereokit_rust::util::Device;
// These are the expected results for tests on a PC:
assert_eq!(Device::has_hand_tracking(), false);
Sourcepub fn get_name<'a>() -> Result<&'a str, StereoKitError>
pub fn get_name<'a>() -> Result<&'a str, StereoKitError>
This is the name of the active device! From OpenXR, this is the same as systemName from XrSystemProperties. The simulator will say “Simulator”. https://stereokit.net/Pages/StereoKit/Device/Name.html
see also device_get_name
§Examples
use stereokit_rust::util::Device;
// These are the expected results for tests on a PC:
assert_eq!(Device::get_name().unwrap(), "Offscreen");
Sourcepub fn get_tracking() -> DeviceTracking
pub fn get_tracking() -> DeviceTracking
The tracking capabilities of this device! Is it 3DoF, rotation only? Or is it 6DoF, with positional tracking as well? Maybe it can’t track at all! https://stereokit.net/Pages/StereoKit/Device/Tracking.html
see also device_get_tracking
§Examples
use stereokit_rust::util::{Device, DeviceTracking};
// These are the expected results for tests on a PC:
assert_eq!(Device::get_tracking(), DeviceTracking::None);
Sourcepub fn valid_blend(blend: DisplayBlend) -> bool
pub fn valid_blend(blend: DisplayBlend) -> bool
Tells if a particular blend mode is valid on this device. Some devices may be capable of more than one blend mode. https://stereokit.net/Pages/StereoKit/Device/ValidBlend.html
see also device_display_valid_blend
§Examples
use stereokit_rust::{util::Device, sk::DisplayBlend};
// These are the expected results for tests on a PC:
assert_eq!(Device::valid_blend(DisplayBlend::Opaque), true);
assert_eq!(Device::valid_blend(DisplayBlend::None), false);
assert_eq!(Device::valid_blend(DisplayBlend::Additive), false);
assert_eq!(Device::valid_blend(DisplayBlend::Blend), false);
assert_eq!(Device::valid_blend(DisplayBlend::AnyTransparent), false);
Auto Trait Implementations§
impl Freeze for Device
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.