Skip to content

Commit

Permalink
supports full touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Feb 28, 2024
1 parent b571453 commit 90a7d35
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
19 changes: 19 additions & 0 deletions app/backend/stream/stream_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ bool stream_input_handle_mouse_event(stream_manager_t *manager, const SDL_Event
if (!manager->app->settings->enable_input) {
return true;
}
if (event->motion.which == SDL_TOUCH_MOUSEID) {
return true;
}
switch (event->type) {
case SDL_MOUSEMOTION: {
if (input_manager_get_and_reset_mouse_movement(manager->app->input_manager)) {
Expand Down Expand Up @@ -102,4 +105,20 @@ bool stream_input_handle_mouse_event(stream_manager_t *manager, const SDL_Event
}
}
return false;
}

bool stream_input_handle_touch_event(stream_manager_t *manager, const SDL_TouchFingerEvent *event) {
if (!manager->app->settings->enable_input) {
return true;
}
if (event->type == SDL_FINGERDOWN) {
IHS_SessionSendTouchDown(manager->session, event->fingerId, event->x, event->y);
} else if (event->type == SDL_FINGERUP) {
IHS_SessionSendTouchUp(manager->session, event->fingerId, event->x, event->y);
} else if (event->type == SDL_FINGERMOTION) {
IHS_SessionSendTouchMotion(manager->session, event->fingerId, event->x, event->y);
} else {
return false;
}
return true;
}
2 changes: 2 additions & 0 deletions app/backend/stream/stream_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
bool stream_input_handle_key_event(stream_manager_t *manager, const SDL_KeyboardEvent *event);

bool stream_input_handle_mouse_event(stream_manager_t *manager, const SDL_Event *event);

bool stream_input_handle_touch_event(stream_manager_t *manager, const SDL_TouchFingerEvent *event);
6 changes: 6 additions & 0 deletions app/backend/stream/stream_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ void stream_manager_handle_event(stream_manager_t *manager, const SDL_Event *eve
stream_input_handle_mouse_event(manager, event);
break;
}
case SDL_FINGERDOWN:
case SDL_FINGERUP:
case SDL_FINGERMOTION: {
stream_input_handle_touch_event(manager, &event->tfinger);
break;
}
case SDL_CONTROLLERBUTTONDOWN: {
if (event->cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {
controller_back_pressed(manager);
Expand Down
2 changes: 1 addition & 1 deletion core
Submodule core updated 138 files
2 changes: 1 addition & 1 deletion third_party/commons

0 comments on commit 90a7d35

Please sign in to comment.