From 1bddb80b5f168611c4e2cbeab716c967184f6da3 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 3 Apr 2018 14:20:33 +0200 Subject: [PATCH] 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 . --- README.md | 4 ++-- app/src/inputmanager.c | 23 ++++++----------------- app/src/main.c | 4 ++-- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fa55b92f..f4908c6d 100644 --- a/README.md +++ b/README.md @@ -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` | diff --git a/app/src/inputmanager.c b/app/src/inputmanager.c index 7704c9a5..e3f1433c 100644 --- a/app/src/inputmanager.c +++ b/app/src/inputmanager.c @@ -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; diff --git a/app/src/main.c b/app/src/main.c index 6b972772..4bad1f3b 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -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"