Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github_28344065
scrcpy
提交
e2ac9961
S
scrcpy
项目概览
github_28344065
/
scrcpy
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scrcpy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e2ac9961
编写于
7月 31, 2019
作者:
R
Romain Vimont
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Cmd instead of Ctrl on macOS when possible
Fixes <
https://github.com/Genymobile/scrcpy/issues/642
>
上级
5e4ccfd8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
60 deletion
+72
-60
README.md
README.md
+20
-20
app/src/input_manager.c
app/src/input_manager.c
+31
-24
app/src/main.c
app/src/main.c
+21
-16
未找到文件。
README.md
浏览文件 @
e2ac9961
...
...
@@ -315,26 +315,26 @@ Also see [issue #14].
## Shortcuts
| Action | Shortcut |
| -------------------------------------- |:----------------------------
|
| Switch fullscreen mode |
`Ctrl`
+
`f`
|
| Resize window to 1:1 (pixel-perfect) |
`Ctrl`
+
`g`
|
| Resize window to remove black borders |
`Ctrl`
+
`x`
\|
_Double-click¹_ |
| Click on
`HOME`
|
`Ctrl`
+
`h`
\|
_Middle-click_ |
| Click on
`BACK`
|
`Ctrl`
+
`b`
\|
_Right-click²_ |
| Click on
`APP_SWITCH`
|
`Ctrl`
+
`s`
|
| Click on
`MENU`
|
`Ctrl`
+
`m`
|
| Click on
`VOLUME_UP`
|
`Ctrl`
+
`↑`
_(up)_
(
`Cmd`
+
`↑`
on macOS) |
| Click on
`VOLUME_DOWN`
|
`Ctrl`
+
`↓`
_(down)_
(
`Cmd`
+
`↓`
on macOS) |
| Click on
`POWER`
|
`Ctrl`
+
`p`
|
| Power on | _Right-click²_ |
| Turn device screen off (keep mirroring)|
`Ctrl`
+
`o`
|
| Expand notification panel |
`Ctrl`
+
`n`
|
| Collapse notification panel |
`Ctrl`
+
`Shift`
+
`n`
|
| Copy device clipboard to computer |
`Ctrl`
+
`c`
|
| Paste computer clipboard to device |
`Ctrl`
+
`v`
|
| Copy computer clipboard to device |
`Ctrl`
+
`Shift`
+
`v`
|
| Enable/disable FPS counter (on stdout) |
`Ctrl`
+
`i`
|
| Action | Shortcut |
Shortcut (macOS)
| -------------------------------------- |:----------------------------
- |:-----------------------------
| Switch fullscreen mode |
`Ctrl`
+
`f`
|
`Cmd`
+
`f`
| Resize window to 1:1 (pixel-perfect) |
`Ctrl`
+
`g`
|
`Cmd`
+
`g`
| Resize window to remove black borders |
`Ctrl`
+
`x`
\|
_Double-click¹_ |
`Cmd`
+
`x`
\|
_Double-click¹_
| Click on
`HOME`
|
`Ctrl`
+
`h`
\|
_Middle-click_ |
`Ctrl`
+
`h`
\|
_Middle-click_
| Click on
`BACK`
|
`Ctrl`
+
`b`
\|
_Right-click²_ |
`Cmd`
+
`b`
\|
_Right-click²_
| Click on
`APP_SWITCH`
|
`Ctrl`
+
`s`
|
`Cmd`
+
`s`
| Click on
`MENU`
|
`Ctrl`
+
`m`
|
`Ctrl`
+
`m`
| Click on
`VOLUME_UP`
|
`Ctrl`
+
`↑`
_(up)_
|
`Cmd`
+
`↑`
_(up)_
| Click on
`VOLUME_DOWN`
|
`Ctrl`
+
`↓`
_(down)_
|
`Cmd`
+
`↓`
_(down)_
| Click on
`POWER`
|
`Ctrl`
+
`p`
|
`Cmd`
+
`p`
| Power on | _Right-click²_ |
_Right-click²_
| Turn device screen off (keep mirroring)|
`Ctrl`
+
`o`
|
`Cmd`
+
`o`
| Expand notification panel |
`Ctrl`
+
`n`
|
`Cmd`
+
`n`
| Collapse notification panel |
`Ctrl`
+
`Shift`
+
`n`
|
`Cmd`
+
`Shift`
+
`n`
| Copy device clipboard to computer |
`Ctrl`
+
`c`
|
`Cmd`
+
`c`
| Paste computer clipboard to device |
`Ctrl`
+
`v`
|
`Cmd`
+
`v`
| Copy computer clipboard to device |
`Ctrl`
+
`Shift`
+
`v`
|
`Cmd`
+
`Shift`
+
`v`
| Enable/disable FPS counter (on stdout) |
`Ctrl`
+
`i`
|
`Cmd`
+
`i`
_¹Double-click on black borders to remove them._
_²Right-click turns the screen on if it was off, presses BACK otherwise._
...
...
app/src/input_manager.c
浏览文件 @
e2ac9961
...
...
@@ -242,16 +242,27 @@ input_manager_process_key(struct input_manager *input_manager,
bool
alt
=
event
->
keysym
.
mod
&
(
KMOD_LALT
|
KMOD_RALT
);
bool
meta
=
event
->
keysym
.
mod
&
(
KMOD_LGUI
|
KMOD_RGUI
);
// use Cmd on macOS, Ctrl on other platforms
#ifdef __APPLE__
bool
cmd
=
!
ctrl
&&
meta
;
#else
if
(
meta
)
{
// no shortcuts involve Meta on platforms other than macOS, and it must
// not be forwarded to the device
return
;
}
bool
cmd
=
ctrl
;
// && !meta, already guaranteed
#endif
if
(
alt
)
{
// no shortcut involves Alt or Meta, and they should not be forwarded
// to the device
// no shortcuts involve Alt, and it must not be forwarded to the device
return
;
}
struct
controller
*
controller
=
input_manager
->
controller
;
// capture all Ctrl events
if
(
ctrl
|
meta
)
{
if
(
ctrl
|
|
cmd
)
{
SDL_Keycode
keycode
=
event
->
keysym
.
sym
;
bool
down
=
event
->
type
==
SDL_KEYDOWN
;
int
action
=
down
?
ACTION_DOWN
:
ACTION_UP
;
...
...
@@ -259,63 +270,59 @@ input_manager_process_key(struct input_manager *input_manager,
bool
shift
=
event
->
keysym
.
mod
&
(
KMOD_LSHIFT
|
KMOD_RSHIFT
);
switch
(
keycode
)
{
case
SDLK_h
:
// Ctrl+h on all platform, since Cmd+h is already captured by
// the system on macOS to hide the window
if
(
control
&&
ctrl
&&
!
meta
&&
!
shift
&&
!
repeat
)
{
action_home
(
controller
,
action
);
}
return
;
case
SDLK_b
:
// fall-through
case
SDLK_BACKSPACE
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
shift
&&
!
repeat
)
{
if
(
control
&&
c
md
&&
!
shift
&&
!
repeat
)
{
action_back
(
controller
,
action
);
}
return
;
case
SDLK_s
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
shift
&&
!
repeat
)
{
if
(
control
&&
c
md
&&
!
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
;
case
SDLK_p
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
shift
&&
!
repeat
)
{
if
(
control
&&
c
md
&&
!
shift
&&
!
repeat
)
{
action_power
(
controller
,
action
);
}
return
;
case
SDLK_o
:
if
(
control
&&
c
trl
&&
!
shift
&&
!
meta
&&
down
)
{
if
(
control
&&
c
md
&&
!
shift
&&
down
)
{
set_screen_power_mode
(
controller
,
SCREEN_POWER_MODE_OFF
);
}
return
;
case
SDLK_DOWN
:
#ifdef __APPLE__
if
(
control
&&
!
ctrl
&&
meta
&&
!
shift
)
{
#else
if
(
control
&&
ctrl
&&
!
meta
&&
!
shift
)
{
#endif
if
(
control
&&
cmd
&&
!
shift
)
{
// forward repeated events
action_volume_down
(
controller
,
action
);
}
return
;
case
SDLK_UP
:
#ifdef __APPLE__
if
(
control
&&
!
ctrl
&&
meta
&&
!
shift
)
{
#else
if
(
control
&&
ctrl
&&
!
meta
&&
!
shift
)
{
#endif
if
(
control
&&
cmd
&&
!
shift
)
{
// forward repeated events
action_volume_up
(
controller
,
action
);
}
return
;
case
SDLK_c
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
shift
&&
!
repeat
&&
down
)
{
if
(
control
&&
c
md
&&
!
shift
&&
!
repeat
&&
down
)
{
request_device_clipboard
(
controller
);
}
return
;
case
SDLK_v
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
repeat
&&
down
)
{
if
(
control
&&
c
md
&&
!
repeat
&&
down
)
{
if
(
shift
)
{
// store the text in the device clipboard
set_device_clipboard
(
controller
);
...
...
@@ -326,29 +333,29 @@ input_manager_process_key(struct input_manager *input_manager,
}
return
;
case
SDLK_f
:
if
(
ctrl
&&
!
meta
&&
!
shift
&&
!
repeat
&&
down
)
{
if
(
!
shift
&&
cmd
&&
!
repeat
&&
down
)
{
screen_switch_fullscreen
(
input_manager
->
screen
);
}
return
;
case
SDLK_x
:
if
(
ctrl
&&
!
meta
&&
!
shift
&&
!
repeat
&&
down
)
{
if
(
!
shift
&&
cmd
&&
!
repeat
&&
down
)
{
screen_resize_to_fit
(
input_manager
->
screen
);
}
return
;
case
SDLK_g
:
if
(
ctrl
&&
!
meta
&&
!
shift
&&
!
repeat
&&
down
)
{
if
(
!
shift
&&
cmd
&&
!
repeat
&&
down
)
{
screen_resize_to_pixel_perfect
(
input_manager
->
screen
);
}
return
;
case
SDLK_i
:
if
(
ctrl
&&
!
meta
&&
!
shift
&&
!
repeat
&&
down
)
{
if
(
!
shift
&&
cmd
&&
!
repeat
&&
down
)
{
struct
fps_counter
*
fps_counter
=
input_manager
->
video_buffer
->
fps_counter
;
switch_fps_counter_state
(
fps_counter
);
}
return
;
case
SDLK_n
:
if
(
control
&&
c
trl
&&
!
meta
&&
!
repeat
&&
down
)
{
if
(
control
&&
c
md
&&
!
repeat
&&
down
)
{
if
(
shift
)
{
collapse_notification_panel
(
controller
);
}
else
{
...
...
app/src/main.c
浏览文件 @
e2ac9961
...
...
@@ -35,6 +35,11 @@ struct args {
};
static
void
usage
(
const
char
*
arg0
)
{
#ifdef __APPLE__
# define CTRL_OR_CMD "Cmd"
#else
# define CTRL_OR_CMD "Ctrl"
#endif
fprintf
(
stderr
,
"Usage: %s [options]
\n
"
"
\n
"
...
...
@@ -115,13 +120,13 @@ static void usage(const char *arg0) {
"
\n
"
"Shortcuts:
\n
"
"
\n
"
"
Ctrl
+f
\n
"
"
"
CTRL_OR_CMD
"
+f
\n
"
" switch fullscreen mode
\n
"
"
\n
"
"
Ctrl
+g
\n
"
"
"
CTRL_OR_CMD
"
+g
\n
"
" resize window to 1:1 (pixel-perfect)
\n
"
"
\n
"
"
Ctrl
+x
\n
"
"
"
CTRL_OR_CMD
"
+x
\n
"
" Double-click on black borders
\n
"
" resize window to remove black borders
\n
"
"
\n
"
...
...
@@ -129,48 +134,48 @@ static void usage(const char *arg0) {
" Middle-click
\n
"
" click on HOME
\n
"
"
\n
"
"
Ctrl
+b
\n
"
"
Ctrl
+Backspace
\n
"
"
"
CTRL_OR_CMD
"
+b
\n
"
"
"
CTRL_OR_CMD
"
+Backspace
\n
"
" Right-click (when screen is on)
\n
"
" click on BACK
\n
"
"
\n
"
"
Ctrl
+s
\n
"
"
"
CTRL_OR_CMD
"
+s
\n
"
" click on APP_SWITCH
\n
"
"
\n
"
" Ctrl+m
\n
"
" click on MENU
\n
"
"
\n
"
"
Ctrl
+Up
\n
"
"
"
CTRL_OR_CMD
"
+Up
\n
"
" click on VOLUME_UP
\n
"
"
\n
"
"
Ctrl
+Down
\n
"
"
"
CTRL_OR_CMD
"
+Down
\n
"
" click on VOLUME_DOWN
\n
"
"
\n
"
"
Ctrl
+p
\n
"
"
"
CTRL_OR_CMD
"
+p
\n
"
" click on POWER (turn screen on/off)
\n
"
"
\n
"
" Right-click (when screen is off)
\n
"
" power on
\n
"
"
\n
"
"
Ctrl
+o
\n
"
"
"
CTRL_OR_CMD
"
+o
\n
"
" turn device screen off (keep mirroring)
\n
"
"
\n
"
"
Ctrl
+n
\n
"
"
"
CTRL_OR_CMD
"
+n
\n
"
" expand notification panel
\n
"
"
\n
"
"
Ctrl
+Shift+n
\n
"
"
"
CTRL_OR_CMD
"
+Shift+n
\n
"
" collapse notification panel
\n
"
"
\n
"
"
Ctrl
+c
\n
"
"
"
CTRL_OR_CMD
"
+c
\n
"
" copy device clipboard to computer
\n
"
"
\n
"
"
Ctrl
+v
\n
"
"
"
CTRL_OR_CMD
"
+v
\n
"
" paste computer clipboard to device
\n
"
"
\n
"
"
Ctrl
+Shift+v
\n
"
"
"
CTRL_OR_CMD
"
+Shift+v
\n
"
" copy computer clipboard to device
\n
"
"
\n
"
"
Ctrl
+i
\n
"
"
"
CTRL_OR_CMD
"
+i
\n
"
" enable/disable FPS counter (print frames/second in logs)
\n
"
"
\n
"
" Drag & drop APK file
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录