From 42ae103a091596346a7661cb01e01ff46b7339b0 Mon Sep 17 00:00:00 2001 From: Takashi Kitao Date: Mon, 9 Dec 2024 06:48:28 +0900 Subject: [PATCH] Fixed a bug in the mouse cursor position --- CHANGELOG.md | 1 + rust/pyxel-engine/src/input.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dedb1f650..7719279ac0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Updated the glow crate to version 0.16 - Updated the bindgen crate to version 0.71 - Raised the minimum supported macOS to version 13 +- Fixed a bug in the mouse cursor position ## 2.2.7 diff --git a/rust/pyxel-engine/src/input.rs b/rust/pyxel-engine/src/input.rs index b58a525dbd..0e27ec1a42 100644 --- a/rust/pyxel-engine/src/input.rs +++ b/rust/pyxel-engine/src/input.rs @@ -141,11 +141,11 @@ impl Pyxel { let mut value = value; match key { MOUSE_POS_X => { - value = (value - self.system.screen_x) / self.system.screen_scale as i32; + value = ((value - self.system.screen_x) as f64 / self.system.screen_scale) as i32; self.mouse_x = value; } MOUSE_POS_Y => { - value = (value - self.system.screen_y) / self.system.screen_scale as i32; + value = ((value - self.system.screen_y) as f64 / self.system.screen_scale) as i32; self.mouse_y = value; } MOUSE_WHEEL_Y => {