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

Add support for CTRL+S to send hardware "shake" to device #85

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

atrich
Copy link

@atrich atrich commented Mar 21, 2018

When developing for React Native, shaking the physical Android device is how you pull up the React Native debug menu, which is a very common task.

This catches the CTRL+S key combination and maps it to the "shake" keycode (keycode 82, AKEYCODE_MENU).

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thank you for the PR. 👍 Adding this shortcut is a good idea.

"Shake" seems very specific to React Native, so it seems to me that MENU is a better name. Could you rename it, please?

(Please edit your commits to apply the changes, using git rebase: this whole PR could fit in only 1 commit, since it is a single technical/functional change.)

Also, could you change its target from master to dev, please? The idea is that the "home page" of the project should always contain valid information for the current (latest) release.

README.md Outdated
@@ -258,6 +258,7 @@ To run without installing:
| click on `HOME` | `Ctrl`+`h` \| _Middle-click_ |
| click on `BACK` | `Ctrl`+`b` \| _Right-click²_ |
| click on `APP_SWITCH` | `Ctrl`+`m` |
| shake device | `Ctrl`+`s` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency:

click on MENU

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also shortcut descriptions for scrcpy --help in main.c. Could you also add one for MENU below APP_SWITCH like here?

@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2018

@atrich Do you want me to apply the requested changes for you?

@atrich atrich changed the base branch from master to dev March 22, 2018 23:00
@atrich
Copy link
Author

atrich commented Mar 22, 2018

@rom1v Sorry for the delay - I believe I have responded to the feedback, rebased, and am requesting a merge into dev now. Let me know if there's other feedback!

@rom1v rom1v merged commit 301c52b into Genymobile:dev Mar 23, 2018
rom1v added a commit that referenced this pull request Mar 23, 2018
The action sends AKEYCODE_MENU, so just name it "menu".

See <#85>.
rom1v added a commit that referenced this pull request Mar 23, 2018
Add support for CTRL+S to send hardware "shake" to device
@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2018

Thank you 👍

I also swapped the shortcuts to avoid confusion: 88ee6bc

@atrich atrich deleted the arich/addShake branch April 4, 2018 17:41
@ihwf
Copy link

ihwf commented Nov 26, 2019

Thank you 👍

I also swapped the shortcuts to avoid confusion: 88ee6bc

This can not work on my MacOS , short press ctrl+M trigger APP_SWITCH, the same as command+S, and long press ctrl+M well trigger shake device , I don't know why must be long press?

@rom1v
Copy link
Collaborator

rom1v commented Nov 26, 2019

short press ctrl+M trigger APP_SWITCH, the same as command+S, and long press ctrl+M well trigger shake device

Actually, Ctrl+m is for MENU, and Cmd+s is for APP_SWITCH:

scrcpy/app/src/main.c

Lines 157 to 161 in 8ec077c

" " CTRL_OR_CMD "+s\n"
" click on APP_SWITCH\n"
"\n"
" Ctrl+m\n"
" click on MENU\n"

case SDLK_s:
if (control && cmd && !shift && !repeat) {
action_app_switch(controller, action);
}
return;
case SDLK_m:
// Ctrl+m on all platform, since Cmd+m is already captured by
// the system on macOS to minimize the window
if (control && ctrl && !meta && !shift && !repeat) {
action_menu(controller, action);
}
return;

I don't really know what "shake device" is in practice, but for example in the VLC app, Ctrl+m opens the menu and Ctrl+s (Cmd+s on macOS) correctly move into the "app switch" mode.

Note that you can inject these events manually via adb:

adb shell input keyevent APP_SWITCH
adb shell input keyevent MENU

@ihwf
Copy link

ihwf commented Nov 26, 2019

short press ctrl+M trigger APP_SWITCH, the same as command+S, and long press ctrl+M well trigger shake device

Actually, Ctrl+m is for MENU, and Cmd+s is for APP_SWITCH:

scrcpy/app/src/main.c

Lines 157 to 161 in 8ec077c

" " CTRL_OR_CMD "+s\n"
" click on APP_SWITCH\n"
"\n"
" Ctrl+m\n"
" click on MENU\n"

case SDLK_s:
if (control && cmd && !shift && !repeat) {
action_app_switch(controller, action);
}
return;
case SDLK_m:
// Ctrl+m on all platform, since Cmd+m is already captured by
// the system on macOS to minimize the window
if (control && ctrl && !meta && !shift && !repeat) {
action_menu(controller, action);
}
return;

I don't know what "shake device" is, but for example in the VLC app, Ctrl+m opens the menu and Ctrl+s (Cmd+s on macOS) correctly move into the "app switch" mode.

Note that you can inject these events manually via adb:

adb shell input keyevent APP_SWITCH
adb shell input keyevent MENU

I mean short press Ctrl +m handle "app switch" on my MacOS, it's wrong, I want to opens the menu, and when I long press Ctrl +m , it can opens the menu, I don't know why long press is right

@rom1v
Copy link
Collaborator

rom1v commented Nov 26, 2019

I mean short press Ctrl +m handle "app switch" on my MacOS

I don't know how it's even possible, looking at the source code. 😕

What is the result of scrcpy -v?

@ihwf
Copy link

ihwf commented Nov 27, 2019

I don't know how it's even possible, looking at the source code. 😕

What is the result of scrcpy -v?

scrcpy 1.11

dependencies:
- SDL 2.0.10
- libavcodec 58.54.100
- libavformat 58.29.100
- libavutil 56.31.100

It's a strange problem, maybe it's not a general problem, have you test on MacOS ?

@r4dixx
Copy link

r4dixx commented Nov 28, 2019

This can not work on my MacOS , short press ctrl+M trigger APP_SWITCH, the same as command+S, and long press ctrl+M well trigger shake device , I don't know why must be long press?

@ihwf Haven't tested this feature, but ctrl + m and cmd + s work as expected here. Maybe you have some keyboard conflicts linked to custom keybindings and/or locale settings? Just a supposition.

scrcpy 1.11

dependencies:
- SDL 2.0.10
- libavcodec 58.54.100
- libavformat 58.29.100
- libavutil 56.31.100

Darwin parprpmc008675a 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64

ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G1012

@scarlac scarlac mentioned this pull request Aug 5, 2021
1 task
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

Successfully merging this pull request may close these issues.

None yet

5 participants