Expose ff effects
This commit is contained in:
parent
93d8fb23e2
commit
5d0c0beda9
3 changed files with 64 additions and 33 deletions
|
@ -285,44 +285,57 @@ impl MiscType {
|
|||
pub(crate) const COUNT: usize = libc::MSC_CNT;
|
||||
}
|
||||
|
||||
// pub enum FFStatusDataIndex {
|
||||
// FF_STATUS_STOPPED = 0x00,
|
||||
// FF_STATUS_PLAYING = 0x01,
|
||||
// }
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub struct FFStatusDataIndex(pub u16);
|
||||
|
||||
// #[derive(Copy, Clone, Copy, Clone)]
|
||||
// pub enum FFEffect {
|
||||
// FF_RUMBLE = 0x50,
|
||||
// FF_PERIODIC = 0x51,
|
||||
// FF_CONSTANT = 0x52,
|
||||
// FF_SPRING = 0x53,
|
||||
// FF_FRICTION = 0x54,
|
||||
// FF_DAMPER = 0x55,
|
||||
// FF_INERTIA = 0x56,
|
||||
// FF_RAMP = 0x57,
|
||||
// FF_SQUARE = 0x58,
|
||||
// FF_TRIANGLE = 0x59,
|
||||
// FF_SINE = 0x5a,
|
||||
// FF_SAW_UP = 0x5b,
|
||||
// FF_SAW_DOWN = 0x5c,
|
||||
// FF_CUSTOM = 0x5d,
|
||||
// FF_GAIN = 0x60,
|
||||
// FF_AUTOCENTER = 0x61,
|
||||
// }
|
||||
evdev_enum!(
|
||||
FFStatusDataIndex,
|
||||
Array,
|
||||
FF_STATUS_STOPPED = 0x00,
|
||||
FF_STATUS_PLAYING = 0x01,
|
||||
);
|
||||
|
||||
// impl FFEffect {
|
||||
// // Needs to be a multiple of 8
|
||||
// pub const COUNT: usize = libc::FF_CNT;
|
||||
// }
|
||||
impl FFStatusDataIndex {
|
||||
pub const COUNT: usize = 2;
|
||||
}
|
||||
|
||||
// #[derive(Copy, Clone, PartialEq, Eq)]
|
||||
// pub struct RepeatType(pub u16);
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub struct FFEffect(pub u16);
|
||||
|
||||
// evdev_enum!(RepeatType, REP_DELAY = 0x00, REP_PERIOD = 0x01,);
|
||||
evdev_enum!(
|
||||
FFEffect,
|
||||
Array,
|
||||
FF_RUMBLE = 0x50,
|
||||
FF_PERIODIC = 0x51,
|
||||
FF_CONSTANT = 0x52,
|
||||
FF_SPRING = 0x53,
|
||||
FF_FRICTION = 0x54,
|
||||
FF_DAMPER = 0x55,
|
||||
FF_INERTIA = 0x56,
|
||||
FF_RAMP = 0x57,
|
||||
FF_SQUARE = 0x58,
|
||||
FF_TRIANGLE = 0x59,
|
||||
FF_SINE = 0x5a,
|
||||
FF_SAW_UP = 0x5b,
|
||||
FF_SAW_DOWN = 0x5c,
|
||||
FF_CUSTOM = 0x5d,
|
||||
FF_GAIN = 0x60,
|
||||
FF_AUTOCENTER = 0x61,
|
||||
);
|
||||
|
||||
// impl RepeatType {
|
||||
// pub(crate) const COUNT: usize = libc::REP_CNT;
|
||||
// }
|
||||
impl FFEffect {
|
||||
// Needs to be a multiple of 8
|
||||
pub const COUNT: usize = libc::FF_CNT;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub struct RepeatType(pub u16);
|
||||
|
||||
evdev_enum!(RepeatType, REP_DELAY = 0x00, REP_PERIOD = 0x01,);
|
||||
|
||||
impl RepeatType {
|
||||
pub const COUNT: usize = libc::REP_CNT;
|
||||
}
|
||||
|
||||
/// A type associated with simple sounds, such as beeps or tones.
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
|
|
|
@ -62,6 +62,7 @@ pub struct RawDevice {
|
|||
supported_switch: Option<AttributeSet<SwitchType>>,
|
||||
supported_led: Option<AttributeSet<LedType>>,
|
||||
supported_misc: Option<AttributeSet<MiscType>>,
|
||||
supported_ff: Option<AttributeSet<FFEffect>>,
|
||||
auto_repeat: Option<AutoRepeat>,
|
||||
// ff: Option<AttributeSet<_>>,
|
||||
// ff_stat: Option<FFStatus>,
|
||||
|
@ -178,6 +179,14 @@ impl RawDevice {
|
|||
None
|
||||
};
|
||||
|
||||
let supported_ff = if ty.contains(EventType::FORCEFEEDBACK) {
|
||||
let mut ff = AttributeSet::<FFEffect>::new();
|
||||
unsafe { sys::eviocgbit_misc(file.as_raw_fd(), ff.as_mut_raw_slice())? };
|
||||
Some(ff)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
//unsafe { sys::eviocgbit(file.as_raw_fd(), ffs(FORCEFEEDBACK.bits()), 0x7f, bits_as_u8_slice)?; }
|
||||
|
||||
let supported_snd = if ty.contains(EventType::SOUND) {
|
||||
|
@ -222,6 +231,7 @@ impl RawDevice {
|
|||
supported_led,
|
||||
supported_misc,
|
||||
supported_snd,
|
||||
supported_ff,
|
||||
auto_repeat,
|
||||
event_buf: Vec::new(),
|
||||
grabbed: false,
|
||||
|
@ -360,6 +370,10 @@ impl RawDevice {
|
|||
self.supported_switch.as_deref()
|
||||
}
|
||||
|
||||
pub fn supported_forcefeedback_effects(&self) -> Option<&AttributeSetRef<FFEffect>> {
|
||||
self.supported_ff.as_deref()
|
||||
}
|
||||
|
||||
/// Returns a set of supported LEDs on the device.
|
||||
///
|
||||
/// Most commonly these are state indicator lights for things like Scroll Lock, but they
|
||||
|
|
|
@ -230,6 +230,10 @@ impl Device {
|
|||
self.raw.supported_switches()
|
||||
}
|
||||
|
||||
pub fn supported_forcefeedback_effects(&self) -> Option<&AttributeSetRef<FFEffect>> {
|
||||
self.raw.supported_forcefeedback_effects()
|
||||
}
|
||||
|
||||
/// Returns a set of supported LEDs on the device.
|
||||
///
|
||||
/// Most commonly these are state indicator lights for things like Scroll Lock, but they
|
||||
|
|
Loading…
Reference in a new issue