From f46c4a81a67ea98ffb69179ffe557833eafeb846 Mon Sep 17 00:00:00 2001 From: vextrixes <113197359+vextrixes@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:17:46 +0200 Subject: [PATCH] updated effect_info --- Cargo.toml | 3 ++- src/lib.rs | 3 +++ src/rgb_controller/controller.rs | 15 ++++++++++++--- src/rgb_controller/effect_info.rs | 31 ++++++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c4c958c..f2d984e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ edition = "2024" hidapi = "2.6.6" [features] -access_hid_wrapper = [] \ No newline at end of file +access_hid_wrapper = [] +fast_controller_experimental = [] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 265dae6..74912e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,9 @@ pub use color::Color; pub use hid_wrapper::HidWrapperError; pub use keymap::{Keymap, KeymapKeys}; pub use rgb_controller::controller::RGBController; +pub use rgb_controller::effect_info::{ + DirectionPolicy, EFFECTS, EffectInfo, HorizontalDirections, VerticalDirections, +}; pub use rgb_controller::effects::Effects; #[cfg(feature = "access_hid_wrapper")] diff --git a/src/rgb_controller/controller.rs b/src/rgb_controller/controller.rs index f35ecf7..3107e6c 100644 --- a/src/rgb_controller/controller.rs +++ b/src/rgb_controller/controller.rs @@ -39,7 +39,10 @@ impl RGBController { /// ```HidWrapperError::NoHidDeviceError``` fn prepare_device(&mut self) -> Result<(), HidWrapperError> { self.hid_wrapper.send_report(&[0x04, 0xab])?; - self.hid_wrapper.get_report()?; + #[cfg(not(feature = "fast_controller_experimental"))] + { + self.hid_wrapper.get_report()?; + } self.hid_wrapper.send_report(&[ 0x26, 0x36, 0xf2, 0x27, 0xb7, 0x2a, 0x56, 0x77, 0x98, 0x59, 0x9c, 0x6d, 0x9f, 0xc6, @@ -54,7 +57,10 @@ impl RGBController { self.hid_wrapper .send_report(&[0x04, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12])?; - self.hid_wrapper.get_report()?; + #[cfg(not(feature = "fast_controller_experimental"))] + { + self.hid_wrapper.get_report()?; + } Ok(()) } @@ -191,7 +197,10 @@ impl RGBController { /// ```HidWrapperError::NoHidDeviceError``` fn apply_to_device(&mut self) -> Result<(), HidWrapperError> { self.hid_wrapper.send_report(&[0x04, 0x02])?; - self.hid_wrapper.get_report()?; + #[cfg(not(feature = "fast_controller_experimental"))] + { + self.hid_wrapper.get_report()?; + } self.hid_wrapper.send_report(&[0x04, 0xf0])?; diff --git a/src/rgb_controller/effect_info.rs b/src/rgb_controller/effect_info.rs index ce2c3c4..2164011 100644 --- a/src/rgb_controller/effect_info.rs +++ b/src/rgb_controller/effect_info.rs @@ -1,6 +1,5 @@ use crate::Effects; -#[allow(dead_code)] pub struct EffectInfo<'a> { name: &'a str, effect: Effects, @@ -11,14 +10,12 @@ pub struct EffectInfo<'a> { requires_keymap: bool, } -#[allow(dead_code)] pub enum DirectionPolicy { None, Horizontal01, Vertical23, } -#[allow(dead_code)] pub const EFFECTS: [EffectInfo; 20] = [ EffectInfo { name: "Static", @@ -201,3 +198,31 @@ pub const EFFECTS: [EffectInfo; 20] = [ requires_keymap: true, }, ]; + +pub enum HorizontalDirections { + Left, + Right, +} + +impl HorizontalDirections { + pub fn to_u8(&self) -> u8 { + match self { + HorizontalDirections::Left => 0, + HorizontalDirections::Right => 1, + } + } +} + +pub enum VerticalDirections { + Down, + Up, +} + +impl VerticalDirections { + pub fn to_u8(&self) -> u8 { + match self { + VerticalDirections::Down => 2, + VerticalDirections::Up => 3, + } + } +}