Struct Mouse

Source
pub struct Mouse { /* private fields */ }
Expand description

The IMouse interface represents the virtual machine’s mouse.

Reference to the official documentation:

https://www.virtualbox.org/sdkref/interface_i_mouse.html

Implementations§

Source§

impl Mouse

Source

pub fn put_mouse_event( &self, dx: i32, dy: i32, dz: i32, dw: i32, button_state: MouseButtonState, ) -> Result<(), VboxError>

Initiates a mouse event using relative pointer movements along x and y axis.

§Arguments
  • dx - Amount of pixels the mouse should move to the right. Negative values move the mouse to the left.
  • dy - Amount of pixels the mouse should move downwards. Negative values move the mouse upwards.
  • dz - Amount of mouse wheel moves. Positive values describe clockwise wheel rotations, negative values describe counterclockwise rotations.
  • dw - Amount of horizontal mouse wheel moves. Positive values describe a movement to the left, negative values describe a movement to the right.
  • button_state - The current state of mouse buttons.
§Returns

Returns Ok(()) success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::{MouseButtonState, SessionType};

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
mouse.put_mouse_event(1,1,1,1,MouseButtonState::Left).unwrap();
Source

pub fn put_mouse_event_absolute( &self, x: i32, y: i32, dz: i32, dw: i32, button_state: MouseButtonState, ) -> Result<(), VboxError>

Positions the mouse pointer using absolute x and y coordinates.

§Arguments
  • x - X coordinate of the pointer in pixels, starting from 1.
  • y - Y coordinate of the pointer in pixels, starting from 1.
  • dz - Amount of mouse wheel moves. Positive values describe clockwise wheel rotations, negative values describe counterclockwise rotations.
  • dw - Amount of horizontal mouse wheel moves. Positive values describe a movement to the left, negative values describe a movement to the right.
  • button_state - The current state of mouse buttons.
§Returns

Returns Ok(()) success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::{MouseButtonState, SessionType};

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
mouse.put_mouse_event_absolute(1,1,1,1,MouseButtonState::Left).unwrap();
Source

pub fn get_absolute_supported(&self) -> Result<bool, VboxError>

Whether the guest OS supports absolute mouse pointer positioning or not.

§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
let supported = mouse.get_absolute_supported().unwrap();
Source

pub fn get_relative_supported(&self) -> Result<bool, VboxError>

Whether the guest OS supports relative mouse pointer positioning or not.

§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
let supported = mouse.get_relative_supported().unwrap();
Source

pub fn get_touch_screen_supported(&self) -> Result<bool, VboxError>

Whether the guest OS has enabled the multi-touch reporting device, touchscreen variant.

This flag only exists for versions 7 and above. For compatibility with earlier versions, this field has been retained, but it always returns false
§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
let supported = mouse.get_touch_screen_supported().unwrap();
Source

pub fn get_touch_pad_supported(&self) -> Result<bool, VboxError>

Whether the guest OS has enabled the multi-touch reporting device, touchpad variant.

This flag only exists for versions 7 and above. For compatibility with earlier versions, this field has been retained, but it always returns false
§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
let supported = mouse.get_touch_pad_supported().unwrap();
Source

pub fn get_needs_host_cursor(&self) -> Result<bool, VboxError>

Whether the guest OS can currently switch to drawing it’s own mouse cursor on demand.

§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();

let mouse = console.get_mouse().unwrap();
let supported = mouse.get_needs_host_cursor().unwrap();
Source

pub fn get_event_source(&self) -> Result<EventSource, VboxError>

Event source for mouse events.

§Returns

Returns a new instance of the EventSource class on success, or a VboxError on failure.

§Example

use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;

let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();

let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();

let event_source = mouse.get_event_source().unwrap();

Trait Implementations§

Source§

impl Clone for Mouse

Source§

fn clone(&self) -> Mouse

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mouse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Mouse

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Mouse

Source§

impl Sync for Mouse

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.