diff --git a/Cargo.toml b/Cargo.toml index d66f88f..435efee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mouse-keyboard-input" -version = "0.6.1" +version = "0.7.1" authors = ["Andrew Korovkin "] edition = "2021" diff --git a/README.md b/README.md index 8734a80..3449e6b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ sudo apt install libudev-dev libevdev-dev libhidapi-dev Add to `Cargo.toml` ``` -mouse-keyboard-input = "0.6.1" +mouse-keyboard-input = "0.7.1" ``` To use the latest development version: ``` @@ -95,8 +95,8 @@ fn main() { for _ in 1..5 { thread::sleep(Duration::from_secs(1)); - // scroll vertically by 100 - device.scroll_vertical(100).unwrap(); + // scroll down by 100 + device.scroll_vertical(-100).unwrap(); // move cursor vertically the from current position by 50 device.move_mouse(50, 50).unwrap(); //click the left mouse button diff --git a/examples/mouse.rs b/examples/mouse.rs index d501bab..51a6018 100644 --- a/examples/mouse.rs +++ b/examples/mouse.rs @@ -9,8 +9,8 @@ fn main() { for _ in 1..5 { thread::sleep(Duration::from_secs(1)); - // scroll vertically by 100 - device.scroll_y(100).unwrap(); + // scroll down by 100 + device.scroll_y(-100).unwrap(); // move cursor vertically from the current position by 50 device.move_mouse(50, 50).unwrap(); //click the left mouse button diff --git a/src/virtual_device.rs b/src/virtual_device.rs index b5d88dc..da112f7 100644 --- a/src/virtual_device.rs +++ b/src/virtual_device.rs @@ -197,26 +197,26 @@ impl VirtualDevice { #[inline] pub fn send_mouse_move_y(y: Coord, sender: &ChannelSender) -> EmptyResult { - sender.send((EV_REL, REL_Y, y))?; + sender.send((EV_REL, REL_Y, -y))?; Ok(()) } #[inline] pub fn send_mouse_move(x: Coord, y: Coord, sender: &ChannelSender) -> EmptyResult { sender.send((EV_REL, REL_X, x))?; - sender.send((EV_REL, REL_Y, y))?; + sender.send((EV_REL, REL_Y, -y))?; Ok(()) } #[inline] pub fn send_scroll_x(value: Coord, sender: &ChannelSender) -> EmptyResult { - sender.send((EV_REL, REL_HWHEEL, -value))?; + sender.send((EV_REL, REL_HWHEEL, value))?; Ok(()) } #[inline] pub fn send_scroll_y(value: Coord, sender: &ChannelSender) -> EmptyResult { - sender.send((EV_REL, REL_WHEEL, -value))?; + sender.send((EV_REL, REL_WHEEL, value))?; Ok(()) } @@ -274,14 +274,14 @@ impl VirtualDevice { #[inline] pub fn move_mouse_y(&mut self, y: Coord) -> EmptyResult { - self.write(EV_REL, REL_Y, y)?; + self.write(EV_REL, REL_Y, -y)?; self.synchronize() } #[inline] pub fn move_mouse(&mut self, x: Coord, y: Coord) -> EmptyResult { self.write(EV_REL, REL_X, x)?; - self.write(EV_REL, REL_Y, y)?; + self.write(EV_REL, REL_Y, -y)?; self.synchronize() } @@ -293,7 +293,7 @@ impl VirtualDevice { #[inline] pub fn scroll_y(&mut self, value: Coord) -> EmptyResult { - self.write(EV_REL, REL_WHEEL, -value)?; + self.write(EV_REL, REL_WHEEL, value)?; self.synchronize() }