Better handling

This commit is contained in:
Luke
2020-04-20 20:56:49 +12:00
parent a78b3ffd84
commit 21f89807d0
6 changed files with 93 additions and 118 deletions

View File

@@ -23,12 +23,7 @@ pub fn match_laptop() -> Result<Box<dyn Laptop>, AuraError> {
/// has 3 explicit groups: main, vol+media, and the ones that the Linux kernel doesn't
/// map.
pub trait Laptop {
fn do_hotkey_action(
&self,
core: &mut RogCore,
key_byte: u8,
virt: Box<dyn Fn(u8)>,
) -> Result<(), AuraError>;
fn do_hotkey_action(&self, core: &mut RogCore, key_byte: u8) -> Result<(), AuraError>;
fn hotkey_group_bytes(&self) -> &[u8];
fn led_iface_num(&self) -> u8;
fn supported_modes(&self) -> &[BuiltInModeByte];
@@ -82,12 +77,7 @@ impl LaptopGX502GW {
}
}
impl Laptop for LaptopGX502GW {
fn do_hotkey_action(
&self,
rogcore: &mut RogCore,
key_byte: u8,
virt: Box<dyn Fn(u8)>,
) -> Result<(), AuraError> {
fn do_hotkey_action(&self, rogcore: &mut RogCore, key_byte: u8) -> Result<(), AuraError> {
match GX502GWKeys::from(key_byte) {
GX502GWKeys::LedBrightUp => {
let mut bright = rogcore.config().brightness;
@@ -159,7 +149,7 @@ impl Laptop for LaptopGX502GW {
"Unmapped key, attempt to pass to virtual device: {:?}, {:X?}",
&key_byte, &key_byte
);
virt(key_byte);
rogcore.virt_keys().press(key_byte);
}
}
}