json is added
This commit is contained in:
parent
26b7341b40
commit
898f50ecec
|
@ -7,14 +7,11 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.117", optional = true }
|
||||
serde_derive = { version = "1.0.117", optional = true }
|
||||
serde_json = { version = "1.0", optional = true }
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
serde_derive = { version = "1.0.117" }
|
||||
serde_json = { version = "1.0" }
|
||||
once_cell = "1.5.2"
|
||||
|
||||
[features]
|
||||
with_serde = ["serde", "serde_derive", "serde_json"]
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3.9", features = ["winuser", "errhandlingapi"] }
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||
pub enum Key {
|
||||
Escape,
|
||||
Digit0,
|
||||
|
|
|
@ -5,13 +5,13 @@ pub use crate::windows::*;
|
|||
|
||||
use crate::keyboard::Key;
|
||||
use crate::mouse::Button;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::SystemTime;
|
||||
|
||||
pub mod keyboard;
|
||||
pub mod mouse;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum EventType {
|
||||
KeyPress(Key),
|
||||
KeyRelease(Key),
|
||||
|
@ -20,8 +20,7 @@ pub enum EventType {
|
|||
MouseMoveTo { x: f64, y: f64 },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Event {
|
||||
pub time: SystemTime,
|
||||
pub event_type: EventType,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub enum Button {
|
||||
Left,
|
||||
Middle,
|
||||
|
|
|
@ -8,6 +8,7 @@ use winapi::shared::minwindef::{DWORD, HINSTANCE, LPARAM, LRESULT, WPARAM};
|
|||
use winapi::shared::windef::{HHOOK__, HWND};
|
||||
use winapi::um::errhandlingapi::GetLastError;
|
||||
use winapi::um::winuser::{GetMessageW, SetWindowsHookExW, UnhookWindowsHookEx, MSG};
|
||||
|
||||
pub mod keyboard;
|
||||
pub mod mouse;
|
||||
|
||||
|
|
|
@ -226,6 +226,7 @@ impl Robot {
|
|||
event_type,
|
||||
time: SystemTime::now(),
|
||||
};
|
||||
|
||||
HOOK_CALLBACK(event);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user