logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::engine::d2::{
    input::{MouseButton, MouseCursor, MouseEvent},
    subsystem::MouseSystem,
    util::Signal1,
};

pub struct DummyMouse {
    pub down: Signal1<MouseEvent>,
    pub move_: Signal1<MouseEvent>,
    pub up: Signal1<MouseEvent>,
    pub scroll: Signal1<f32>,
    cursor: MouseCursor,
}

impl DummyMouse {
    pub fn new() -> Self {
        Self {
            down: Signal1::new(None),
            move_: Signal1::new(None),
            up: Signal1::new(None),
            scroll: Signal1::new(None),
            cursor: MouseCursor::Default,
        }
    }

    pub fn set_cursor(&mut self, cursor: MouseCursor) {
        self.cursor = cursor;
    }
}

impl MouseSystem for DummyMouse {
    fn down_signal(&self) -> &Signal1<MouseEvent> {
        &self.down
    }

    fn move_signal(&self) -> &Signal1<MouseEvent> {
        &self.move_
    }

    fn scroll_signal(&self) -> &Signal1<f32> {
        &self.scroll
    }

    fn up_signal(&self) -> &Signal1<MouseEvent> {
        &self.up
    }

    fn is_supported(&self) -> bool {
        false
    }

    fn x(&self) -> f32 {
        0.0
    }

    fn y(&self) -> f32 {
        0.0
    }

    fn is_down(&self, button: MouseButton) -> bool {
        false
    }

    fn cursor(&self) -> MouseCursor {
        self.cursor
    }
}