Skip to content

Commit

Permalink
feat: ForceFeedbackEvent
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `Event::ForceFeedback` enum variant
  • Loading branch information
arcnmx committed Jul 19, 2024
1 parent 9a2d768 commit d291847
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
EventTime, RangeError, KeyState,
EventKind, SynchronizeKind, Key, RelativeAxis, AbsoluteAxis,
SwitchKind, MiscKind, LedKind, AutorepeatKind, SoundKind, UInputKind,
ForceFeedbackKind,
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -137,6 +138,20 @@ pub struct SoundEvent {
pub value: i32,
}

#[repr(C)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
/// An event that indicates a force feedback effect.
pub struct ForceFeedbackEvent {
/// The timestamp associated with the event.
pub time: EventTime,
event: EventKind,
/// The force effect.
pub kind: ForceFeedbackKind,
/// The value or state associated with the effect.
pub value: i32,
}

#[repr(C)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
Expand Down Expand Up @@ -436,6 +451,7 @@ event_impl! {
struct LedEvent : EventKind::Led { led: LedKind, value: i32 }
struct AutorepeatEvent : EventKind::Autorepeat { kind: AutorepeatKind, value: i32 }
struct SoundEvent : EventKind::Sound { sound: SoundKind, value: i32 }
struct ForceFeedbackEvent : EventKind::ForceFeedback { kind: ForceFeedbackKind, value: i32 }
struct UInputEvent : EventKind::UInput { code: UInputKind, value: i32 }
struct InputEvent : Unknown { code: u16, value: i32 }
}
Expand Down Expand Up @@ -873,5 +889,6 @@ input_event_enum! {
Led(LedEvent),
Autorepeat(AutorepeatEvent),
Sound(SoundEvent),
ForceFeedback(ForceFeedbackEvent),
UInput(UInputEvent),
}
1 change: 1 addition & 0 deletions src/kinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ impl EventKind {
EventKind::Led => Ok(LedKind::COUNT),
EventKind::Sound => Ok(SoundKind::COUNT),
EventKind::Autorepeat => Ok(AutorepeatKind::COUNT),
EventKind::ForceFeedback => Ok(ForceFeedbackKind::COUNT),
EventKind::UInput => Ok(UInputKind::COUNT),
_ => Err(()),
}
Expand Down

0 comments on commit d291847

Please sign in to comment.