diff --git a/app/src/convert.c b/app/src/convert.c index 9d947cb348..bfd83ab8d3 100644 --- a/app/src/convert.c +++ b/app/src/convert.c @@ -86,6 +86,10 @@ static SDL_bool convert_keycode(SDL_Keycode from, enum android_keycode *to) { MAP(SDLK_LEFT, AKEYCODE_DPAD_LEFT); MAP(SDLK_DOWN, AKEYCODE_DPAD_DOWN); MAP(SDLK_UP, AKEYCODE_DPAD_UP); + MAP(SDLK_w, AKEYCODE_W); + MAP(SDLK_a, AKEYCODE_A); + MAP(SDLK_s, AKEYCODE_S); + MAP(SDLK_d, AKEYCODE_D); FAIL; } } diff --git a/app/src/inputmanager.c b/app/src/inputmanager.c index 9dd952648d..c82c23040a 100644 --- a/app/src/inputmanager.c +++ b/app/src/inputmanager.c @@ -127,18 +127,25 @@ static void clipboard_paste(struct controller *controller) { } } -void input_manager_process_text_input(struct input_manager *input_manager, +SDL_bool input_manager_process_text_input(struct input_manager *input_manager, const SDL_TextInputEvent *event) { struct control_event control_event; control_event.type = CONTROL_EVENT_TYPE_TEXT; control_event.text_event.text = SDL_strdup(event->text); + if (strcmp(control_event.text_event.text, "w") == 0 || + strcmp(control_event.text_event.text, "a") == 0 || + strcmp(control_event.text_event.text, "s") == 0 || + strcmp(control_event.text_event.text, "d") == 0) { + return SDL_FALSE; + } if (!control_event.text_event.text) { LOGW("Cannot strdup input text"); - return; + return SDL_TRUE; } if (!controller_push_event(input_manager->controller, &control_event)) { LOGW("Cannot send text event"); } + return SDL_TRUE; } void input_manager_process_key(struct input_manager *input_manager, diff --git a/app/src/inputmanager.h b/app/src/inputmanager.h index d7eaccbcf2..d223a72148 100644 --- a/app/src/inputmanager.h +++ b/app/src/inputmanager.h @@ -13,7 +13,7 @@ struct input_manager { struct screen *screen; }; -void input_manager_process_text_input(struct input_manager *input_manager, +SDL_bool input_manager_process_text_input(struct input_manager *input_manager, const SDL_TextInputEvent *event); void input_manager_process_key(struct input_manager *input_manager, const SDL_KeyboardEvent *event); diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 23de498447..a79ed14bef 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -88,8 +88,9 @@ static SDL_bool event_loop(void) { } break; case SDL_TEXTINPUT: - input_manager_process_text_input(&input_manager, &event.text); - break; + if (input_manager_process_text_input(&input_manager, &event.text)) { + break; + } case SDL_KEYDOWN: case SDL_KEYUP: input_manager_process_key(&input_manager, &event.key);