Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ mod cli {
std::process::exit(0);
}

#[cfg(all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
))]
#[cfg(all(target_os = "windows", feature = "interception_driver"))]
if args.list {
main_lib::list_devices_windows();
std::process::exit(0);
Expand Down
6 changes: 1 addition & 5 deletions src/main_lib/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ kanata.kbd in the current working directory and
#[cfg(any(
target_os = "macos",
any(target_os = "linux", target_os = "android"),
all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
)
all(target_os = "windows", feature = "interception_driver")
))]
#[arg(short, long)]
pub list: bool,
Expand Down
24 changes: 4 additions & 20 deletions src/main_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,14 @@ pub(crate) fn list_devices_linux() {
println!(" )");
}

#[cfg(all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
))]
#[cfg(all(target_os = "windows", feature = "interception_driver"))]
struct WindowsDeviceInfo {
display_name: String, // For user display
raw_wide_bytes: Vec<u8>, // For kanata configuration (original wide string bytes)
hardware_id: Option<String>, // Parsed hardware ID (e.g., "HID#VID_046D&PID_C52B")
}

#[cfg(all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
))]
#[cfg(all(target_os = "windows", feature = "interception_driver"))]
fn get_device_info(device_handle: winapi::um::winnt::HANDLE) -> Option<WindowsDeviceInfo> {
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
Expand Down Expand Up @@ -197,11 +189,7 @@ fn get_device_info(device_handle: winapi::um::winnt::HANDLE) -> Option<WindowsDe
None
}

#[cfg(all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
))]
#[cfg(all(target_os = "windows", feature = "interception_driver"))]
pub(crate) fn list_devices_windows() {
use std::ptr::null_mut;
use winapi::shared::minwindef::{PUINT, UINT};
Expand Down Expand Up @@ -302,11 +290,7 @@ pub(crate) fn list_devices_windows() {
}
}

#[cfg(all(
target_os = "windows",
feature = "interception_driver",
not(feature = "gui")
))]
#[cfg(all(target_os = "windows", feature = "interception_driver"))]
fn extract_hardware_id(device_name: &str) -> Option<String> {
// Windows device names typically look like:
// \\?\HID#VID_046D&PID_C52B&MI_01#7&1234abcd&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
Expand Down
8 changes: 8 additions & 0 deletions src/main_lib/win_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ fn cli_init() -> Result<ValidatedArgs> {
}
};

#[cfg(feature = "interception_driver")]
{
if args.list {
super::list_devices_windows();
std::process::exit(0);
}
}

let cfg_paths = args.cfg.unwrap_or_else(default_cfg);

let log_lvl = match (args.debug, args.trace) {
Expand Down
Loading