mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-06-01 09:00:21 +00:00
Slightly altered virtual mouse position
This commit is contained in:
parent
b6086eed8c
commit
7be70269e9
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -548,7 +548,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "svc16"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "svc16"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
edition = "2021"
|
||||
authors = ["Jan Neuendorf"]
|
||||
description = "An emulator for a simple virtual computer"
|
||||
|
@ -35,7 +35,11 @@ impl Layout {
|
||||
let (raw_x, raw_y) = mouse_position();
|
||||
let clamped_x = (raw_x.clamp(self.x, self.x + self.size) - self.x) / self.size * 255.;
|
||||
let clamped_y = (raw_y.clamp(self.y, self.y + self.size) - self.y) / self.size * 255.;
|
||||
(clamped_x, clamped_y)
|
||||
// The mouse position is slightly modified so that the maximal position can be reached when the image takes up the entire window.
|
||||
(
|
||||
(clamped_x * 255. / 254.).min(255.),
|
||||
(clamped_y * 255. / 254.).min(255.),
|
||||
)
|
||||
}
|
||||
pub fn cursor_in_window(&self) -> bool {
|
||||
let mp = mouse_position();
|
||||
|
Loading…
x
Reference in New Issue
Block a user