Add shortcut to rotate screen
On Ctrl+r, disable auto-rotation (if enabled), set the screen rotation and re-enable auto-rotation (if it was enabled). Closes #11 <https://github.com/Genymobile/scrcpy/issues/11>
This commit is contained in:
@@ -78,6 +78,7 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
|
||||
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||
case CONTROL_MSG_TYPE_COLLAPSE_NOTIFICATION_PANEL:
|
||||
case CONTROL_MSG_TYPE_GET_CLIPBOARD:
|
||||
case CONTROL_MSG_TYPE_ROTATE_DEVICE:
|
||||
// no additional data
|
||||
return 1;
|
||||
default:
|
||||
|
||||
@@ -28,6 +28,7 @@ enum control_msg_type {
|
||||
CONTROL_MSG_TYPE_GET_CLIPBOARD,
|
||||
CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
||||
CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
||||
CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
||||
};
|
||||
|
||||
enum screen_power_mode {
|
||||
|
||||
@@ -211,6 +211,16 @@ clipboard_paste(struct controller *controller) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_device(struct controller *controller) {
|
||||
struct control_msg msg;
|
||||
msg.type = CONTROL_MSG_TYPE_ROTATE_DEVICE;
|
||||
|
||||
if (!controller_push_msg(controller, &msg)) {
|
||||
LOGW("Could not request device rotation");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
input_manager_process_text_input(struct input_manager *im,
|
||||
const SDL_TextInputEvent *event) {
|
||||
@@ -388,6 +398,11 @@ input_manager_process_key(struct input_manager *im,
|
||||
}
|
||||
}
|
||||
return;
|
||||
case SDLK_r:
|
||||
if (control && cmd && !shift && !repeat && down) {
|
||||
rotate_device(controller);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -175,6 +175,9 @@ static void usage(const char *arg0) {
|
||||
" " CTRL_OR_CMD "+o\n"
|
||||
" turn device screen off (keep mirroring)\n"
|
||||
"\n"
|
||||
" " CTRL_OR_CMD "+r\n"
|
||||
" rotate device screen\n"
|
||||
"\n"
|
||||
" " CTRL_OR_CMD "+n\n"
|
||||
" expand notification panel\n"
|
||||
"\n"
|
||||
|
||||
Reference in New Issue
Block a user