rog-platform: Add extra check types to find battery

Closes #243
This commit is contained in:
Luke D. Jones
2022-08-24 10:11:32 +12:00
parent fa1feaf9d9
commit f3876100ae
3 changed files with 61 additions and 183 deletions

View File

@@ -1,3 +1,6 @@
//! A series of pre-defined layouts. These were mostly used to generate an editable
//! config.
/// Hardcoded layout. Was used to generate a toml default
pub mod g513;
/// Hardcoded layout. Was used to generate a toml default

View File

@@ -47,7 +47,7 @@ impl KeyColourArray {
#[inline]
pub fn set(&mut self, key: Key, r: u8, g: u8, b: u8) {
if let Some(c) = self.rgb(key) {
if let Some(c) = self.rgb_for_key(key) {
c[0] = r;
c[1] = g;
c[2] = b;
@@ -56,7 +56,7 @@ impl KeyColourArray {
/// Indexes in to `KeyColourArray` at the correct row and column
/// to set a series of three bytes to the chosen R,G,B values
pub fn rgb(&mut self, key: Key) -> Option<&mut [u8]> {
pub fn rgb_for_key(&mut self, key: Key) -> Option<&mut [u8]> {
// Tuples are indexes in to array
let (row, col) = match key {
Key::VolDown => (0, 15),
@@ -223,171 +223,3 @@ impl KeyColourArray {
pub trait KeyLayout {
fn get_rows(&self) -> &Vec<[Key; 17]>;
}
#[allow(clippy::upper_case_acronyms)]
pub struct GX502Layout(Vec<[Key; 17]>);
impl KeyLayout for GX502Layout {
fn get_rows(&self) -> &Vec<[Key; 17]> {
&self.0
}
}
impl Default for GX502Layout {
fn default() -> Self {
GX502Layout(vec![
[
Key::NormalSpacer,
Key::FuncSpacer,
Key::VolDown,
Key::VolUp,
Key::MicMute,
Key::Rog,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
],
[
Key::Esc,
Key::NormalBlank,
Key::F1,
Key::F2,
Key::F3,
Key::F4,
Key::NormalBlank, // not sure which key to put here
Key::F5,
Key::F6,
Key::F7,
Key::F8,
Key::NormalBlank,
Key::F9,
Key::F10,
Key::F11,
Key::F12,
Key::Del,
],
[
Key::Tilde,
Key::N1,
Key::N2,
Key::N3,
Key::N4,
Key::N5,
Key::N6,
Key::N7,
Key::N8,
Key::N9,
Key::N0,
Key::Hyphen,
Key::Equals,
Key::BkSpc3_1,
Key::BkSpc3_2,
Key::BkSpc3_3,
Key::Home,
],
[
Key::Tab,
Key::Q,
Key::W,
Key::E,
Key::R,
Key::T,
Key::Y,
Key::U,
Key::I,
Key::O,
Key::P,
Key::LBracket,
Key::RBracket,
Key::BackSlash,
Key::BackSlash,
Key::BackSlash,
Key::PgUp,
],
[
Key::Caps,
Key::A,
Key::S,
Key::D,
Key::F,
Key::G,
Key::H,
Key::J,
Key::K,
Key::L,
Key::SemiColon,
Key::Quote,
Key::Quote,
Key::Return3_1,
Key::Return3_2,
Key::Return3_3,
Key::PgDn,
],
[
Key::LShift,
Key::LShift,
Key::Z,
Key::X,
Key::C,
Key::V,
Key::B,
Key::N,
Key::M,
Key::Comma,
Key::Period,
Key::FwdSlash,
Key::FwdSlash,
Key::Rshift3_1,
Key::Rshift3_2,
Key::Rshift3_3,
Key::End,
],
[
Key::LCtrl,
Key::LFn,
Key::Meta,
Key::LAlt,
Key::Space5_1,
Key::Space5_2,
Key::Space5_3,
Key::Space5_4,
Key::Space5_5,
Key::RAlt,
Key::PrtSc,
Key::RCtrl,
Key::RCtrl,
Key::Left,
Key::Up,
Key::Right,
Key::RFn,
],
[
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::NormalBlank,
Key::Left,
Key::Down,
Key::Right,
Key::NormalBlank,
],
])
}
}