Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Relative Mouse Hack Because SDL2 Now Works Fine #404

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ if (TARGET_WEBOS)
set(FEATURE_INPUT_EVMOUSE ON)

target_compile_definitions(moonlight-lib PUBLIC TARGET_WEBOS OS_LINUX _GNU_SOURCE APPID="${WEBOS_APPINFO_ID}")
target_compile_definitions(moonlight-lib PUBLIC HAVE_RELATIVE_MOUSE_HACK)
target_compile_definitions(moonlight-lib PUBLIC GAMECONTROLLERDB_PLATFORM="webOS" GAMECONTROLLERDB_PLATFORM_USE="Linux")

target_include_directories(moonlight-lib SYSTEM PUBLIC ${PBNJSON_C_INCLUDE_DIRS} ${PMLOG_INCLUDE_DIRS}
Expand Down
23 changes: 3 additions & 20 deletions src/app/input/app_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void app_input_init(app_input_t *input, app_t *app) {
SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
input->max_num_gamepads = 4;
input->gamepads_count = 0;
for(int i = 0; i < input->max_num_gamepads; i++) {
for (int i = 0; i < input->max_num_gamepads; i++) {
input->gamepads[i].instance_id = -1;
input->gamepads[i].gs_id = -1;
}
Expand All @@ -41,29 +41,12 @@ void app_input_deinit(app_input_t *input) {
}

void app_set_mouse_grab(app_input_t *input, bool grab) {
#if HAVE_RELATIVE_MOUSE_HACK
if (grab && input->blank_cursor_surface->userdata != NULL) {
commons_log_debug("Input", "Set cursor to blank bitmap: %p", input->blank_cursor_surface->userdata);
SDL_SetCursor(input->blank_cursor_surface->userdata);
} else {
SDL_SetCursor(SDL_GetDefaultCursor());
}
#else
if (app_configuration->hardware_mouse) {
SDL_ShowCursor(grab ? SDL_FALSE : SDL_TRUE);
} else {
if (!app_configuration->hardware_mouse) {
SDL_SetRelativeMouseMode(grab && !app_configuration->absmouse ? SDL_TRUE : SDL_FALSE);
if (!grab) {
SDL_ShowCursor(SDL_TRUE);
}
}
#endif
SDL_ShowCursor(grab ? SDL_FALSE : SDL_TRUE);
}

bool app_get_mouse_relative() {
#if HAVE_RELATIVE_MOUSE_HACK
return !app_configuration->absmouse;
#else
return SDL_GetRelativeMouseMode() == SDL_TRUE;
#endif
}
13 changes: 1 addition & 12 deletions src/app/lvgl/input/lv_sdl_drv_pointer_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,12 @@ static void indev_pointer_read(lv_indev_drv_t *drv, lv_indev_data_t *data) {
indev_point_def(data);
return;
}
static bool warped = false;
if (e.type == SDL_MOUSEMOTION) {
if (!warped && app->session != NULL) {
if (app->session != NULL) {
session_handle_input_event(app->session, &e);
}
data->state = e.motion.state;
data->point = (lv_point_t) {.x = e.motion.x, .y = e.motion.y};
#if HAVE_RELATIVE_MOUSE_HACK
if (warped || e.motion.which == SDL_TOUCH_MOUSEID) {
warped = false;
} else if (app->session != NULL && session_accepting_input(app->session) && app_get_mouse_relative()) {
int w, h;
SDL_GetWindowSize(input->ui->window, &w, &h);
SDL_WarpMouseInWindow(input->ui->window, w / 2, h / 2);
warped = true;
}
#endif
} else {
if (app->session != NULL) {
session_handle_input_event(app->session, &e);
Expand Down