summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-12-12 01:30:31 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-12-12 01:30:31 +0100
commitf86892c2639f0256a99d66bd34f40a572acc070c (patch)
tree06c02a62024198c40ad2fab12b6733d1dd695c74 /src/lib.rs
parent11156b67778ce87a24611b918b60fe970b979755 (diff)
downloadvtcol-f86892c2639f0256a99d66bd34f40a572acc070c.tar.gz
bin: lib: implement setting state of individual LEDs
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0669b87..64cf6f3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -186,7 +186,10 @@ impl KbLedState
}
#[inline]
- pub fn revert(con: &Console) -> io::Result<()> { ioctl::kdsetled(con, None) }
+ pub fn revert(con: &Console) -> io::Result<()>
+ {
+ ioctl::kdsetled(con, None)
+ }
#[inline]
pub fn cap(&self) -> bool { (self.0 & 0x4) != 0 }
@@ -196,6 +199,27 @@ impl KbLedState
#[inline]
pub fn scr(&self) -> bool { (self.0 & 0x1) != 0 }
+
+ #[inline]
+ pub fn set_cap(&mut self, set: bool)
+ {
+ let bit = (set as u8) << 2;
+ self.0 = (self.0 & !bit) | bit;
+ }
+
+ #[inline]
+ pub fn set_num(&mut self, set: bool)
+ {
+ let bit = (set as u8) << 1;
+ self.0 = (self.0 & !bit) | bit;
+ }
+
+ #[inline]
+ pub fn set_scr(&mut self, set: bool)
+ {
+ let bit = set as u8;
+ self.0 = (self.0 & !bit) | bit;
+ }
}
impl fmt::Display for KbLedState