mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Add MouseButton::{Back, Forward} to MouseInput
Add named variants for physical back and forward keys which could be found on some mice. The macOS bits may not work on all the hardware given that apple doesn't directly support such a thing. Co-authored-by: daxpedda <daxpedda@gmail.com>
This commit is contained in:
@@ -397,15 +397,21 @@ impl Default for WinitPointerDataInner {
|
||||
|
||||
/// Convert the Wayland button into winit.
|
||||
fn wayland_button_to_winit(button: u32) -> MouseButton {
|
||||
// These values are comming from <linux/input-event-codes.h>.
|
||||
// These values are coming from <linux/input-event-codes.h>.
|
||||
const BTN_LEFT: u32 = 0x110;
|
||||
const BTN_RIGHT: u32 = 0x111;
|
||||
const BTN_MIDDLE: u32 = 0x112;
|
||||
const BTN_SIDE: u32 = 0x113;
|
||||
const BTN_EXTRA: u32 = 0x114;
|
||||
const BTN_FORWARD: u32 = 0x115;
|
||||
const BTN_BACK: u32 = 0x116;
|
||||
|
||||
match button {
|
||||
BTN_LEFT => MouseButton::Left,
|
||||
BTN_RIGHT => MouseButton::Right,
|
||||
BTN_MIDDLE => MouseButton::Middle,
|
||||
BTN_BACK | BTN_SIDE => MouseButton::Back,
|
||||
BTN_FORWARD | BTN_EXTRA => MouseButton::Forward,
|
||||
button => MouseButton::Other(button as u16),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||
|
||||
use crate::event::{
|
||||
ElementState::{Pressed, Released},
|
||||
MouseButton::{Left, Middle, Other, Right},
|
||||
MouseButton::{Back, Forward, Left, Middle, Other, Right},
|
||||
MouseScrollDelta::LineDelta,
|
||||
Touch,
|
||||
WindowEvent::{
|
||||
@@ -651,6 +651,23 @@ impl<T: 'static> EventProcessor<T> {
|
||||
}
|
||||
}
|
||||
|
||||
8 => callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: MouseInput {
|
||||
device_id,
|
||||
state,
|
||||
button: Back,
|
||||
},
|
||||
}),
|
||||
9 => callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: MouseInput {
|
||||
device_id,
|
||||
state,
|
||||
button: Forward,
|
||||
},
|
||||
}),
|
||||
|
||||
x => callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: MouseInput {
|
||||
|
||||
Reference in New Issue
Block a user