Enum kll_core::TriggerCondition
source · [−]#[repr(u8)]
pub enum TriggerCondition {
Show 14 variants
None,
Switch {
state: Phro,
index: u16,
loop_condition_index: u16,
},
HidLed {
state: Aodo,
loop_condition_index: u16,
index: u8,
},
AnalogDistance {
reserved: u8,
index: u16,
val: i16,
},
AnalogVelocity {
reserved: u8,
index: u16,
val: i16,
},
AnalogAcceleration {
reserved: u8,
index: u16,
val: i16,
},
AnalogJerk {
reserved: u8,
index: u16,
val: i16,
},
Layer {
state: LayerState,
loop_condition_index: u16,
layer: u8,
},
Animation {
state: Dro,
index: u16,
loop_condition_index: u16,
},
Sleep {
state: Aodo,
loop_condition_index: u16,
},
Resume {
state: Aodo,
loop_condition_index: u16,
},
Inactive {
state: Aodo,
loop_condition_index: u16,
},
Active {
state: Aodo,
loop_condition_index: u16,
},
Rotation {
index: u8,
loop_condition_index: u16,
position: i8,
},
}Expand description
Trigger condition definitions
XXX (HaaTa): Field order is extremely important. Rust will optimize field packing if done correctly. Static assertions are included to prevent bad mistakes. Changing the enum size is an API breaking change (requires KLL compiler updates).
Variants
None
Switch
Fields
state: PhroSwitch state
index: u16Switch identification index
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
6 bytes
HidLed
Fields
state: AodoLED state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
index: u8HID LED identification (from USB HID spec, e.g. CapsLock)
5 bytes
AnalogDistance
Fields
reserved: u8Needed focontiguous packing
index: u16Switch identification index
val: i16Analog distance, units depend on the keyboard, KLL compiler handles unit conversion
6 bytes
AnalogVelocity
Fields
reserved: u8Needed for contiguous packing
index: u16Switch identification index
val: i16Analog velocity, units depend on the keyboard, KLL compiler handles unit conversion
6 bytes
AnalogAcceleration
Fields
reserved: u8Needed for contiguous packing
index: u16Switch identification index
val: i16Analog acceleration, units depend on the keyboard, KLL compiler handles unit conversion
6 bytes
AnalogJerk
Fields
reserved: u8Needed for contiguous packing
index: u16Switch identification index
val: i16Analog jerk, units depend on the keyboard, KLL compiler handles unit conversion
6 bytes
Layer
Fields
state: LayerStateLayer state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
layer: u8Layer index (layer 0 is the default state and does not have events)
5 bytes
Animation
Fields
state: DroAnimation state
index: u16Animation index
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
6 bytes
Sleep
Fields
state: AodoSleep state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
Sleep events are always index 0 4 bytes
Resume
Fields
state: AodoResume state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
Resume events are always index 0 4 bytes
Inactive
Fields
state: AodoInactive state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
Inactive events are always index 0 4 bytes
Active
Fields
state: AodoActive state
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
Active events are always index 0 4 bytes
Rotation
Fields
index: u8Rotation index
loop_condition_index: u16Scanning loop condition (number of scanning loops attached to state condition) Lookup index
position: i8Rotation direction (-1,+1)
5 bytes
Implementations
sourceimpl TriggerCondition
impl TriggerCondition
sourcepub const unsafe fn from_byte_array(bytes: [u8; 6]) -> Self
pub const unsafe fn from_byte_array(bytes: [u8; 6]) -> Self
Convert array of bytes to enum
Safety
sourcepub const unsafe fn from_bytes(bytes: &[u8]) -> Self
pub const unsafe fn from_bytes(bytes: &[u8]) -> Self
Convert slice of bytes to enum Aggressively casts the provide u8 slice to retrieve a TriggerCondition
Safety
sourcepub fn index(&self) -> u16
pub fn index(&self) -> u16
Attempts to determine the index value of the condition If an index is not valid, return 0 instead (index may not have any meaning)
sourcepub fn evaluate(
&self,
event: TriggerEvent,
loop_condition_lookup: &[u32]
) -> Vote
pub fn evaluate(
&self,
event: TriggerEvent,
loop_condition_lookup: &[u32]
) -> Vote
Compare TriggerEvent to TriggerCondition NOTE: This is not a direct equivalent comparison each type and state can influence how the loop_condition_index is evaluated. In a way, this is similar to the voting scheme of the older C KLL implementation.
Trait Implementations
sourceimpl Clone for TriggerCondition
impl Clone for TriggerCondition
sourcefn clone(&self) -> TriggerCondition
fn clone(&self) -> TriggerCondition
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for TriggerCondition
impl Debug for TriggerCondition
sourceimpl Format for TriggerCondition
impl Format for TriggerCondition
sourceimpl From<TriggerCondition> for u8
impl From<TriggerCondition> for u8
Convert TriggerCondition into the u8 identifier
sourcefn from(cond: TriggerCondition) -> Self
fn from(cond: TriggerCondition) -> Self
Converts to this type from the input type.
sourceimpl From<TriggerCondition> for TriggerEvent
impl From<TriggerCondition> for TriggerEvent
Convert TriggerCondition to TriggerEvent Used for mainly for kll validation, events are time index 0 and are assumed to be immediate with no history
sourcefn from(cond: TriggerCondition) -> Self
fn from(cond: TriggerCondition) -> Self
Converts to this type from the input type.
sourceimpl Hash for TriggerCondition
impl Hash for TriggerCondition
sourceimpl PartialEq<TriggerCondition> for TriggerCondition
impl PartialEq<TriggerCondition> for TriggerCondition
sourcefn eq(&self, other: &TriggerCondition) -> bool
fn eq(&self, other: &TriggerCondition) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &TriggerCondition) -> bool
fn ne(&self, other: &TriggerCondition) -> bool
This method tests for !=.
impl Copy for TriggerCondition
impl Eq for TriggerCondition
impl StructuralEq for TriggerCondition
impl StructuralPartialEq for TriggerCondition
Auto Trait Implementations
impl RefUnwindSafe for TriggerCondition
impl Send for TriggerCondition
impl Sync for TriggerCondition
impl Unpin for TriggerCondition
impl UnwindSafe for TriggerCondition
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more