Closed elig0n closed 3 years ago
Any change to fix this?
Probably not. Only ASCII and some accented characters work.
Except if someone finds a technical solution ;)
I used to have the same issue but it disappeared through some "practice":
1234
(that works fine).shift
key several times. (You may say a bunch of letters "crowding in".One possible technical solution is to write a customized input method manager. Vysor(an scrcpy alternative) does this. The input method manager can be installed and enabled by adb, without user interaction.
+1 on this. Wanted to write in Hebrew too, but failed. Are you sure it's impossible to use adb to pass unicode keys ?
@rom1v One of the possible options could be to create a custom keyboard, like NULL keyboard
that I described here: https://github.com/Genymobile/scrcpy/issues/181, but with an ability to Input and Copy/Paste unicode. Probably not the easiest option, but at least something if there's no system API for such things.
AFAIK, KDEConnect
installs own keyboard.
I would prefer without this workaround...
I strongly hope this will be fixed soon
https://remoboard.app/ example of this app may be help. pass unicode via an wireless server independent from adb server.
@livin2 This means I have to change my default keyboard, which means I might have less features than what I want to have. If an app is required, I would even install one that requires root, but having less features and having to switch keyboards as an alternative... This is just a hassle...
Is there maybe a way to do it using "monkeyrunner "? Someone wrote about this here: https://stackoverflow.com/a/20615725/878126
If an app is required, I would even install one that requires root, but having less features and having to switch keyboards as an alternative... This is just a hassle...
feature like emoji mostly depend on the ime of computer.
and you can switch keyboards with adb shell in the script where you start scrcpy:
adb shell ime list -s
adb shell ime set 【IME NAME】
adb connect 【xxx】
scrcpy -s 【xxx】
Yes, still a hassle. Once I disconnect from USB, I have to switch back to the keyboard I use. Besides, all this time that I use Scrcpy I won't have any of the features of the keyboard that I use.
Refer to the Vysor method, add a custom ime to enter unicode characters
I guess it may not be that easy and other apps may implement it successfully.
hope can input and copy/paste unicode characters via scrcpy window directly.
hope can input and copy/paste unicode characters via scrcpy window directly.
Yes, this works. https://github.com/Genymobile/scrcpy#copy-paste
I mean 'unicode directly'.
what about putting the key event to the IME if don't implement something new?
I think if users are playing mobile game using scrcpy, they must need type texts sometimes. if the users are trying to type/paste chinese or japanese then scrcpy is unable to cover that needs. and I don't think scrcpy need other big features except this one.
I don't think scrcpy need other big features except this one.
and #14 :wink:
oh, I'm just reading it while you reply. the audio seems a bigger feature and some hard and a little important than current one. but when waking up the phone(cpu855) using scrcpy, I feel it recover from lag in the first seconds(on windows). I guess there could be problems if there's audio playing in the background.
Could copy-paste work method work for non-English? I tried now using it, but it didn't paste. It did succeed to copy it to the clipboard of the device though. Is there maybe an Android-supported key for pasting ? If so, maybe this could be a workaround for typing...
When you Ctrl+Shift+v in the scrcpy window, the computer clipboard is copied to the device clipboard (exactly, without problems with special characters).
You can then long-press in any text area on your fevice and click in Copy.
@rom1v I know. That's why I wrote "It did succeed to copy it to the clipboard of the device though.". My question was if it's possible to do a real pasting, perhaps using some workaround of paste via a key.
Please test #1426 (works on Android >= 7).
any workarounds found?
@npes87184 So this is by using a new keyboard app on the device, that has to be set as default, right?
@npes87184 To keep things simple on the client side, I think we could do the following:
--use-ime
(for example), then the scrcpy-server installs itself (programatically, it has shell permissions) asynchronously (if the same version is not already installed), without delaying video stream and control (except text events, which could be queued or ignored)Tht way, the client always communicate to scrcpy-server only, which manages everything. And this doesn't delay scrcpy starting (except for text).
What do you think?
@npes87184 So this is by using a new keyboard app on the device, that has to be set as default, right?
In this POC, yes.
@npes87184 To keep things simple on the client side, I think we could do the following:
- put the IME service class in scrcpy-server
- if the user pass
--use-ime
(for example), then the scrcpy-server installs itself (programatically, it has shell permissions) asynchronously (if the same version is not already installed), without delaying video stream and control (except text events, which could be queued or ignored)- it then enables the IME and connects to it
- once connected, all text events received by scrcpy-server are now forwarded to the IME
- on cleanup, scrcpy-server restore the previous IME
Tht way, the client always communicate to scrcpy-server only, which manages everything. And this doesn't delay scrcpy starting (except for text).
What do you think?
I would say that this method is pretty well. However, there is a problem about UI. How do we "make" an area to let user enter words.
However, there is a problem about UI. How do we "make" an area to let user enter words.
Oh, I've never used this kind of things. I don't really know how they work.
Isn't this area provided by the system, and give the resulting character as a "text event"?
Once we have the text event with UTF-8 content (typically for one "character", like for letters), we can inject it to the system using the IME without being limited to ASCII.
and what about the physical keyboard
? making user type on the device directly.
and what about adding a text control let user input texts and copy to the device by scrcpy in bachground when user type enter
.
both ways will be better than panful installing anything.
Is there perhaps a way to achieve unicode key support by using accessibilityService? Maybe using dispatchKey() or something? Seems to me like a better thing, instead of having to use new keyboard and reset it...
However, there is a problem about UI. How do we "make" an area to let user enter words.
Oh, I've never used this kind of things. I don't really know how they work.
Isn't this area provided by the system, and give the resulting character as a "text event"?
Once we have the text event with UTF-8 content (typically for one "character", like for letters), we can inject it to the system using the IME without being limited to ASCII.
Oh, you misunderstand my question. My question is how do we design an area in SDL so that user can type in that area and send it to IME.
@rom1v What's that?
当手机打开投屏时,系统会自动添加wfd-uhid-device的物理键盘 这让scrcpy的input keyevent可以被输入法监听到 这很神奇,但是我不知道如何在不开启投屏的时候启用这个wfd-uhid-device物理键盘 视频测试经过地址: https://raw.githubusercontent.com/vip-liutao/scrcpy/main/keyboard.mkv
当手机打开投屏时,系统会自动添加wfd-uhid-device的物理键盘 这让scrcpy的输入键事件可以被输入法监听到 这很神奇,但是我不知道如何在不开启投屏的时候启用这个wfd -uhid-device物理键盘 视频测试通过地址:https : //raw.githubusercontent.com/vip-liutao/scrcpy/main/keyboard.mkv
@rom1v
How do you enable "wfd-uhid-device" in practice?
Refs:
When I activate raw key events mode (by pressing Ctrl+K) then try to type using Arabic (101) keyboard layout, I get messages like these on command line and no Arabic letters are passed to my Android device:
[server] WARN: Could not inject char u+0643 [server] WARN: Could not inject char u+064a [server] WARN: Could not inject char u+0641
Wait, does it mean scrcpy now supports unicode?
I've probably just found a way to work around this. This can be added in newer builds with some --command-line-option to enable or disable. I am not a coding genius so let me explain in my bad English:
We create an invisible always-focused text field that tracks input. Its content always defaults to, say, >
. If any symbol was inserted or some text was pasted, device clipboard copies somewhere where it can be accessed easily, then everything after >
is put to device clipboard, then server KEYCODE_PASTEs clipboard into the phone, and then clipboard is set back to what we saved back there. If >
suddenly disappears (probably because it was wiped out by user who pressed Backspace), server sends KEYCODE_BACKSPACE. And all the function keys/arrows/etc are passed as it is right now if possible.
@gaussandhisgun Even without "invisible text field", I did this experiment earlier: https://github.com/Genymobile/scrcpy/pull/1426
wether there is a way , we could hack 'hard keyboard' mode for input unicode chars? @rom1v
Is there any progress on this?
EDIT: Code moved to repository: https://github.com/epilys/scrcpy-input.py I will leave the gist up to not screw up bookmarks etc.
Hello all, scrcpy was useless to me without unicode (greek) input so I made a small GUI app with python3 + tkinter using only standard library modules plus xclip
and xdotool
to copy the input text to system clipboard and paste it inside scrcpy with Alt-v
xclip
is used for setting the clipboardxdotool
to search for the scrcpy
window (set by window_name
argument) and perform the paste shortcutYou can easily modify it to modify how the clipboard is set and how the key input is simulated (I included an example with xte
in the comments)
Set up a macro to bring it up whenever you want unicode input using your favourite macro app.
usage: scrcpy-input.py [-h] [-m] [-nh] [-ns] window_name
This tool copies your input to system clipboard and then synchronises it with
android's clipboard and pastes it with Alt-v command. Obviously this will
overwrite your clipboard contents. Make sure you focus on the text input on
the scrcpy window before you attempt to paste.
positional arguments:
window_name window name to target
optional arguments:
-h, --help show this help message and exit
-m, --manual don't auto send on ctrl+Enter
-nh, --no-hide don't auto hide on send
-ns, --no-strip don't auto strip whitespace on send
https://gist.github.com/epilys/89148373fd2fb0d1d50c941eda3ec6db
Doesn't it "contaminate" the clipboard history of the device?
Isn't it better to have some accessibility app installed, and send adb commands to it, to put the character?
@AndroidDeveloperLB yes it does since it syncs the clipboards. There are probably better solutions, but I made this in 2 hours without any knowledge about android or scrcpy.
@epilys I see.
@rom1v If you want, I can create an accessibility app. I just don't know how to make it secure, so that only via add (and maybe of a specific PC) it will allow to post the keys. I don't want the app to be insecure, letting other apps be able to post things... I could perhaps offer some kind of password-like solution, so that if whoever triggers the posting of keys don't use the correct password, the app will stop working, telling the user that something weird happened...
Closed by #2632: a new option --hid-keyboard
allows to simulate a physical keyboard via USB.
Advantages:
Limitations:
@rom1v What's special on Linux&USB , that sadly it works only in this scenario? Also, have you tried the solution of an accessibility app?
Wait for Windows support.
@rom1v What's special on Linux&USB , that sadly it works only in this scenario? Also, have you tried the solution of an accessibility app?
libusb does not work on Windows for Android HID, at least for myself.
I have hebrew keyboard layout on both my computer and my android keyboard that is in use but it wouldn't let me pass the letters. Any chance to fix this?