Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hope to support the following special ASCII character input, thank you! #2816

Closed
Helaer opened this issue Nov 22, 2021 · 15 comments
Closed

Hope to support the following special ASCII character input, thank you! #2816

Helaer opened this issue Nov 22, 2021 · 15 comments

Comments

@Helaer
Copy link

Helaer commented Nov 22, 2021

The following is the special ASCII character input supported by Qtscrcpy. I hope that scrcpy can also support the following special ASCII character input. I am not good at C language, so come to ask for help, thank you!

@@ -279,6 +279,7 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
        keyCode = AKEYCODE_0;
        break;
    case Qt::Key_1:
    case Qt::Key_Exclam:// !
        keyCode = AKEYCODE_1;
        break;
    case Qt::Key_2:
@@ -288,15 +289,19 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
        keyCode = AKEYCODE_3;
        break;
    case Qt::Key_4:
    case Qt::Key_Dollar://$
        keyCode = AKEYCODE_4;
        break;
    case Qt::Key_5:
    case Qt::Key_Percent:// %
        keyCode = AKEYCODE_5;
        break;
    case Qt::Key_6:
    case Qt::Key_AsciiCircum: //^
        keyCode = AKEYCODE_6;
        break;
    case Qt::Key_7:
    case Qt::Key_Ampersand: //&
        keyCode = AKEYCODE_7;
        break;
    case Qt::Key_8:
@@ -308,6 +313,67 @@ AndroidKeycode InputConvertNormal::convertKeyCode(int key, Qt::KeyboardModifiers
    case Qt::Key_Space:
        keyCode = AKEYCODE_SPACE;
        break;
    case Qt::Key_Comma://,
    case Qt::Key_Less://<
        keyCode = AKEYCODE_COMMA;
        break;
    case Qt::Key_Period://.
    case Qt::Key_Greater://>
        keyCode = AKEYCODE_PERIOD;
        break;
    case Qt::Key_Minus://-
    case Qt::Key_Underscore: //_
        keyCode = AKEYCODE_MINUS;
        break;
    case Qt::Key_Equal://=
        keyCode = AKEYCODE_EQUALS;
        break;
    case Qt::Key_BracketLeft://[
    case Qt::Key_BraceLeft: //{
        keyCode = AKEYCODE_LEFT_BRACKET;
        break;
    case Qt::Key_BracketRight://]
    case Qt::Key_BraceRight: //}
        keyCode = AKEYCODE_RIGHT_BRACKET;
        break;
    case Qt::Key_Backslash:// \ ????
    case Qt::Key_Bar: //|
        keyCode = AKEYCODE_BACKSLASH;
        break;
    case Qt::Key_Semicolon://;
    case Qt::Key_Colon: //:
        keyCode = AKEYCODE_SEMICOLON;
        break;
    case Qt::Key_Apostrophe://'
    case Qt::Key_QuoteDbl: //"
        keyCode = AKEYCODE_APOSTROPHE;
        break;
    case Qt::Key_Slash:// /
    case Qt::Key_Question://?
        keyCode = AKEYCODE_SLASH;
        break;
    case Qt::Key_At://@
        keyCode = AKEYCODE_AT;
        break;
    case Qt::Key_Plus://+
        keyCode = AKEYCODE_PLUS;
        break;
    case Qt::Key_QuoteLeft://`
    case Qt::Key_AsciiTilde://~
        keyCode = AKEYCODE_GRAVE;
        break;
    case Qt::Key_NumberSign: //#
        keyCode = AKEYCODE_POUND;
        break;
    case Qt::Key_ParenLeft: //(
        keyCode = AKEYCODE_NUMPAD_LEFT_PAREN;
        break;
    case Qt::Key_ParenRight: //)
        keyCode = AKEYCODE_NUMPAD_RIGHT_PAREN;
        break;
    case Qt::Key_Asterisk: //*
        keyCode = AKEYCODE_STAR;
        break;
    }
    return keyCode;
}
@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2021

These keys are handled as text events (see here). Their character differ depending on the charmap/language.

Why do you need them as key events?

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

