Enum TriggerCondition

Source
#[repr(u8)]
pub enum TriggerCondition {
Show 14 variants None = 0, 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 = 0

§

Switch

6 bytes

Fields

§state: Phro

Switch state

§index: u16

Switch identification index

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

HidLed

5 bytes

Fields

§state: Aodo

LED state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§index: u8

HID LED identification (from USB HID spec, e.g. CapsLock)

§

AnalogDistance

6 bytes

Fields

§reserved: u8

Needed focontiguous packing

§index: u16

Switch identification index

§val: i16

Analog distance, units depend on the keyboard, KLL compiler handles unit conversion

§

AnalogVelocity

6 bytes

Fields

§reserved: u8

Needed for contiguous packing

§index: u16

Switch identification index

§val: i16

Analog velocity, units depend on the keyboard, KLL compiler handles unit conversion

§

AnalogAcceleration

6 bytes

Fields

§reserved: u8

Needed for contiguous packing

§index: u16

Switch identification index

§val: i16

Analog acceleration, units depend on the keyboard, KLL compiler handles unit conversion

§

AnalogJerk

6 bytes

Fields

§reserved: u8

Needed for contiguous packing

§index: u16

Switch identification index

§val: i16

Analog jerk, units depend on the keyboard, KLL compiler handles unit conversion

§

Layer

5 bytes

Fields

§state: LayerState

Layer state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§layer: u8

Layer index (layer 0 is the default state and does not have events)

§

Animation

6 bytes

Fields

§state: Dro

Animation state

§index: u16

Animation index

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

Sleep

Sleep events are always index 0 4 bytes

Fields

§state: Aodo

Sleep state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

Resume

Resume events are always index 0 4 bytes

Fields

§state: Aodo

Resume state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

Inactive

Inactive events are always index 0 4 bytes

Fields

§state: Aodo

Inactive state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

Active

Active events are always index 0 4 bytes

Fields

§state: Aodo

Active state

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§

Rotation

5 bytes

Fields

§index: u8

Rotation index

§loop_condition_index: u16

Scanning loop condition (number of scanning loops attached to state condition) Lookup index

§position: i8

Rotation direction (-1,+1)

Implementations§

Source§

impl TriggerCondition

Source

pub const unsafe fn bytes(&self) -> &[u8]

Convert enum to an array of bytes

§Safety
Source

pub const unsafe fn from_byte_array(bytes: [u8; 6]) -> Self

Convert array of bytes to enum

§Safety
Source

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
Source

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)

Source

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§

Source§

impl Clone for TriggerCondition

Source§

fn clone(&self) -> TriggerCondition

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TriggerCondition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

fn from(cond: TriggerCondition) -> Self

Converts to this type from the input type.
Source§

impl From<TriggerCondition> for u8

Convert TriggerCondition into the u8 identifier

Source§

fn from(cond: TriggerCondition) -> Self

Converts to this type from the input type.
Source§

impl Hash for TriggerCondition

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TriggerCondition

Source§

fn eq(&self, other: &TriggerCondition) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TriggerCondition

Source§

impl Eq for TriggerCondition

Source§

impl StructuralPartialEq for TriggerCondition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.