fix: move send_enter to impl UinputInjector block
This commit is contained in:
parent
b40c615583
commit
eb7960cc77
1 changed files with 9 additions and 9 deletions
|
|
@ -24,6 +24,15 @@ unsafe impl Send for UinputInjector {}
|
||||||
unsafe impl Sync for UinputInjector {}
|
unsafe impl Sync for UinputInjector {}
|
||||||
|
|
||||||
impl UinputInjector {
|
impl UinputInjector {
|
||||||
|
fn send_enter(&self) {
|
||||||
|
self.send_uinput_event(EV_KEY, 28, 1);
|
||||||
|
self.send_uinput_event(0, 0, 0);
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(2));
|
||||||
|
self.send_uinput_event(EV_KEY, 28, 0);
|
||||||
|
self.send_uinput_event(0, 0, 0);
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(2));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(name: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
pub fn new(name: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||||
let file = OpenOptions::new()
|
let file = OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
|
|
@ -124,15 +133,6 @@ impl KeyInjector for UinputInjector {
|
||||||
InjectResult::Success
|
InjectResult::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_enter(&self) {
|
|
||||||
self.send_uinput_event(EV_KEY, 28, 1); // KEY_ENTER press
|
|
||||||
self.send_uinput_event(0, 0, 0);
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(2));
|
|
||||||
self.send_uinput_event(EV_KEY, 28, 0);
|
|
||||||
self.send_uinput_event(0, 0, 0);
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send_key_event(&self, keycode: u16, value: i32) -> InjectResult {
|
fn send_key_event(&self, keycode: u16, value: i32) -> InjectResult {
|
||||||
self.send_uinput_event(EV_KEY, keycode, value);
|
self.send_uinput_event(EV_KEY, keycode, value);
|
||||||
self.send_uinput_event(0, 0, 0);
|
self.send_uinput_event(0, 0, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue