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:
bbb651 2023-06-16 11:51:09 +03:00 committed by GitHub
parent 6300cf915e
commit 4748890935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 9 deletions

View file

@ -1647,7 +1647,8 @@ unsafe fn public_window_callback_inner<T: 'static>(
WM_XBUTTONDOWN => {
use crate::event::{
ElementState::Pressed, MouseButton::Other, WindowEvent::MouseInput,
ElementState::Pressed, MouseButton::Back, MouseButton::Forward, MouseButton::Other,
WindowEvent::MouseInput,
};
let xbutton = super::get_xbutton_wparam(wparam as u32);
@ -1660,7 +1661,11 @@ unsafe fn public_window_callback_inner<T: 'static>(
event: MouseInput {
device_id: DEVICE_ID,
state: Pressed,
button: Other(xbutton),
button: match xbutton {
1 => Back,
2 => Forward,
_ => Other(xbutton),
},
},
});
result = ProcResult::Value(0);
@ -1668,7 +1673,8 @@ unsafe fn public_window_callback_inner<T: 'static>(
WM_XBUTTONUP => {
use crate::event::{
ElementState::Released, MouseButton::Other, WindowEvent::MouseInput,
ElementState::Released, MouseButton::Back, MouseButton::Forward,
MouseButton::Other, WindowEvent::MouseInput,
};
let xbutton = super::get_xbutton_wparam(wparam as u32);
@ -1681,7 +1687,11 @@ unsafe fn public_window_callback_inner<T: 'static>(
event: MouseInput {
device_id: DEVICE_ID,
state: Released,
button: Other(xbutton),
button: match xbutton {
1 => Back,
2 => Forward,
_ => Other(xbutton),
},
},
});
result = ProcResult::Value(0);