Improve wayland settings
This commit is contained in:
parent
3737eed034
commit
cfadebc733
|
@ -15,7 +15,7 @@ use thiserror::Error;
|
|||
|
||||
use super::{
|
||||
ffi::{
|
||||
is_keyboard, xkb_key_direction, xkb_keycode_t, xkb_keymap_key_repeats, xkb_state,
|
||||
is_keyboard_or_mouse, xkb_key_direction, xkb_keycode_t, xkb_keymap_key_repeats, xkb_state,
|
||||
xkb_state_get_keymap, xkb_state_key_get_one_sym, xkb_state_key_get_utf8, xkb_state_new,
|
||||
xkb_state_unref, xkb_state_update_key, EV_KEY,
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ impl Device {
|
|||
.custom_flags(O_NONBLOCK | O_CLOEXEC | O_RDONLY)
|
||||
.open(&path)?;
|
||||
|
||||
if unsafe { is_keyboard(file.as_raw_fd()) == 0 } {
|
||||
if unsafe { is_keyboard_or_mouse(file.as_raw_fd()) == 0 } {
|
||||
return Err(DeviceError::InvalidDevice(path.to_string()).into());
|
||||
}
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ extern "C" {
|
|||
|
||||
#[link(name = "espansodetectevdev", kind = "static")]
|
||||
extern "C" {
|
||||
pub fn is_keyboard(fd: i32) -> i32;
|
||||
pub fn is_keyboard_or_mouse(fd: i32) -> i32;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ evdev_bit_is_set(const unsigned long *array, int bit)
|
|||
}
|
||||
|
||||
/* Some heuristics to see if the device is a keyboard. */
|
||||
int32_t is_keyboard(int fd)
|
||||
int32_t is_keyboard_or_mouse(int fd)
|
||||
{
|
||||
int i;
|
||||
unsigned long evbits[NLONGS(EV_CNT)] = {0};
|
||||
|
@ -76,9 +76,15 @@ int32_t is_keyboard(int fd)
|
|||
if (errno)
|
||||
return false;
|
||||
|
||||
// Test for keyboard keys
|
||||
for (i = KEY_RESERVED; i <= KEY_MIN_INTERESTING; i++)
|
||||
if (evdev_bit_is_set(keybits, i))
|
||||
return true;
|
||||
|
||||
// Test for mouse keys
|
||||
for (i = BTN_MOUSE; i <= BTN_TASK; i++)
|
||||
if (evdev_bit_is_set(keybits, i))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
|
@ -22,6 +22,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" int32_t is_keyboard(int fd);
|
||||
extern "C" int32_t is_keyboard_or_mouse(int fd);
|
||||
|
||||
#endif //ESPANSO_DETECT_EVDEV_H
|
|
@ -65,7 +65,11 @@ impl Default for InjectionOptions {
|
|||
} else if cfg!(target_os = "macos") {
|
||||
2
|
||||
} else if cfg!(target_os = "linux") {
|
||||
if cfg!(feature = "wayland") {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
} else {
|
||||
panic!("unsupported OS");
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user