diff --git a/src/wlserver.cpp b/src/wlserver.cpp index b3f9f31..38a3365 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -70,6 +70,8 @@ static LogScope wl_log("wlserver"); +extern bool env_to_bool(const char *env); + struct wlserver_t wlserver = { .touch_down_ids = {} }; @@ -2192,6 +2194,36 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time ) if ( eMode == gamescope::TouchClickModes::Passthrough ) { wlr_seat_touch_notify_motion( wlserver.wlr.seat, time, touch_id, tx, ty ); + + if ( !env_to_bool(getenv("GAMESCOPE_DISABLE_TOUCH_GESTURES")) ) { + bool start_gesture = false; + + // Round the x-coordinate to the nearest whole number + uint32_t roundedCursorX = static_cast(std::round(wlserver.mouse_surface_cursorx)); + // Grab 2% of the display to be used for the edge range + double edge_range = g_nOutputWidth * 0.02; + + // if the touch cursor x position is less or equal to the range then start the gesture for left to right + if (roundedCursorX <= edge_range) { + start_gesture = true; + } + // if the touch cursor x position is the output width minus the edge range value then we are doing right to left + if (roundedCursorX >= g_nOutputWidth - edge_range) { + start_gesture = true; + } + // when the gesture is started and we are moving to the end of the edge range open home + if (start_gesture && roundedCursorX >= 1 && roundedCursorX <= edge_range) { + wl_log.infof("Detected Home gesture"); + wlserver_open_steam_menu(false); + start_gesture = false; + } + // when the gesture is started and we are moving from the output width minus the edge range to the output width open QAM + if (start_gesture && roundedCursorX >= g_nOutputWidth - edge_range && roundedCursorX <= g_nOutputWidth ) { + wl_log.infof("Detected QAM gesture"); + wlserver_open_steam_menu(true); + start_gesture = false; + } + } } else if ( eMode == gamescope::TouchClickModes::Disabled ) {