Fix tests

This commit is contained in:
Luke D. Jones
2024-04-11 12:51:41 +12:00
parent 484ca692ad
commit 3142353f98
6 changed files with 229 additions and 43 deletions

View File

@@ -361,6 +361,7 @@ mod tests {
let config = AuraConfig::new("19b6");
let supported_basic_modes = LedSupportData {
device_name: String::new(),
product_id: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![],
@@ -401,6 +402,7 @@ mod tests {
let config = AuraConfig::new("19b6");
let supported_basic_modes = LedSupportData {
device_name: String::new(),
product_id: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![AuraZone::Key1, AuraZone::Key2],

View File

@@ -1,6 +1,7 @@
([
(
device_name: "FA506I",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -9,6 +10,7 @@
),
(
device_name: "FA506Q",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [],
@@ -17,6 +19,7 @@
),
(
device_name: "FA507",
product_id: "",
layout_name: "fa507",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -25,6 +28,7 @@
),
(
device_name: "FX505D",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -33,6 +37,7 @@
),
(
device_name: "FX505G",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -41,6 +46,7 @@
),
(
device_name: "FX506H",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -49,6 +55,7 @@
),
(
device_name: "FX506L",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -57,6 +64,7 @@
),
(
device_name: "FX507Z",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -65,6 +73,7 @@
),
(
device_name: "FX516P",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Strobe],
basic_zones: [],
@@ -73,6 +82,7 @@
),
(
device_name: "FX705D",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -81,6 +91,7 @@
),
(
device_name: "G512",
product_id: "",
layout_name: "g512",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -89,6 +100,7 @@
),
(
device_name: "G512LV",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -97,6 +109,7 @@
),
(
device_name: "G513I",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -105,6 +118,7 @@
),
(
device_name: "G513QE",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -113,6 +127,7 @@
),
(
device_name: "G513QM",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -121,6 +136,7 @@
),
(
device_name: "G513QR",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -129,6 +145,7 @@
),
(
device_name: "G513QY",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -137,6 +154,7 @@
),
(
device_name: "G513RC",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -145,6 +163,7 @@
),
(
device_name: "G513RM",
product_id: "",
layout_name: "g513i",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -153,6 +172,7 @@
),
(
device_name: "G513RW",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -161,6 +181,7 @@
),
(
device_name: "G531",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -169,6 +190,7 @@
),
(
device_name: "G531",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -177,6 +199,7 @@
),
(
device_name: "G531GD",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -185,6 +208,7 @@
),
(
device_name: "G531GT",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [],
@@ -193,6 +217,7 @@
),
(
device_name: "G531GU",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -201,6 +226,7 @@
),
(
device_name: "G531GV",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -209,6 +235,7 @@
),
(
device_name: "G531GW",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -217,6 +244,7 @@
),
(
device_name: "G532",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -225,6 +253,7 @@
),
(
device_name: "G533Q",
product_id: "",
layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -233,6 +262,7 @@
),
(
device_name: "G533Z",
product_id: "",
layout_name: "g533q-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -241,6 +271,7 @@
),
(
device_name: "G614J",
product_id: "",
layout_name: "g634j-per-key",
basic_modes: [Static, Breathe, Pulse, Strobe, Rainbow],
basic_zones: [],
@@ -249,6 +280,7 @@
),
(
device_name: "G634J",
product_id: "",
layout_name: "g634j-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -257,6 +289,7 @@
),
(
device_name: "G712LI",
product_id: "",
layout_name: "gl503",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -265,6 +298,7 @@
),
(
device_name: "G712LV",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -273,6 +307,7 @@
),
(
device_name: "G712LW",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -281,6 +316,7 @@
),
(
device_name: "G713IC",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -289,6 +325,7 @@
),
(
device_name: "G713QM",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -297,6 +334,7 @@
),
(
device_name: "G713QR",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -305,6 +343,7 @@
),
(
device_name: "G713RC",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -313,6 +352,7 @@
),
(
device_name: "G713RM",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -321,6 +361,7 @@
),
(
device_name: "G713RS",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -329,6 +370,7 @@
),
(
device_name: "G713RW",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -337,6 +379,7 @@
),
(
device_name: "G731",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -345,6 +388,7 @@
),
(
device_name: "G731GT",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [],
@@ -353,6 +397,7 @@
),
(
device_name: "G731GU",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [],
@@ -361,6 +406,7 @@
),
(
device_name: "G731GV",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -369,6 +415,7 @@
),
(
device_name: "G731GW",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -377,6 +424,7 @@
),
(
device_name: "G733C",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [Logo, BarLeft, BarRight],
@@ -385,6 +433,7 @@
),
(
device_name: "G733PZ",
product_id: "",
layout_name: "g733pz-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -393,6 +442,7 @@
),
(
device_name: "G733Q",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -401,6 +451,7 @@
),
(
device_name: "G733Z",
product_id: "",
layout_name: "g513i-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -409,6 +460,7 @@
),
(
device_name: "G814JI",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -417,6 +469,7 @@
),
(
device_name: "G814JZ",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -425,6 +478,7 @@
),
(
device_name: "G834JZ",
product_id: "",
layout_name: "g814ji-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -433,6 +487,7 @@
),
(
device_name: "GA401Q",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -441,6 +496,7 @@
),
(
device_name: "GA402N",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
basic_zones: [],
@@ -449,6 +505,7 @@
),
(
device_name: "GA402R",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow],
basic_zones: [],
@@ -457,14 +514,25 @@
),
(
device_name: "GA402X",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "GA403UI",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "GA503Q",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
basic_zones: [],
@@ -473,6 +541,7 @@
),
(
device_name: "GA503QE",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -481,6 +550,7 @@
),
(
device_name: "GA503R",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe],
basic_zones: [],
@@ -489,6 +559,7 @@
),
(
device_name: "GL503",
product_id: "",
layout_name: "gl503",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -497,6 +568,7 @@
),
(
device_name: "GL503V",
product_id: "",
layout_name: "gl503",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -505,6 +577,7 @@
),
(
device_name: "GL504G",
product_id: "",
layout_name: "gl503",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4, Logo, BarLeft, BarRight],
@@ -513,6 +586,7 @@
),
(
device_name: "GL531",
product_id: "",
layout_name: "g512",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -521,6 +595,7 @@
),
(
device_name: "GL553VE",
product_id: "",
layout_name: "g533q",
basic_modes: [Static, Breathe, Strobe],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -529,6 +604,7 @@
),
(
device_name: "GL703G",
product_id: "",
layout_name: "gl503",
basic_modes: [Static, Breathe, Strobe, Rainbow],
basic_zones: [],
@@ -537,6 +613,7 @@
),
(
device_name: "GM501G",
product_id: "",
layout_name: "fa507",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -545,6 +622,7 @@
),
(
device_name: "GU502",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -553,6 +631,7 @@
),
(
device_name: "GU502G",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -561,6 +640,7 @@
),
(
device_name: "GU502L",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -569,6 +649,7 @@
),
(
device_name: "GU502LU",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -577,6 +658,7 @@
),
(
device_name: "GU603H",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -585,6 +667,7 @@
),
(
device_name: "GU603VV",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -593,6 +676,7 @@
),
(
device_name: "GU603Z",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -601,6 +685,7 @@
),
(
device_name: "GU604V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -609,6 +694,7 @@
),
(
device_name: "GV301Q",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -617,6 +703,7 @@
),
(
device_name: "GV301V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -625,6 +712,7 @@
),
(
device_name: "GV301VIC",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -633,6 +721,7 @@
),
(
device_name: "GV601R",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -641,6 +730,7 @@
),
(
device_name: "GV601V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -649,6 +739,7 @@
),
(
device_name: "GV604V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Strobe, Pulse],
basic_zones: [],
@@ -657,6 +748,7 @@
),
(
device_name: "GX502",
product_id: "",
layout_name: "gx502",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -665,6 +757,7 @@
),
(
device_name: "GX531",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [Key1, Key2, Key3, Key4],
@@ -673,6 +766,7 @@
),
(
device_name: "GX550L",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -681,6 +775,7 @@
),
(
device_name: "GX551Q",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse],
basic_zones: [],
@@ -689,6 +784,7 @@
),
(
device_name: "GX650P",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -697,6 +793,7 @@
),
(
device_name: "GX701",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -705,6 +802,7 @@
),
(
device_name: "GX703H",
product_id: "",
layout_name: "gx531-per-key",
basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
basic_zones: [],
@@ -713,6 +811,7 @@
),
(
device_name: "GZ301V",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -721,6 +820,7 @@
),
(
device_name: "GZ301VIC",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
@@ -729,26 +829,29 @@
),
(
device_name: "GZ301Z",
product_id: "1a30",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "GZ301Z",
product_id: "18c6",
layout_name: "",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [None],
),
(
device_name: "RC71L",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
(
device_name: "GA403UI",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
])
])

