Skip to content

Commit

Permalink
main: Add --virtual-connector-strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Aug 22, 2024
1 parent 3a3f910 commit 953cd7f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
23 changes: 18 additions & 5 deletions src/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ namespace gamescope
{
enum VirtualConnectorStrategy : uint32_t
{
SingleApplication = 0x1,
SteamControlled = 0x2,
PerAppId = 0x4,
PerWindow = 0x8,
SingleApplication,
SteamControlled,
PerAppId,
PerWindow,

Count,
};
}
using VirtualConnectorStrategy = VirtualConnectorStrategies::VirtualConnectorStrategy;
using VirtualConnectorKey_t = uint64_t;
using VirtualConnectorKey_t = uint64_t;
extern ConVar<VirtualConnectorStrategy> cv_backend_virtual_connector_strategy;

static constexpr bool VirtualConnectorStrategyIsSingleOutput( VirtualConnectorStrategy eStrategy )
Expand All @@ -64,6 +64,19 @@ namespace gamescope
return VirtualConnectorInSteamPerAppState() && ulKey == 769;
}

static std::string_view VirtualConnectorStrategyToString( VirtualConnectorStrategy eStrategy )
{
switch ( eStrategy )
{
case VirtualConnectorStrategies::SingleApplication: return "SingleApplication";
case VirtualConnectorStrategies::SteamControlled: return "SteamControlled";
case VirtualConnectorStrategies::PerAppId: return "PerAppId";
case VirtualConnectorStrategies::PerWindow: return "PerWindow";
default:
return "Unknown";
}
}


namespace TouchClickModes
{
Expand Down
15 changes: 14 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const struct option *gamescope_options = (struct option[]){
{ "cursor", required_argument, nullptr, 0 },
{ "cursor-hotspot", required_argument, nullptr, 0 },
{ "cursor-scale-height", required_argument, nullptr, 0 },
{ "virtual-connector-strategy", required_argument, nullptr, 0 },
{ "ready-fd", required_argument, nullptr, 'R' },
{ "stats-path", required_argument, nullptr, 'T' },
{ "hide-cursor-delay", required_argument, nullptr, 'C' },
Expand Down Expand Up @@ -190,6 +191,7 @@ const char usage[] =
" --force-orientation rotate the internal display (left, right, normal, upsidedown)\n"
" --force-windows-fullscreen force windows inside of gamescope to be the size of the nested display (fullscreen)\n"
" --cursor-scale-height if specified, sets a base output height to linearly scale the cursor against.\n"
" --virtual-connector-strategy Specifies how we should make virtual connectors.\n"
" --hdr-enabled enable HDR output (needs Gamescope WSI layer enabled for support from clients)\n"
" If this is not set, and there is a HDR client, it will be tonemapped SDR.\n"
" --sdr-gamut-wideness Set the 'wideness' of the gamut for SDR comment. 0 - 1.\n"
Expand Down Expand Up @@ -765,7 +767,7 @@ int main(int argc, char **argv)
} else if (strcmp(opt_name, "force-grab-cursor") == 0) {
g_bForceRelativeMouse = true;
} else if (strcmp(opt_name, "display-index") == 0) {
g_nNestedDisplayIndex = atoi( optarg );
g_nNestedDisplayIndex = atoi( optarg );
} else if (strcmp(opt_name, "adaptive-sync") == 0) {
cv_adaptive_sync = true;
} else if (strcmp(opt_name, "expose-wayland") == 0) {
Expand All @@ -776,6 +778,17 @@ int main(int argc, char **argv)
g_nCursorScaleHeight = atoi(optarg);
} else if (strcmp(opt_name, "mangoapp") == 0) {
g_bLaunchMangoapp = true;
} else if (strcmp(opt_name, "virtual-connector-strategy") == 0) {
for ( uint32_t i = 0; i < gamescope::VirtualConnectorStrategies::Count; i++ )
{
gamescope::VirtualConnectorStrategy eStrategy =
static_cast<gamescope::VirtualConnectorStrategy>( i );
if ( optarg == gamescope::VirtualConnectorStrategyToString( eStrategy ) )
{
gamescope::cv_backend_virtual_connector_strategy = eStrategy;

}
}
}
break;
case '?':
Expand Down
2 changes: 1 addition & 1 deletion src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7672,7 +7672,7 @@ steamcompmgr_main(int argc, char **argv)
}

bool bDirtyFocuses = false;
for ( auto &iter : g_VirtuaConnectorFocuses )
for ( auto &iter : g_VirtualConnectorFocuses )
{
global_focus_t *pFocus = &iter.second;
if ( pFocus->IsDirty() )
Expand Down

0 comments on commit 953cd7f

Please sign in to comment.