Change volume shortcuts

I could not make Ctrl+'+' and Ctrl+'-' work for every keyboard on every
platform.

Instead, use Ctrl+UP and Ctrl+DOWN (like in VLC) to change the volume.

Fixes <https://github.com/Genymobile/scrcpy/issues/103>.
This commit is contained in:
Romain Vimont 2018-04-03 14:20:33 +02:00
parent 71f50fb697
commit 1bddb80b5f
3 changed files with 10 additions and 21 deletions

View file

@ -273,8 +273,8 @@ To run without installing:
| click on `BACK` | `Ctrl`+`b` \| _Right-click²_ |
| click on `APP_SWITCH` | `Ctrl`+`s` |
| click on `MENU` | `Ctrl`+`m` |
| click on `VOLUME_UP` | `Ctrl`+`+` |
| click on `VOLUME_DOWN` | `Ctrl`+`-` |
| click on `VOLUME_UP` | `Ctrl`+`↑` _(up)_ |
| click on `VOLUME_DOWN` | `Ctrl`+`↓` _(down)_ |
| click on `POWER` | `Ctrl`+`p` |
| turn screen on | _Right-click²_ |
| paste computer clipboard to device | `Ctrl`+`v` |

View file

@ -29,11 +29,6 @@ static struct point get_mouse_point(struct screen *screen) {
};
}
static SDL_bool is_ctrl_down(void) {
const Uint8 *state = SDL_GetKeyboardState(NULL);
return state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL];
}
static void send_keycode(struct controller *controller, enum android_keycode keycode, const char *name) {
// send DOWN event
struct control_event control_event;
@ -128,18 +123,6 @@ static void clipboard_paste(struct controller *controller) {
void input_manager_process_text_input(struct input_manager *input_manager,
const SDL_TextInputEvent *event) {
if (is_ctrl_down()) {
switch (event->text[0]) {
case '+':
action_volume_up(input_manager->controller);
break;
case '-':
action_volume_down(input_manager->controller);
break;
}
return;
}
struct control_event control_event;
control_event.type = CONTROL_EVENT_TYPE_TEXT;
control_event.text_event.text = SDL_strdup(event->text);
@ -189,6 +172,12 @@ void input_manager_process_key(struct input_manager *input_manager,
case SDLK_p:
action_power(input_manager->controller);
return;
case SDLK_DOWN:
action_volume_down(input_manager->controller);
return;
case SDLK_UP:
action_volume_up(input_manager->controller);
return;
case SDLK_v:
clipboard_paste(input_manager->controller);
return;

View file

@ -81,10 +81,10 @@ static void usage(const char *arg0) {
" Ctrl+m\n"
" click on MENU\n"
"\n"
" Ctrl+'+'\n"
" Ctrl+Up\n"
" click on VOLUME_UP\n"
"\n"
" Ctrl+'-'\n"
" Ctrl+Down\n"
" click on VOLUME_DOWN\n"
"\n"
" Ctrl+p\n"