View File

@@ -13,7 +13,6 @@ pub struct LedSupportData {
/// This can be many different types of name:
/// - `/sys/class/dmi/id/board_name` (must use for laptops)
/// - The device name from `lsusb`
/// - The product ID (usb only)
///
/// The laptop board_name is found via `cat /sys/class/dmi/id/board_name`,
/// e.g `GU603ZW`. The match doesn't have to be the complete model
@@ -26,16 +25,19 @@ pub struct LedSupportData {
/// If using a device name the match is similar to the above where it can be
/// partial, so `ASUSTek Computer, Inc. ROG STRIX Arion` can be `STRIX
/// Arion` for short. Case insensitive.
///
pub device_name: String,
/// The product ID (usb only)
/// Example of using a product ID is:
/// ```
/// ```ignore
/// $ lsusb
/// $ Bus 003 Device 003: ID 0b05:19b6 ASUSTek Computer, Inc. N-KEY Device
/// ```
/// here `19b6` is all that is required. Case insensitive.
pub device_name: String,
#[serde(default)]
pub product_id: String,
/// Keyboard or device LED layout, this is the name of the externally
/// defined layout file. Optional, can be an empty string
#[serde(default)]
pub layout_name: String,
/// If empty will default to `Static` mode
pub basic_modes: Vec<AuraModeNum>,
@@ -43,9 +45,11 @@ pub struct LedSupportData {
/// 4 zones and may have a logo and lightbar.
///
/// Ignored if empty.
#[serde(default)]
pub basic_zones: Vec<AuraZone>,
/// `Zoned` or `PerKey`.
// TODO: remove and use layouts only
#[serde(default)]
pub advanced_type: AdvancedAuraType,
/// If empty will default to `Keyboard` power zone
pub power_zones: Vec<PowerZones>,
@@ -55,13 +59,13 @@ impl LedSupportData {
/// Find the data for the device. This function will check DMI info for
/// matches against laptops first, then will proceed with matching the
/// `device_name` if there are no DMI matches.
pub fn get_data(_device_name: &str) -> Self {
pub fn get_data(product_id: &str) -> Self {
let dmi = DMIID::new().unwrap_or_default();
// let prod_family = dmi.product_family().expect("Could not get
// product_family");
if let Some(data) = LedSupportFile::load_from_supoprt_db() {
if let Some(data) = data.match_device(&dmi.board_name) {
if let Some(data) = data.match_device(&dmi.board_name, product_id) {
return data;
}
}
@@ -80,10 +84,18 @@ impl LedSupportFile {
/// The list is stored in ordered format, so the iterator must be reversed
/// to ensure we match to *whole names* first before doing a glob match
fn match_device(&self, device_name: &str) -> Option<LedSupportData> {
fn match_device(&self, device_name: &str, product_id: &str) -> Option<LedSupportData> {
for config in self.0.iter().rev() {
if device_name.contains(&config.device_name) {
info!("LedSupport: Matched to {}", config.device_name);
info!("Matched to {}", config.device_name);
if !config.product_id.is_empty() {
info!("Checking product ID");
if config.product_id == product_id {
return Some(config.clone());
} else {
continue;
}
}
return Some(config.clone());
}
}
@@ -157,6 +169,7 @@ mod tests {
fn check_data_parse() {
let led = LedSupportData {
device_name: "Test".to_owned(),
product_id: String::new(),
layout_name: "ga401".to_owned(),
basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft],

View File

@@ -4,6 +4,9 @@ use typeshare::typeshare;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
// TODO: GZ301Z
// 5dbcd0010300000a00ff0000ff0000ff0000ff0000ff0000ff0000ff0000ff0000ff0000ff0000
/// The `LedCode` used in setting up keyboard layouts is important because it
/// determines the idexing for an RGB value in the final USB packets (for
/// per-key addressable keyboards).

View File

@@ -531,6 +531,10 @@ mod tests {
data_path.push("loop_prep");
for config in data.get().iter().rev() {
if config.layout_name.is_empty() {
continue;
}
buf.clear();
let layout_file = format!("{}_US.ron", config.layout_name);

View File

@@ -305,7 +305,7 @@ mod test {
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
let bytes = AuraPowerState {
zone: PowerZones::Keyboard,
zone: PowerZones::None,
awake: false,
boot: false,
sleep: true,
@@ -316,7 +316,7 @@ mod test {
assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]);
let bytes = AuraPowerState {
zone: PowerZones::Keyboard,
zone: PowerZones::None,
awake: false,
boot: true,
sleep: false,
@@ -353,140 +353,180 @@ mod test {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: true,
..Default::default()
awake: false,
sleep: false,
shutdown: false,
}],
});
let boot_keyb_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: true,
..Default::default()
awake: false,
sleep: false,
shutdown: false,
}],
});
let sleep_logo = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: true,
..Default::default()
shutdown: false,
}],
});
let sleep_keyb = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: true,
..Default::default()
shutdown: false,
}],
});
let awake_logo = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: true,
..Default::default()
sleep: false,
shutdown: false,
}],
});
let awake_keyb = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: true,
..Default::default()
sleep: false,
shutdown: false,
}],
});
let shut_logo_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Logo,
boot: false,
awake: false,
sleep: false,
shutdown: true,
..Default::default()
}],
});
let shut_keyb_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Keyboard,
boot: false,
awake: false,
sleep: false,
shutdown: true,
..Default::default()
}],
});
let boot_bar__ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: true,
..Default::default()
awake: false,
sleep: false,
shutdown: false,
}],
});
let awake_bar_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: true,
..Default::default()
sleep: false,
shutdown: false,
}],
});
let sleep_bar_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: true,
..Default::default()
shutdown: false,
}],
});
let shut_bar__ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lightbar,
boot: false,
awake: false,
sleep: false,
shutdown: true,
..Default::default()
}],
});
let boot_lid__ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: true,
..Default::default()
awake: false,
sleep: false,
shutdown: false,
}],
});
let awake_lid_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: true,
..Default::default()
sleep: false,
shutdown: false,
}],
});
let sleep_lid_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: true,
..Default::default()
shutdown: false,
}],
});
let shut_lid__ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::Lid,
boot: false,
awake: false,
sleep: false,
shutdown: true,
..Default::default()
}],
});
let boot_rear_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: true,
..Default::default()
awake: false,
sleep: false,
shutdown: false,
}],
});
let awake_rear = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: true,
..Default::default()
sleep: false,
shutdown: false,
}],
});
let sleep_rear = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: true,
..Default::default()
shutdown: false,
}],
});
let shut_rear_ = to_binary_string(&LaptopAuraPower {
states: vec![AuraPowerState {
zone: PowerZones::RearGlow,
boot: false,
awake: false,
sleep: false,
shutdown: true,
..Default::default()
}],
});
@@ -515,9 +555,30 @@ mod test {
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
// All on
let byte1 =
LaptopAuraPower::new(AuraDeviceType::LaptopPost2021, &LedSupportData::default());
let out = to_binary_string(&byte1);
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
let byte1 = to_binary_string(&LaptopAuraPower {
states: vec![
AuraPowerState {
zone: PowerZones::Keyboard,
..Default::default()
},
AuraPowerState {
zone: PowerZones::Lid,
..Default::default()
},
AuraPowerState {
zone: PowerZones::Logo,
..Default::default()
},
AuraPowerState {
zone: PowerZones::Lightbar,
..Default::default()
},
AuraPowerState {
zone: PowerZones::RearGlow,
..Default::default()
},
],
});
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
}
}