Do not return status for event handling
It is never read. Simplify.
This commit is contained in:
parent
8e4e7d42f1
commit
ebef027c4f
5 changed files with 21 additions and 24 deletions
|
@ -834,45 +834,43 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
|
|||
im->mp->ops->process_mouse_scroll(im->mp, &evt);
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event) {
|
||||
switch (event->type) {
|
||||
case SDL_TEXTINPUT:
|
||||
if (!im->control) {
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
sc_input_manager_process_text_input(im, &event->text);
|
||||
return true;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
// some key events do not interact with the device, so process the
|
||||
// event even if control is disabled
|
||||
sc_input_manager_process_key(im, &event->key);
|
||||
return true;
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
if (!im->control) {
|
||||
break;
|
||||
}
|
||||
sc_input_manager_process_mouse_motion(im, &event->motion);
|
||||
return true;
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (!im->control) {
|
||||
break;
|
||||
}
|
||||
sc_input_manager_process_mouse_wheel(im, &event->wheel);
|
||||
return true;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
// some mouse events do not interact with the device, so process
|
||||
// the event even if control is disabled
|
||||
sc_input_manager_process_mouse_button(im, &event->button);
|
||||
return true;
|
||||
break;
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP:
|
||||
sc_input_manager_process_touch(im, &event->tfinger);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void
|
|||
sc_input_manager_init(struct sc_input_manager *im,
|
||||
const struct sc_input_manager_params *params);
|
||||
|
||||
bool
|
||||
void
|
||||
sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -195,8 +195,7 @@ handle_event(struct scrcpy *s, const struct scrcpy_options *options,
|
|||
}
|
||||
}
|
||||
|
||||
bool consumed = sc_screen_handle_event(&s->screen, event);
|
||||
(void) consumed;
|
||||
sc_screen_handle_event(&s->screen, event);
|
||||
|
||||
end:
|
||||
return EVENT_RESULT_CONTINUE;
|
||||
|
|
|
@ -770,7 +770,7 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) {
|
|||
return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI;
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
|
||||
switch (event->type) {
|
||||
case EVENT_NEW_FRAME: {
|
||||
|
@ -778,12 +778,12 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
|
|||
if (!ok) {
|
||||
LOGW("Frame update failed\n");
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
case SDL_WINDOWEVENT:
|
||||
if (!screen->has_frame) {
|
||||
// Do nothing
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
switch (event->window.event) {
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
|
@ -814,14 +814,14 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
case SDL_KEYDOWN:
|
||||
if (screen->im.mp->relative_mode) {
|
||||
SDL_Keycode key = event->key.keysym.sym;
|
||||
if (sc_screen_is_mouse_capture_key(key)) {
|
||||
if (!screen->mouse_capture_key_pressed) {
|
||||
screen->mouse_capture_key_pressed = key;
|
||||
return true;
|
||||
return;
|
||||
} else {
|
||||
// Another mouse capture key has been pressed, cancel
|
||||
// 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:
|
||||
// toggle the capture mouse mode
|
||||
sc_screen_capture_mouse(screen, !screen->mouse_captured);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
// Do not return, the event must be forwarded to the input
|
||||
// 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) {
|
||||
// Do not forward to input manager, the mouse will be captured
|
||||
// on SDL_MOUSEBUTTONUP
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERMOTION:
|
||||
|
@ -862,17 +862,17 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
|
|||
if (screen->im.mp->relative_mode) {
|
||||
// Touch events are not compatible with relative mode
|
||||
// (coordinates are not relative)
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (screen->im.mp->relative_mode && !screen->mouse_captured) {
|
||||
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
|
||||
|
|
|
@ -139,7 +139,7 @@ void
|
|||
sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation);
|
||||
|
||||
// react to SDL events
|
||||
bool
|
||||
void
|
||||
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event);
|
||||
|
||||
// convert point from window coordinates to frame coordinates
|
||||
|
|
Loading…
Reference in a new issue