Skip to content

Commit

Permalink
buffer as slice
Browse files Browse the repository at this point in the history
  • Loading branch information
positiveway committed Jun 7, 2024
1 parent 209ec8e commit 75c994d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/virtual_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl VirtualDevice {
}

#[inline]
pub fn write_batch(&mut self, batch: Vec<EventParams>) -> EmptyResult{
pub fn write_batch(&mut self, batch: &[EventParams]) -> EmptyResult{
let mut converted = Vec::new();

for event in batch{
Expand Down Expand Up @@ -394,7 +394,7 @@ impl VirtualDevice {

#[inline]
pub fn move_mouse_raw(&mut self, x: Coord, y: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_X, x),
(EV_REL, REL_Y, -y),
])
Expand Down Expand Up @@ -463,23 +463,23 @@ impl VirtualDevice {

#[inline]
pub fn move_mouse_x(&mut self, x: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_X, x),
SYN_PARAMS
])
}

#[inline]
pub fn move_mouse_y(&mut self, y: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_Y, -y),
SYN_PARAMS
])
}

#[inline]
pub fn move_mouse(&mut self, x: Coord, y: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_X, x),
(EV_REL, REL_Y, -y),
SYN_PARAMS
Expand Down Expand Up @@ -551,7 +551,7 @@ impl VirtualDevice {

#[inline]
pub fn scroll_x(&mut self, value: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_HWHEEL, value),
SYN_PARAMS
])
Expand Down Expand Up @@ -597,7 +597,7 @@ impl VirtualDevice {

#[inline]
pub fn scroll_y(&mut self, value: Coord) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_REL, REL_WHEEL, value),
SYN_PARAMS
])
Expand All @@ -621,15 +621,15 @@ impl VirtualDevice {

#[inline]
pub fn press(&mut self, button: Button) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_KEY, button, 1),
SYN_PARAMS
])
}

#[inline]
pub fn release(&mut self, button: Button) -> EmptyResult {
self.write_batch(vec![
self.write_batch(&[
(EV_KEY, button, 0),
SYN_PARAMS
])
Expand Down

0 comments on commit 75c994d

Please sign in to comment.