Skip to content

Commit 2e6f88d

Browse files
committed
[update] mouse events & fix readmes.
1 parent d13fe9d commit 2e6f88d

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
</p>
44

55
[![Cross Platform builds & tests](https://github.com/lambda-sh/lambda/actions/workflows/compile_lambda_rs.yml/badge.svg)](https://github.com/lambda-sh/lambda/actions/workflows/compile_lambda_rs.yml)
6+
![lambda-rs](https://img.shields.io/crates/d/lambda-rs)
7+
![lambda-rs](https://img.shields.io/crates/v/lambda-rs)
8+
69

710

811

crates/lambda-rs-args/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# lambda-rs-args
2+
![lambda-rs](https://img.shields.io/crates/d/lambda-rs-args)
3+
![lambda-rs](https://img.shields.io/crates/v/lambda-rs-args)
4+
25
Argument parsing for lambda-rs applications.
36

47
## Getting started

crates/lambda-rs-platform/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# lambda-rs-platform
2+
![lambda-rs](https://img.shields.io/crates/d/lambda-rs-platform)
3+
![lambda-rs](https://img.shields.io/crates/v/lambda-rs-platform)
4+
25
Platform implementations for lambda-rs. This crate is not intended to be used directly and guarantees no stability across versions.
36

47
## Platforms

crates/lambda-rs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# lambda-rs
2+
![lambda-rs](https://img.shields.io/crates/d/lambda-rs)
3+
![lambda-rs](https://img.shields.io/crates/v/lambda-rs)
4+
25
The lambda-rs crate provides a safe, cross-platform API for building applications on the Lambda platform.
36

47
## Getting started

crates/lambda-rs/src/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ pub enum KeyEvent {
4343

4444
#[derive(Debug, Clone)]
4545
pub enum Mouse {
46-
MouseMoved { x: f32, y: f32, dx: f32, dy: f32 },
47-
MouseWheelPressed { x: f32, y: f32, button: u32 },
48-
MousePressed { x: f32, y: f32, button: u32 },
49-
MouseReleased { x: f32, y: f32, button: u32 },
46+
Moved { x: f64, y: f64, dx: f64, dy: f64 },
47+
WheelPressed { x: f64, y: f64, button: u32 },
48+
Pressed { x: f64, y: f64, button: u32 },
49+
Released { x: f64, y: f64, button: u32 },
5050
}
5151

5252
/// Generic Event Enum which encapsulates all possible events that will be

crates/lambda-rs/src/runtimes/application.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::{
2121
ComponentEvent,
2222
Events,
2323
KeyEvent,
24+
Mouse,
2425
RuntimeEvent,
2526
WindowEvent,
2627
},
@@ -231,7 +232,17 @@ impl Runtime for ApplicationRuntime {
231232
device_id,
232233
position,
233234
modifiers,
234-
} => {None}
235+
} => {
236+
Some(Events::Mouse {
237+
event: Mouse::Moved {
238+
x: position.x,
239+
y: position.y,
240+
dx: 0.0,
241+
dy: 0.0
242+
},
243+
issued_at: Instant::now(),
244+
})
245+
}
235246
WinitWindowEvent::CursorEntered { device_id } => {None}
236247
WinitWindowEvent::CursorLeft { device_id } => {None}
237248
WinitWindowEvent::MouseWheel {
@@ -245,7 +256,25 @@ impl Runtime for ApplicationRuntime {
245256
state,
246257
button,
247258
modifiers,
248-
} => {None}
259+
} => {
260+
let event = match state {
261+
ElementState::Pressed => Mouse::Pressed {
262+
button: button.clone(),
263+
x: 0.0,
264+
y: 0.0,
265+
},
266+
ElementState::Released => Mouse::Released {
267+
button: button.into(),
268+
x: 0.0,
269+
y: 0.0
270+
},
271+
};
272+
273+
Some(Events::Mouse {
274+
event,
275+
issued_at: Instant::now(),
276+
})
277+
}
249278
WinitWindowEvent::TouchpadPressure {
250279
device_id,
251280
pressure,

0 commit comments

Comments
 (0)