hidpp/feature/
disable_keys.rs1use openlogi_hidpp_derive::Feature;
8
9use crate::{feature::FeatureEndpoint, protocol::v20::Hidpp20Error};
10
11bitflags::bitflags! {
12 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
17 #[cfg_attr(feature = "serde", derive(serde::Serialize))]
18 pub struct DisableableKeys: u8 {
19 const CAPS_LOCK = 1 << 0;
21 const NUM_LOCK = 1 << 1;
23 const SCROLL_LOCK = 1 << 2;
25 const INSERT = 1 << 3;
27 const WINDOWS = 1 << 4;
29 }
30}
31
32#[derive(Clone, Feature)]
34#[creatable(id = 0x4521, version = 0)]
35pub struct DisableKeysFeature {
36 endpoint: FeatureEndpoint,
38}
39
40impl DisableKeysFeature {
41 pub async fn get_capabilities(&self) -> Result<DisableableKeys, Hidpp20Error> {
43 let payload = self.endpoint.call(0, [0; 3]).await?.extend_payload();
44 Ok(DisableableKeys::from_bits_retain(payload[0]))
45 }
46
47 pub async fn get_disabled_keys(&self) -> Result<DisableableKeys, Hidpp20Error> {
49 let payload = self.endpoint.call(1, [0; 3]).await?.extend_payload();
50 Ok(DisableableKeys::from_bits_retain(payload[0]))
51 }
52
53 pub async fn set_disabled_keys(
58 &self,
59 keys: DisableableKeys,
60 ) -> Result<DisableableKeys, Hidpp20Error> {
61 let payload = self
62 .endpoint
63 .call(2, [keys.bits(), 0, 0])
64 .await?
65 .extend_payload();
66 Ok(DisableableKeys::from_bits_retain(payload[0]))
67 }
68}