Switch to WheelHiRes. Add horizontal scrolling (#171)

* Switch to HiResScroll. Add horizontal scrolling

* Fix OpenVR compilation for horizontal scrolling

* fix OpenXR scroll using x axis for both scroll axes
This commit is contained in:
AdiMCS
2025-03-09 10:20:10 -07:00
committed by GitHub
parent 36074307b7
commit b0883e81bf
14 changed files with 77 additions and 60 deletions

View File

@@ -516,9 +516,10 @@ impl InteractionHandler for KeyboardBackend {
&mut self,
app: &mut AppState,
hit: &crate::backend::input::PointerHit,
delta: f32,
delta_y: f32,
delta_x: f32,
) {
self.canvas.on_scroll(app, hit, delta)
self.canvas.on_scroll(app, hit, delta_y, delta_x)
}
fn on_left(&mut self, app: &mut AppState, pointer: usize) {
self.canvas.on_left(app, pointer)

View File

@@ -88,7 +88,6 @@ fn set_next_move(millis_from_now: u64) {
}
pub struct ScreenInteractionHandler {
next_scroll: Instant,
mouse_transform: Affine2,
}
impl ScreenInteractionHandler {
@@ -113,7 +112,6 @@ impl ScreenInteractionHandler {
};
ScreenInteractionHandler {
next_scroll: Instant::now(),
mouse_transform: transform,
}
}
@@ -152,19 +150,8 @@ impl InteractionHandler for ScreenInteractionHandler {
let pos = self.mouse_transform.transform_point2(hit.uv);
app.hid_provider.mouse_move(pos);
}
fn on_scroll(&mut self, app: &mut AppState, hit: &PointerHit, delta: f32) {
if self.next_scroll > Instant::now() {
return;
}
let max_millis = if matches!(hit.mode, PointerMode::Left) {
200.0
} else {
100.0
};
let millis = (1. - delta.abs()) * max_millis;
self.next_scroll = Instant::now().add(Duration::from_millis(millis as _));
app.hid_provider.wheel(if delta < 0. { -1 } else { 1 })
fn on_scroll(&mut self, app: &mut AppState, _hit: &PointerHit, delta_y: f32, delta_x: f32) {
app.hid_provider.wheel((delta_y*64.) as i32, (delta_x*64.) as i32)
}
fn on_left(&mut self, _app: &mut AppState, _hand: usize) {}
}

View File

@@ -153,13 +153,13 @@ impl InteractionHandler for WayVRInteractionHandler {
}
}
fn on_scroll(&mut self, _app: &mut state::AppState, _hit: &input::PointerHit, delta: f32) {
fn on_scroll(&mut self, _app: &mut state::AppState, _hit: &input::PointerHit, delta_y: f32, delta_x: f32) {
let ctx = self.context.borrow();
ctx.wayvr
.borrow_mut()
.data
.state
.send_mouse_scroll(ctx.display, delta);
.send_mouse_scroll(ctx.display, delta_y, delta_x);
}
}