Skip to content

Commit

Permalink
Updated Focus crate
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwilding committed Feb 8, 2024
1 parent 2b16d43 commit 63b1807
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions dygma-layer-switcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "dygma-layer-switcher"
version = "0.3.8"
version = "0.3.9"
edition = "2021"
authors = ["Matthew Wilding <[email protected]>"]
build = "build.rs"

[dependencies]
anyhow = "1.0"
dygma_focus = "0.3"
eframe = { version = "0.24", default-features = false, features = [
dygma_focus = { version = "0.4", default-features = false, features = ["is_sync"] }
eframe = { version = "0.26", default-features = false, features = [
"default_fonts",
"wgpu",
"persistence",
Expand Down
6 changes: 3 additions & 3 deletions dygma-layer-switcher/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ impl DygmaLayerSwitcher {
.on_hover_text(verbiage::SETTING_PORT_REFRESH_HINT)
.clicked()
{
let keyboard = Keyboard::find_first_keyboard();
match keyboard {
let device = Focus::find_first_device();
match device {
Ok(port) => {
self.port = port.port;
self.port = port.serial_port;
self.configuration_changed = true;
}
Err(_) => warn!("{}", verbiage::ERROR_NO_KEYBOARD),
Expand Down
10 changes: 5 additions & 5 deletions dygma-layer-switcher/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ pub struct DygmaLayerSwitcher {

impl Default for DygmaLayerSwitcher {
fn default() -> Self {
let port = Keyboard::find_first_keyboard().unwrap_or_else(|_| {
let device = Focus::find_first_device().unwrap_or_else(|_| {
error!("{}", verbiage::ERROR_NO_KEYBOARD);
Keyboard {
name: verbiage::ERROR_NO_KEYBOARD,
port: verbiage::ERROR_NO_KEYBOARD.to_string(),
Device {
hardware: types::hardware_virtual::DEFY_WIRELESS_VIRTUAL,
serial_port: verbiage::ERROR_NO_KEYBOARD.to_string(),
}
});

Self {
logging: false,
port: port.port,
port: device.serial_port,
base_layer: 1,
mappings: (0..MAX_LAYERS)
.map(|i| (i, Layer::new(i)))
Expand Down
8 changes: 4 additions & 4 deletions dygma-layer-switcher/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ pub unsafe fn app_details_from_window_handle(window_handle: HWND) -> AppDetails
///
/// WinAPI.
unsafe fn get_window(h_wnd: HWND) -> String {
let title_length = GetWindowTextLengthW(h_wnd) + 1;
let mut window: Vec<u16> = vec![0; title_length as usize];
let title_length = GetWindowTextLengthW(h_wnd);
let mut window: Vec<u16> = vec![0; title_length as usize + 1];
let _ = GetWindowTextW(h_wnd, window.as_mut_slice());
let window = String::from_utf16_lossy(&window[..title_length as usize - 1]);
let window = String::from_utf16_lossy(&window[..title_length as usize]);
trace!("Window: {:?}", window);

window
Expand All @@ -116,7 +116,7 @@ unsafe fn get_window(h_wnd: HWND) -> String {
unsafe fn get_process(window_handle: HWND) -> String {
let mut process_id: u32 = 0;

let thread_id = GetWindowThreadProcessId(window_handle, Some(&mut process_id as *mut u32));
let thread_id = GetWindowThreadProcessId(window_handle, Some(&mut process_id));

if thread_id == 0 {
error!("Failed to retrieve process ID");
Expand Down

0 comments on commit 63b1807

Please sign in to comment.