8000 Add support for mouse buttons 4 & 5 by guy-bartkus · Pull Request #471 · not-fl3/miniquad · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for mouse buttons 4 & 5 #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ debug-assertions = false
incremental = false
rpath = false
codegen-units = 1
strip = true
strip = true
15 changes: 15 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ pub enum MouseButton {
Left = 0,
Middle = 1,
Right = 2,
MB4 = 3,
MB5 = 4,
Unknown = 255,
}

impl MouseButton {
pub fn from_u8(value: u8) -> MouseButton {
match value {
0 => MouseButton::Left,
1 => MouseButton::Middle,
2 => MouseButton::Right,
3 => MouseButton::MB4,
4 => MouseButton::MB5,
_ => MouseButton::Unknown,
}
}
}

#[derive(Debug, Copy, Clone)]
pub struct Touch {
pub id: u32,
Expand Down
18 changes: 18 additions & 0 deletions src/native/windows.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::TryFrom;

Check warning on line 1 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unused import: `std::convert::TryFrom`

Check warning on line 1 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

unused import: `std::convert::TryFrom`

use crate::{
conf::{Conf, Icon},
event::{KeyMods, MouseButton},
Expand Down Expand Up @@ -160,7 +162,7 @@
unsafe {
#[cfg(target_arch = "x86_64")]
SetWindowLongPtrA(self.wnd, GWL_STYLE, win_style as _);
#[cfg(target_arch = "i686")]

Check warning on line 165 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unexpected `cfg` condition value: `i686`

C 10000 heck warning on line 165 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

unexpected `cfg` condition value: `i686`
SetWindowLong(self.wnd, GWL_STYLE, win_style as _);

if self.fullscreen {
Expand Down Expand Up @@ -362,6 +364,14 @@

event_handler.mouse_button_down_event(MouseButton::Middle, mouse_x, mouse_y);
}
WM_XBUTTONDOWN => {
let mouse_x = payload.mouse_x;
let mouse_y = payload.mouse_y;
let xbutton = GET_XBUTTON_WPARAM(wparam) as u8;
let which = MouseButton::from_u8(xbutton+2);

event_handler.mouse_button_down_event(which, mouse_x, mouse_y);
}
WM_LBUTTONUP => {
let mouse_x = payload.mouse_x;
let mouse_y = payload.mouse_y;
Expand All @@ -380,6 +390,14 @@

event_handler.mouse_button_up_event(MouseButton::Middle, mouse_x, mouse_y);
}
WM_XBUTTONUP => {
let mouse_x = payload.mouse_x;
let mouse_y = payload.mouse_y;
let xbutton = GET_XBUTTON_WPARAM(wparam) as u8;
let which = MouseButton::from_u8(xbutton+2);

event_handler.mouse_button_up_event(which, mouse_x, mouse_y);
}

WM_MOUSEMOVE => {
payload.mouse_x = GET_X_LPARAM(lparam) as f32 * payload.mouse_scale;
Expand Down Expand Up @@ -823,7 +841,7 @@

fn process_request(&mut self, request: Request) {
use Request::*;
unsafe {

Check warning on line 844 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unnecessary `unsafe` block

Check warning on line 844 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

unnecessary `unsafe` block
match request {
ScheduleUpdate => {
self.update_requested = true;
Expand All @@ -837,7 +855,7 @@
} => self.set_window_size(new_width as _, new_height as _),
SetWindowPosition { new_x, new_y } => self.set_window_position(new_x, new_y),
SetFullscreen(fullscreen) => self.set_fullscreen(fullscreen),
ShowKeyboard(show) => {

Check warning on line 858 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unused variable: `show`

Check warning on line 858 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

unused variable: `show`
eprintln!("Not implemented for windows")
}
}
Expand Down Expand Up @@ -916,7 +934,7 @@

#[cfg(target_arch = "x86_64")]
SetWindowLongPtrA(wnd, GWLP_USERDATA, &mut display as *mut _ as isize);
#[cfg(target_arch = "i686")]

Check warning on line 937 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (windows-latest, x86_64-pc-windows-msvc)

unexpected `cfg` condition value: `i686`

Check warning on line 937 in src/native/windows.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-pc-windows-gnu)

unexpected `cfg` condition value: `i686`
SetWindowLong(wnd, GWLP_USERDATA, &mut display as *mut _ as isize);

let mut done = false;
Expand Down
Loading
0