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:
@@ -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)
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user