Do not return status for event handling

It is never read. Simplify.
This commit is contained in:
Romain Vimont 2022-01-21 19:16:32 +01:00
parent 8e4e7d42f1
commit ebef027c4f
5 changed files with 21 additions and 24 deletions

View file

@ -834,45 +834,43 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
im->mp->ops->process_mouse_scroll(im->mp, &evt); im->mp->ops->process_mouse_scroll(im->mp, &evt);
} }
bool void
sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event) { sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event) {
switch (event->type) { switch (event->type) {
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
if (!im->control) { if (!im->control) {
return true; break;
} }
sc_input_manager_process_text_input(im, &event->text); sc_input_manager_process_text_input(im, &event->text);
return true; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
// some key events do not interact with the device, so process the // some key events do not interact with the device, so process the
// event even if control is disabled // event even if control is disabled
sc_input_manager_process_key(im, &event->key); sc_input_manager_process_key(im, &event->key);
return true; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
if (!im->control) { if (!im->control) {
break; break;
} }
sc_input_manager_process_mouse_motion(im, &event->motion); sc_input_manager_process_mouse_motion(im, &event->motion);
return true; break;
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
if (!im->control) { if (!im->control) {
break; break;
} }
sc_input_manager_process_mouse_wheel(im, &event->wheel); sc_input_manager_process_mouse_wheel(im, &event->wheel);
return true; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
// some mouse events do not interact with the device, so process // some mouse events do not interact with the device, so process
// the event even if control is disabled // the event even if control is disabled
sc_input_manager_process_mouse_button(im, &event->button); sc_input_manager_process_mouse_button(im, &event->button);
return true; break;
case SDL_FINGERMOTION: case SDL_FINGERMOTION:
case SDL_FINGERDOWN: case SDL_FINGERDOWN:
case SDL_FINGERUP: case SDL_FINGERUP:
sc_input_manager_process_touch(im, &event->tfinger); sc_input_manager_process_touch(im, &event->tfinger);
return true; break;
} }
return false;
} }

View file

@ -59,7 +59,7 @@ void
sc_input_manager_init(struct sc_input_manager *im, sc_input_manager_init(struct sc_input_manager *im,
const struct sc_input_manager_params *params); const struct sc_input_manager_params *params);
bool void
sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event); sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event);
#endif #endif

View file

@ -195,8 +195,7 @@ handle_event(struct scrcpy *s, const struct scrcpy_options *options,
} }
} }
bool consumed = sc_screen_handle_event(&s->screen, event); sc_screen_handle_event(&s->screen, event);
(void) consumed;
end: end:
return EVENT_RESULT_CONTINUE; return EVENT_RESULT_CONTINUE;

View file

@ -770,7 +770,7 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) {
return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI; return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI;
} }
bool void
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
switch (event->type) { switch (event->type) {
case EVENT_NEW_FRAME: { case EVENT_NEW_FRAME: {
@ -778,12 +778,12 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
if (!ok) { if (!ok) {
LOGW("Frame update failed\n"); LOGW("Frame update failed\n");
} }
return true; return;
} }
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (!screen->has_frame) { if (!screen->has_frame) {
// Do nothing // Do nothing
return true; return;
} }
switch (event->window.event) { switch (event->window.event) {
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
@ -814,14 +814,14 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
} }
break; break;
} }
return true; return;
case SDL_KEYDOWN: case SDL_KEYDOWN:
if (screen->im.mp->relative_mode) { if (screen->im.mp->relative_mode) {
SDL_Keycode key = event->key.keysym.sym; SDL_Keycode key = event->key.keysym.sym;
if (sc_screen_is_mouse_capture_key(key)) { if (sc_screen_is_mouse_capture_key(key)) {
if (!screen->mouse_capture_key_pressed) { if (!screen->mouse_capture_key_pressed) {
screen->mouse_capture_key_pressed = key; screen->mouse_capture_key_pressed = key;
return true; return;
} else { } else {
// Another mouse capture key has been pressed, cancel // Another mouse capture key has been pressed, cancel
// mouse (un)capture // mouse (un)capture
@ -841,7 +841,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
// A mouse capture key has been pressed then released: // A mouse capture key has been pressed then released:
// toggle the capture mouse mode // toggle the capture mouse mode
sc_screen_capture_mouse(screen, !screen->mouse_captured); sc_screen_capture_mouse(screen, !screen->mouse_captured);
return true; return;
} }
// Do not return, the event must be forwarded to the input // Do not return, the event must be forwarded to the input
// manager // manager
@ -853,7 +853,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
if (screen->im.mp->relative_mode && !screen->mouse_captured) { if (screen->im.mp->relative_mode && !screen->mouse_captured) {
// Do not forward to input manager, the mouse will be captured // Do not forward to input manager, the mouse will be captured
// on SDL_MOUSEBUTTONUP // on SDL_MOUSEBUTTONUP
return true; return;
} }
break; break;
case SDL_FINGERMOTION: case SDL_FINGERMOTION:
@ -862,17 +862,17 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
if (screen->im.mp->relative_mode) { if (screen->im.mp->relative_mode) {
// Touch events are not compatible with relative mode // Touch events are not compatible with relative mode
// (coordinates are not relative) // (coordinates are not relative)
return true; return;
} }
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
if (screen->im.mp->relative_mode && !screen->mouse_captured) { if (screen->im.mp->relative_mode && !screen->mouse_captured) {
sc_screen_capture_mouse(screen, true); sc_screen_capture_mouse(screen, true);
return true; return;
} }
} }
return sc_input_manager_handle_event(&screen->im, event); sc_input_manager_handle_event(&screen->im, event);
} }
struct sc_point struct sc_point

View file

@ -139,7 +139,7 @@ void
sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation); sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation);
// react to SDL events // react to SDL events
bool void
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event); sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event);
// convert point from window coordinates to frame coordinates // convert point from window coordinates to frame coordinates