fox32+fox32rom: Add EVENT_TYPE_MOUSE_RELEASE
This commit is contained in:
parent
e7f81afa50
commit
fb3d681f55
19
src/bus.rs
19
src/bus.rs
|
@ -51,15 +51,17 @@ impl Bus {
|
||||||
0x00 => {
|
0x00 => {
|
||||||
// we're reading the button states
|
// we're reading the button states
|
||||||
let mut byte: u8 = 0x00;
|
let mut byte: u8 = 0x00;
|
||||||
let mut mouse_lock = self.mouse.lock().expect("failed to lock the mouse mutex");
|
let mouse_lock = self.mouse.lock().expect("failed to lock the mouse mutex");
|
||||||
if mouse_lock.click {
|
if mouse_lock.clicked {
|
||||||
byte |= 0b01;
|
byte |= 0b001;
|
||||||
mouse_lock.click = false;
|
}
|
||||||
|
if mouse_lock.released {
|
||||||
|
byte |= 0b010;
|
||||||
}
|
}
|
||||||
if mouse_lock.held {
|
if mouse_lock.held {
|
||||||
byte |= 0b10;
|
byte |= 0b100;
|
||||||
} else {
|
} else {
|
||||||
byte &= !0b10;
|
byte &= !0b100;
|
||||||
}
|
}
|
||||||
byte as u32
|
byte as u32
|
||||||
}
|
}
|
||||||
|
@ -145,8 +147,9 @@ impl Bus {
|
||||||
0x00 => {
|
0x00 => {
|
||||||
// we're setting the button states
|
// we're setting the button states
|
||||||
let mut mouse_lock = self.mouse.lock().expect("failed to lock the mouse mutex");
|
let mut mouse_lock = self.mouse.lock().expect("failed to lock the mouse mutex");
|
||||||
mouse_lock.click = word & (1 << 0) != 0;
|
mouse_lock.clicked = word & (1 << 0) != 0;
|
||||||
mouse_lock.held = word & (1 << 1) != 0;
|
mouse_lock.released = word & (1 << 1) != 0;
|
||||||
|
mouse_lock.held = word & (1 << 2) != 0;
|
||||||
}
|
}
|
||||||
0x01 => {
|
0x01 => {
|
||||||
// we're setting the position
|
// we're setting the position
|
||||||
|
|
|
@ -217,9 +217,13 @@ fn main() {
|
||||||
let mut mouse_lock = mouse.lock().expect("failed to lock the mouse mutex");
|
let mut mouse_lock = mouse.lock().expect("failed to lock the mouse mutex");
|
||||||
mouse_lock.x = mouse_pixel.0;
|
mouse_lock.x = mouse_pixel.0;
|
||||||
mouse_lock.y = mouse_pixel.1;
|
mouse_lock.y = mouse_pixel.1;
|
||||||
|
if mouse_lock.held && !input.mouse_held(0) {
|
||||||
|
// mouse button was released this frame
|
||||||
|
mouse_lock.released = true;
|
||||||
|
}
|
||||||
mouse_lock.held = input.mouse_held(0);
|
mouse_lock.held = input.mouse_held(0);
|
||||||
if input.mouse_pressed(0) {
|
if input.mouse_pressed(0) {
|
||||||
mouse_lock.click = true;
|
mouse_lock.clicked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
pub struct Mouse {
|
pub struct Mouse {
|
||||||
pub x: u16,
|
pub x: u16,
|
||||||
pub y: u16,
|
pub y: u16,
|
||||||
pub click: bool,
|
pub clicked: bool,
|
||||||
|
pub released: bool,
|
||||||
pub held: bool,
|
pub held: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mouse {
|
impl Mouse {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Mouse { x: 0, y: 0, click: false, held: false }
|
Mouse { x: 0, y: 0, clicked: false, released: false, held: false }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user