这些键作为文本事件处理(请参阅此处)。他们的性格因魅力图/语言而异。

为什么需要它们作为关键事件?

These keys are handled as text events (see here). Their character differ depending on the charmap/language.

Why do you need them as key events?

In Chinese input, Chinese punctuation cannot be input normally. Qtscrcpy is optimized in this respect. It can input Chinese punctuation normally when inputting Chinese. This is very bad for me who often input text. I hope you can make some optimizations. Thank you!

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2021

Could you test this (very old) branch: rawkeyevents (#87 (comment))

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

你能测试这个(很老的)分支吗:rawkeyevents#87(评论)

I downloaded the 1.3 branch, but the -k option does not work.

image

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2021

There is no binary for this rawkeyevents branch. You have to build it manually.

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

Sorry, I don’t know how to build a binary file, can you help me build it, thank you!

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

你能测试这个(很老的)分支吗:(#87(评论)rawkeyevents

I just found a friend to help me compile, the test result is that the above special ASCII characters can be input, but this branch uses Ctrl+K to switch, this experience is not very good, I hope to add --raw-key-events Or -k option to start by default.
image

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

I hope the 1.12.1 version can add the --raw-key-events or -k function, so that the text input of scrcpy can be perfectly inputted with the mobile input method. If you can do this, it will be great!

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2021

Oh, the reason why scrcpy uses a mix of key events and text events is that key events depend on the physical device keyboard layout (so most of the time, it does not behave like expected).

But when an HID keyboard is enabled (or a real physical keyboard is plugged), the layout may be configured in Settings → System → Languages and input → Physical keyboard.

This option disappears from the settings as soon as the physical keyboard is disconnected, but its configuration remains for injecting key events! 🎉

So, definitely, I will re-implement this feature for a future release 👍

I would like to find a way to configure the physical keyboard layout event when the physical keyboard is not connected (programmatically or even manually).

@Helaer
Copy link
Author

Helaer commented Nov 22, 2021

@rom1v Can the --raw-key-events or -k option be added in the next version? I think this feature is what most people need, thank you!

@rom1v
Copy link
Collaborator

rom1v commented Nov 22, 2021

Probably something similar, yes.

If you find a way to configure the physical keyboard layout even when a physical keyboard (or HID) is not connected, that would be great 😉

@Helaer
Copy link
Author

Helaer commented Nov 24, 2021

@rom1v Hello, I have many friends who need this function, Can you add --raw-key-events to the next version? and I hope you can release the next version as soon as possible, Thank you.

@rom1v
Copy link
Collaborator

rom1v commented Nov 24, 2021

Can you add --raw-key-events to the next version?

I just answered in the previous comment: yes, I'll implement it.

I hope you can release the next version as soon as possible

Depends on my free time, I also have other things to implement before a new release.

@Helaer
Copy link
Author

Helaer commented Nov 24, 2021

Can you add --raw-key-events to the next version?

I just answered in the previous comment: yes, I'll implement it.

I hope you can release the next version as soon as possible

Depends on my free time, I also have other things to implement before a new release.

Okay, thank you for your contribution.

rom1v added a commit that referenced this issue Nov 26, 2021
This option allows to inject all input keys as key events, and ignore
text events.

Fixes #2816 <#2816>
@rom1v
Copy link
Collaborator

rom1v commented Nov 26, 2021

Oh, the reason why scrcpy uses a mix of key events and text events is that key events depend on the physical device keyboard layout (so most of the time, it does not behave like expected).

But when an HID keyboard is enabled (or a real physical keyboard is plugged), the layout may be configured in Settings → System → Languages and input → Physical keyboard.

This option disappears from the settings as soon as the physical keyboard is disconnected, but its configuration remains for injecting key events! 🎉

My test was incorrect, this is totally false. Physical keyboard layout configuration has no impact on raw key events.

Anyway, I implemented the option: #2831.

rom1v added a commit that referenced this issue Nov 28, 2021
This option allows to inject all input keys as key events, and ignore
text events.

Fixes #2816 <#2816>
@rom1v rom1v closed this as completed in bd56d81 Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants