mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 23:01:30 +11:00
Transparent axis/button IDs
This commit is contained in:
parent
e196f80e98
commit
3d9e8da9ec
|
@ -1,5 +1,5 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use {WindowId, DeviceId, AxisId, ButtonId};
|
use {WindowId, DeviceId};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
|
@ -157,6 +157,12 @@ pub struct Touch {
|
||||||
|
|
||||||
pub type ScanCode = u32;
|
pub type ScanCode = u32;
|
||||||
|
|
||||||
|
/// Identifier for a specific analog axis on some device.
|
||||||
|
pub type AxisId = u32;
|
||||||
|
|
||||||
|
/// Identifier for a specific button on some device.
|
||||||
|
pub type ButtonId = u32;
|
||||||
|
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum ElementState {
|
pub enum ElementState {
|
||||||
Pressed,
|
Pressed,
|
||||||
|
|
|
@ -170,14 +170,6 @@ pub struct WindowId(platform::WindowId);
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DeviceId(platform::DeviceId);
|
pub struct DeviceId(platform::DeviceId);
|
||||||
|
|
||||||
/// Identifier for a specific analog axis on some device.
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct AxisId(u32);
|
|
||||||
|
|
||||||
/// Identifier for a specific button on some device.
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
||||||
pub struct ButtonId(u32);
|
|
||||||
|
|
||||||
/// Provides a way to retreive events from the windows that were registered to it.
|
/// Provides a way to retreive events from the windows that were registered to it.
|
||||||
///
|
///
|
||||||
/// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs.
|
/// To wake up an `EventsLoop` from a another thread, see the `EventsLoopProxy` docs.
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub use self::xdisplay::{XConnection, XNotSupported, XError};
|
||||||
pub mod ffi;
|
pub mod ffi;
|
||||||
|
|
||||||
use platform::PlatformSpecificWindowBuilderAttributes;
|
use platform::PlatformSpecificWindowBuilderAttributes;
|
||||||
use {CreationError, Event, EventsLoopClosed, WindowEvent, DeviceEvent, AxisId, ButtonId,
|
use {CreationError, Event, EventsLoopClosed, WindowEvent, DeviceEvent,
|
||||||
KeyboardInput, ControlFlow};
|
KeyboardInput, ControlFlow};
|
||||||
|
|
||||||
use std::{mem, ptr, slice};
|
use std::{mem, ptr, slice};
|
||||||
|
@ -419,7 +419,7 @@ impl EventsLoop {
|
||||||
} else {
|
} else {
|
||||||
events.push(Event::WindowEvent { window_id: wid, event: AxisMotion {
|
events.push(Event::WindowEvent { window_id: wid, event: AxisMotion {
|
||||||
device_id: did,
|
device_id: did,
|
||||||
axis: AxisId(i as u32),
|
axis: i as u32,
|
||||||
value: unsafe { *value },
|
value: unsafe { *value },
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ impl EventsLoop {
|
||||||
let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) };
|
let xev: &ffi::XIRawEvent = unsafe { &*(xev.data as *const _) };
|
||||||
if xev.flags & ffi::XIPointerEmulated == 0 {
|
if xev.flags & ffi::XIPointerEmulated == 0 {
|
||||||
callback(Event::DeviceEvent { device_id: mkdid(xev.deviceid), event: DeviceEvent::Button {
|
callback(Event::DeviceEvent { device_id: mkdid(xev.deviceid), event: DeviceEvent::Button {
|
||||||
button: ButtonId(xev.detail as u32),
|
button: xev.detail as u32,
|
||||||
state: match xev.evtype {
|
state: match xev.evtype {
|
||||||
ffi::XI_RawButtonPress => Pressed,
|
ffi::XI_RawButtonPress => Pressed,
|
||||||
ffi::XI_RawButtonRelease => Released,
|
ffi::XI_RawButtonRelease => Released,
|
||||||
|
@ -489,7 +489,7 @@ impl EventsLoop {
|
||||||
for i in 0..xev.valuators.mask_len*8 {
|
for i in 0..xev.valuators.mask_len*8 {
|
||||||
if ffi::XIMaskIsSet(mask, i) {
|
if ffi::XIMaskIsSet(mask, i) {
|
||||||
callback(Event::DeviceEvent { device_id: did, event: DeviceEvent::Motion {
|
callback(Event::DeviceEvent { device_id: did, event: DeviceEvent::Motion {
|
||||||
axis: AxisId(i as u32),
|
axis: i as u32,
|
||||||
value: unsafe { *value },
|
value: unsafe { *value },
|
||||||
}});
|
}});
|
||||||
value = unsafe { value.offset(1) };
|
value = unsafe { value.offset(1) };
|
||||||
|
|
Loading…
Reference in a new issue