Skip to content

Commit

Permalink
Fix internal display touchscreen orientation when it's forced
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow authored and honjow committed Apr 10, 2024
1 parent 95983d1 commit ef8d0b1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ namespace gamescope
virtual const char *GetName() const = 0;
virtual const char *GetMake() const = 0;
virtual const char *GetModel() const = 0;

virtual bool DisplayTypeInternal() const
{
return GetScreenType() == GAMESCOPE_SCREEN_TYPE_INTERNAL;
}
};

class INestedHints
Expand Down
4 changes: 2 additions & 2 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ namespace gamescope
return GAMESCOPE_SCREEN_TYPE_EXTERNAL;
}

bool GetDisplayTypeInternal()
bool DisplayTypeInternal() const override
{
return m_pConnector->connector_type == DRM_MODE_CONNECTOR_eDP ||
m_pConnector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
Expand Down Expand Up @@ -1950,7 +1950,7 @@ namespace gamescope
{
if ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_EXTERNAL &&
g_eGamescopePanelExternalOrientation != GAMESCOPE_PANEL_EXTERNAL_ORIENTATION_AUTO &&
this->GetDisplayTypeInternal() )
this->DisplayTypeInternal() )
{
switch ( g_eGamescopePanelExternalOrientation )
{
Expand Down
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ bool g_bForceRelativeMouse = false;

bool g_bGrabbed = false;

bool g_bExternalForced = false;

float g_mouseSensitivity = 1.0;

GamescopeUpscaleFilter g_upscaleFilter = GamescopeUpscaleFilter::LINEAR;
Expand Down Expand Up @@ -421,12 +423,16 @@ GamescopePanelExternalOrientation g_eGamescopePanelExternalOrientation = GAMESCO
static GamescopePanelExternalOrientation force_external_orientation(const char *str)
{
if (strcmp(str, "normal") == 0) {
g_bExternalForced = true;
return GAMESCOPE_PANEL_EXTERNAL_ORIENTATION_0;
} else if (strcmp(str, "right") == 0) {
g_bExternalForced = true;
return GAMESCOPE_PANEL_EXTERNAL_ORIENTATION_270;
} else if (strcmp(str, "left") == 0) {
g_bExternalForced = true;
return GAMESCOPE_PANEL_EXTERNAL_ORIENTATION_90;
} else if (strcmp(str, "upsidedown") == 0) {
g_bExternalForced = true;
return GAMESCOPE_PANEL_EXTERNAL_ORIENTATION_180;
} else {
fprintf( stderr, "gamescope: invalid value for --force-external-orientation\n" );
Expand Down
2 changes: 2 additions & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern bool g_bFullscreen;

extern bool g_bGrabbed;

extern bool g_bExternalForced;

extern float g_mouseSensitivity;
extern const char *g_sOutputName;

Expand Down
8 changes: 6 additions & 2 deletions src/wlserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2013,8 +2013,12 @@ static void apply_touchscreen_orientation(double *x, double *y )
double tx = 0;
double ty = 0;

// Use internal screen always for orientation purposes.
switch ( GetBackend()->GetConnector( gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL )->GetCurrentOrientation() )
auto orientation = GAMESCOPE_PANEL_ORIENTATION_AUTO;
if ( GetBackend() && GetBackend()->GetCurrentConnector( ) )
{
orientation = GetBackend()->GetCurrentConnector()->GetCurrentOrientation();
}
switch ( orientation )
{
default:
case GAMESCOPE_PANEL_ORIENTATION_AUTO:
Expand Down

0 comments on commit ef8d0b1

Please sign in to comment.