Convert keycode to RdevKey
This commit is contained in:
parent
b38c3299d8
commit
ee19a03ecc
75
Cargo.lock
generated
75
Cargo.lock
generated
@ -627,21 +627,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cocoa"
|
|
||||||
version = "0.22.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "667fdc068627a2816b9ff831201dd9864249d6ee8d190b9532357f1fc0f61ea7"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"block",
|
|
||||||
"core-foundation 0.9.3",
|
|
||||||
"core-graphics 0.21.0",
|
|
||||||
"foreign-types",
|
|
||||||
"libc",
|
|
||||||
"objc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.24.0"
|
version = "0.24.0"
|
||||||
@ -759,18 +744,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "core-graphics"
|
|
||||||
version = "0.21.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "52a67c4378cf203eace8fb6567847eb641fd6ff933c1145a115c6ee820ebb978"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"core-foundation 0.9.3",
|
|
||||||
"foreign-types",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-graphics"
|
name = "core-graphics"
|
||||||
version = "0.22.3"
|
version = "0.22.3"
|
||||||
@ -1283,6 +1256,26 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enum-map"
|
||||||
|
version = "2.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f5a56d54c8dd9b3ad34752ed197a4eb2a6601bc010808eb097a04a58ae4c43e1"
|
||||||
|
dependencies = [
|
||||||
|
"enum-map-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enum-map-derive"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9045e2676cd5af83c3b167d917b0a5c90a4d8e266e2683d6631b235c457fc27"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enum_dispatch"
|
name = "enum_dispatch"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
@ -3741,15 +3734,17 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rdev"
|
name = "rdev"
|
||||||
version = "0.5.0"
|
version = "0.5.0-2"
|
||||||
source = "git+https://github.com/open-trade/rdev#fbbefd0b5d87095a7349965aec9ecd33de7035ac"
|
source = "git+https://github.com/asur4s/rdev#895c8fb1a6106714793e8877d35d2b7a1c57ce9c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa 0.22.0",
|
"cocoa",
|
||||||
"core-foundation 0.7.0",
|
"core-foundation 0.9.3",
|
||||||
"core-foundation-sys 0.7.0",
|
"core-foundation-sys 0.8.3",
|
||||||
"core-graphics 0.19.2",
|
"core-graphics 0.22.3",
|
||||||
|
"enum-map",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
|
"widestring 1.0.2",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
"x11",
|
"x11",
|
||||||
]
|
]
|
||||||
@ -3967,7 +3962,7 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"clap 3.1.18",
|
"clap 3.1.18",
|
||||||
"clipboard",
|
"clipboard",
|
||||||
"cocoa 0.24.0",
|
"cocoa",
|
||||||
"core-foundation 0.9.3",
|
"core-foundation 0.9.3",
|
||||||
"core-graphics 0.22.3",
|
"core-graphics 0.22.3",
|
||||||
"cpal",
|
"cpal",
|
||||||
@ -4939,7 +4934,7 @@ version = "0.7.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "76863575f7842ed64fda361f417a787efa82811b4617267709066969cd4ccf3b"
|
checksum = "76863575f7842ed64fda361f417a787efa82811b4617267709066969cd4ccf3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa 0.24.0",
|
"cocoa",
|
||||||
"core-graphics 0.22.3",
|
"core-graphics 0.22.3",
|
||||||
"gtk",
|
"gtk",
|
||||||
"libappindicator",
|
"libappindicator",
|
||||||
@ -5357,6 +5352,12 @@ version = "0.4.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
@ -5430,7 +5431,7 @@ checksum = "0c643e10139d127d30d6d753398c8a6f0a43532e8370f6c9d29ebbff29b984ab"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"err-derive",
|
"err-derive",
|
||||||
"widestring",
|
"widestring 0.4.3",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -5557,7 +5558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a"
|
checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cocoa 0.24.0",
|
"cocoa",
|
||||||
"core-foundation 0.9.3",
|
"core-foundation 0.9.3",
|
||||||
"core-graphics 0.22.3",
|
"core-graphics 0.22.3",
|
||||||
"core-video-sys",
|
"core-video-sys",
|
||||||
|
@ -74,7 +74,7 @@ sciter-rs = { git = "https://github.com/open-trade/rust-sciter", branch = "dyn"
|
|||||||
sys-locale = "0.2"
|
sys-locale = "0.2"
|
||||||
enigo = { path = "libs/enigo", features = [ "with_serde" ] }
|
enigo = { path = "libs/enigo", features = [ "with_serde" ] }
|
||||||
clipboard = { path = "libs/clipboard" }
|
clipboard = { path = "libs/clipboard" }
|
||||||
rdev = { git = "https://github.com/open-trade/rdev" }
|
rdev = { git = "https://github.com/asur4s/rdev" }
|
||||||
ctrlc = "3.2"
|
ctrlc = "3.2"
|
||||||
arboard = "2.0"
|
arboard = "2.0"
|
||||||
#minreq = { version = "2.4", features = ["punycode", "https-native"] }
|
#minreq = { version = "2.4", features = ["punycode", "https-native"] }
|
||||||
|
@ -234,22 +234,54 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
buildBody(context, ffiModel))));
|
buildBody(context, ffiModel))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getRawPointerAndKeyBody(Widget child) {
|
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
|
||||||
return Consumer<FfiModel>(
|
String? keyboardMode = Platform.environment['KEYBOARD_MODE'];
|
||||||
builder: (context, FfiModel, _child) => MouseRegion(
|
keyboardMode ??= 'legacy';
|
||||||
cursor: FfiModel.permissions['keyboard'] != false
|
|
||||||
? SystemMouseCursors.none
|
if (keyboardMode == 'map') {
|
||||||
: MouseCursor.defer,
|
mapKeyboardMode(e);
|
||||||
child: FocusScope(
|
} else if (keyboardMode == 'translate') {
|
||||||
autofocus: true,
|
legacyKeyboardMode(e);
|
||||||
child: Focus(
|
} else {
|
||||||
autofocus: true,
|
legacyKeyboardMode(e);
|
||||||
canRequestFocus: true,
|
}
|
||||||
focusNode: _physicalFocusNode,
|
|
||||||
onFocusChange: (bool v) {
|
return KeyEventResult.handled;
|
||||||
_imageFocused = v;
|
}
|
||||||
},
|
|
||||||
onKey: (data, e) {
|
void mapKeyboardMode(RawKeyEvent e) {
|
||||||
|
int scanCode;
|
||||||
|
int keyCode;
|
||||||
|
bool down;
|
||||||
|
|
||||||
|
if (e.data is RawKeyEventDataMacOs) {
|
||||||
|
RawKeyEventDataMacOs newData = e.data as RawKeyEventDataMacOs;
|
||||||
|
scanCode = newData.keyCode;
|
||||||
|
keyCode = newData.keyCode;
|
||||||
|
} else if (e.data is RawKeyEventDataWindows) {
|
||||||
|
RawKeyEventDataWindows newData = e.data as RawKeyEventDataWindows;
|
||||||
|
scanCode = newData.scanCode;
|
||||||
|
keyCode = newData.keyCode;
|
||||||
|
} else if (e.data is RawKeyEventDataLinux) {
|
||||||
|
RawKeyEventDataLinux newData = e.data as RawKeyEventDataLinux;
|
||||||
|
scanCode = newData.scanCode;
|
||||||
|
keyCode = newData.keyCode;
|
||||||
|
debugPrint(newData.unicodeScalarValues.toString());
|
||||||
|
} else {
|
||||||
|
scanCode = -1;
|
||||||
|
keyCode = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e is RawKeyDownEvent){
|
||||||
|
down = true;
|
||||||
|
}else{
|
||||||
|
down = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ffi.inputRawKey(keyCode, scanCode, down);
|
||||||
|
}
|
||||||
|
|
||||||
|
void legacyKeyboardMode(RawKeyEvent e) {
|
||||||
final key = e.logicalKey;
|
final key = e.logicalKey;
|
||||||
if (e is RawKeyDownEvent) {
|
if (e is RawKeyDownEvent) {
|
||||||
if (e.repeat) {
|
if (e.repeat) {
|
||||||
@ -283,8 +315,24 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
sendRawKey(e);
|
sendRawKey(e);
|
||||||
}
|
}
|
||||||
return KeyEventResult.handled;
|
}
|
||||||
|
|
||||||
|
Widget getRawPointerAndKeyBody(Widget child) {
|
||||||
|
return Consumer<FfiModel>(
|
||||||
|
builder: (context, FfiModel, _child) => MouseRegion(
|
||||||
|
cursor: FfiModel.permissions['keyboard'] != false
|
||||||
|
? SystemMouseCursors.none
|
||||||
|
: MouseCursor.defer,
|
||||||
|
child: FocusScope(
|
||||||
|
autofocus: true,
|
||||||
|
child: Focus(
|
||||||
|
autofocus: true,
|
||||||
|
canRequestFocus: true,
|
||||||
|
focusNode: _physicalFocusNode,
|
||||||
|
onFocusChange: (bool v) {
|
||||||
|
_imageFocused = v;
|
||||||
},
|
},
|
||||||
|
onKey: handleRawKeyEvent,
|
||||||
child: child))));
|
child: child))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,6 +980,12 @@ class FFI {
|
|||||||
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Raw Key
|
||||||
|
void inputRawKey(int keyCode, int scanCode, bool down){
|
||||||
|
debugPrint(scanCode.toString());
|
||||||
|
bind.sessionInputRawKey(id: id, keycode: keyCode, scancode: scanCode, down: down);
|
||||||
|
}
|
||||||
|
|
||||||
/// Send key stroke event.
|
/// Send key stroke event.
|
||||||
/// [down] indicates the key's state(down or up).
|
/// [down] indicates the key's state(down or up).
|
||||||
/// [press] indicates a click event(down and up).
|
/// [press] indicates a click event(down and up).
|
||||||
|
@ -1649,7 +1649,7 @@ pub enum Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Keycode for key events.
|
/// Keycode for key events.
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
ControlKey(ControlKey),
|
ControlKey(ControlKey),
|
||||||
Chr(u32),
|
Chr(u32),
|
||||||
|
@ -373,6 +373,16 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn input_raw_key(&self, keycode: i32, scancode: i32, down: bool){
|
||||||
|
use rdev::{EventType::*, Key as RdevKey, *};
|
||||||
|
if scancode < 0 || keycode < 0{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let key = rdev::key_from_scancode(scancode.try_into().unwrap()) as RdevKey;
|
||||||
|
|
||||||
|
log::info!("{:?}", key);
|
||||||
|
}
|
||||||
|
|
||||||
/// Input a string of text.
|
/// Input a string of text.
|
||||||
/// String is parsed into individual key presses.
|
/// String is parsed into individual key presses.
|
||||||
///
|
///
|
||||||
|
@ -208,6 +208,12 @@ pub fn session_switch_display(id: String, value: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn session_input_raw_key(id: String, keycode: i32, scancode:i32, down: bool){
|
||||||
|
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||||
|
session.input_raw_key(keycode, scancode, down);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn session_input_key(
|
pub fn session_input_key(
|
||||||
id: String,
|
id: String,
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::ipc::{self, new_listener, Connection, Data};
|
use crate::ipc::{self, new_listener, Connection, Data};
|
||||||
#[cfg(windows)]
|
#[cfg(target_os = "linux")]
|
||||||
use crate::ipc::{start_pa};
|
use crate::ipc::{start_pa};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use crate::ipc::start_clipboard_file;
|
use crate::ipc::start_clipboard_file;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user