Skip to content

Commit

Permalink
removed relative mouse hack because SDL2 now works fine
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Apr 4, 2024
1 parent cda020b commit 1b29c0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
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

0 comments on commit 1b29c0d

Please sign in to comment.