Skip to content

Commit

Permalink
List identifiers when no valid keyboard exists
Browse files Browse the repository at this point in the history
  • Loading branch information
4JX committed May 8, 2024
1 parent 5322239 commit b59cc81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 16 additions & 1 deletion app/src/gui/modals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eframe::egui::Context;
use eframe::egui::{Area, Color32, ComboBox, Context, Frame, ScrollArea};
use egui_modal::Modal;

use crate::util;
Expand Down Expand Up @@ -41,6 +41,21 @@ pub fn manager_error(ctx: &Context) -> bool {
util::clickable_link(ui, "https://github.com/4JX/L5P-Keyboard-RGB#usage");
});
modal.body(ui, "In certain cases, this may be due to a hardware error.");

if let Ok(list) = legion_rgb_driver::find_possible_keyboards() {
modal.body(ui, "Please attach the following list of identifiers when making an issue:");
Frame::none().fill(Color32::from_gray(20)).inner_margin(5.0).rounding(6.0).show(ui, |ui| {
ScrollArea::vertical().show(ui, |ui| {
if list.is_empty() {
ui.label("No candidates found");
} else {
for d in list {
ui.label(d);
}
}
});
});
}
});

modal.buttons(ui, |ui| {
Expand Down
12 changes: 11 additions & 1 deletion driver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use error::{RangeError, RangeErrorKind, Result};
use hidapi::{HidApi, HidDevice};
use hidapi::{DeviceInfo, HidApi, HidDevice};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -230,3 +230,13 @@ pub fn get_keyboard(stop_signal: Arc<AtomicBool>) -> Result<Keyboard> {
keyboard.refresh()?;
Ok(keyboard)
}

pub fn find_possible_keyboards<'a>() -> Result<Vec<String>> {
let api: HidApi = HidApi::new()?;

Ok(api
.device_list()
// .filter(|d| d.vendor_id() == 0x048d)
.map(|d| format!("{:#06x}:{:#06x}", d.vendor_id(), d.product_id()))
.collect())
}

0 comments on commit b59cc81

Please sign in to comment.