pub struct Mouse<'c> { /* private fields */ }
Expand description
A PS/2 mouse.
This provides the functionality of a typical PS/2 mouse, as well as PS/2 devices that act like mice, such as touchpads or wireless mouse receivers.
§Examples
use ps2::Controller;
let mut controller = unsafe { Controller::new() };
let mut mouse = controller.mouse();
Implementations§
Source§impl<'c> Mouse<'c>
impl<'c> Mouse<'c>
Sourcepub fn set_scaling_one_to_one(&mut self) -> Result<(), MouseError>
pub fn set_scaling_one_to_one(&mut self) -> Result<(), MouseError>
Set the scaling of reported data to be 1:1.
Read more about scaling here.
Sourcepub fn set_scaling_two_to_one(&mut self) -> Result<(), MouseError>
pub fn set_scaling_two_to_one(&mut self) -> Result<(), MouseError>
Set the scaling of reported data to be 2:1.
Read more about scaling here.
Sourcepub fn set_resolution(&mut self, resolution: u8) -> Result<(), MouseError>
pub fn set_resolution(&mut self, resolution: u8) -> Result<(), MouseError>
Set mouse resolution.
Valid values are 0
for 1 count/mm, 1
for 2 counts/mm, 2
for 4 counts/mm, or 3
for
8 counts/mm.
Sourcepub fn get_status_packet(
&mut self,
) -> Result<(MouseStatusFlags, u8, u8), MouseError>
pub fn get_status_packet( &mut self, ) -> Result<(MouseStatusFlags, u8, u8), MouseError>
Request a status packet from the mouse and reset the movement counters.
The first byte returned is a bitfield, the second byte is the mouse resolution, and the third is the sample rate.
Sourcepub fn set_stream_mode(&mut self) -> Result<(), MouseError>
pub fn set_stream_mode(&mut self) -> Result<(), MouseError>
Reset mouse movement counters and enter streaming mode.
Read more about modes here.
Sourcepub fn request_data_packet(
&mut self,
) -> Result<(MouseMovementFlags, i16, i16), MouseError>
pub fn request_data_packet( &mut self, ) -> Result<(MouseMovementFlags, i16, i16), MouseError>
Request a movement data packet from the mouse and reset the movement counters.
The first byte returned is a bitfield, and the other two bytes are 9-bit two’s complement integers for the horizontal and vertical movement offset relative to the position at which the last packet was sent.
If you’re writing an interrupt handler, see Mouse::read_data_packet
.
Sourcepub fn read_data_packet(
&mut self,
) -> Result<(MouseMovementFlags, i16, i16), MouseError>
pub fn read_data_packet( &mut self, ) -> Result<(MouseMovementFlags, i16, i16), MouseError>
Read an existing movement data packet directly from the data buffer.
The first byte returned is a bitfield, and the other two bytes are 9-bit two’s complement integers for the horizontal and vertical movement offset relative to the position at which the last packet was sent.
This does not send any commands to the mouse. This is useful in interrupt handlers when we just want to read the data sent by the mouse.
Sourcepub fn reset_wrap_mode(&mut self) -> Result<(), MouseError>
pub fn reset_wrap_mode(&mut self) -> Result<(), MouseError>
Reset mouse movement counters and exit wrap mode, entering the mode the mouse was in previously.
Read more about modes here.
Sourcepub fn set_wrap_mode(&mut self) -> Result<(), MouseError>
pub fn set_wrap_mode(&mut self) -> Result<(), MouseError>
Reset mouse movement counters and enter wrap mode.
Read more about modes here.
Sourcepub fn set_remote_mode(&mut self) -> Result<(), MouseError>
pub fn set_remote_mode(&mut self) -> Result<(), MouseError>
Reset mouse movement counters and enter remote mode.
Read more about modes here.
Sourcepub fn get_mouse_type(&mut self) -> Result<MouseType, MouseError>
pub fn get_mouse_type(&mut self) -> Result<MouseType, MouseError>
Attempt to obtain a device identifier for this mouse.
Sourcepub fn set_sample_rate(&mut self, sample_rate: u8) -> Result<(), MouseError>
pub fn set_sample_rate(&mut self, sample_rate: u8) -> Result<(), MouseError>
Set the mouse sample rate and reset the movement counters.
Valid rates are 10
, 20
, 40
, 60
, 80
, 100
, and 200
, in samples per second.
Sourcepub fn enable_data_reporting(&mut self) -> Result<(), MouseError>
pub fn enable_data_reporting(&mut self) -> Result<(), MouseError>
Enable data reporting and reset the movement counters.
This only affects data reporting in stream mode.
Sourcepub fn disable_data_reporting(&mut self) -> Result<(), MouseError>
pub fn disable_data_reporting(&mut self) -> Result<(), MouseError>
Disable data reporting and reset the movement counters.
This only affects data reporting in stream mode. Note that this only disables reporting,
not sampling. Movement packets may still be read using Mouse::request_data_packet
.
Sourcepub fn set_defaults(&mut self) -> Result<(), MouseError>
pub fn set_defaults(&mut self) -> Result<(), MouseError>
Set defaults, clear movement counters, and enter stream mode.
Default settings are as follows: sampling rate = 100 samples/second, resolution = 4 counts/mm, scaling = 1:1, data reporting disabled.
Sourcepub fn resend_last_packet(&mut self) -> Result<(), MouseError>
pub fn resend_last_packet(&mut self) -> Result<(), MouseError>
Request that the mouse resend the last transmitted byte or packet.
Currently, this does not return any data, since the resent data may be one or more bytes in
length. It is the responsibility of the caller to consume these bytes using
Controller::read_data
.
Sourcepub fn reset_and_self_test(&mut self) -> Result<(), MouseError>
pub fn reset_and_self_test(&mut self) -> Result<(), MouseError>
Reset the mouse and perform a Basic Assurance Test.
Returns MouseError::SelfTestFailed
if the test fails.