AIRWAVES_PLATFORM says otherwise.
- commit
- 09a035da3052c3bbe8805b6fa14c95c413c9cc3d
- parent
- 71151f59be443b65522c7e2ccfd70859155e73e2
- author
- FelineStateMachine <226808055+FelineStateMachine@users.noreply.github.com>
- kind
- feat risk score 1.8 of 3, Jev's estimate
| M | app.go | 6 | +++++- |
| M | frontend/ | 2 | ++ |
| M | main.go | 13 | +++++++++++++ |
@@ -95,6 +95,10 @@ type Boot struct {
9595 NativeZoom bool `json:"nativeZoom,omitempty"`9696 // Version is the app's.9797 Version string `json:"version"`98+ // Platform is which of the frontend's three experiences this is:99+ // "desktop", or "console" under gamescope; AIRWAVES_PLATFORM (desktop,100+ // console or tv) says otherwise.101+ Platform string `json:"platform"`98102 }99103 100104 // Boot returns settings and the server's description. AIRWAVES_VIEW opens a@@ -102,7 +106,7 @@ type Boot struct {
102106 func (a *App) Boot() Boot {103107 c, s, err := a.server()104108 out := Boot{Settings: s, View: os.Getenv("AIRWAVES_VIEW"), Lite: os.Getenv("AIRWAVES_LITE"),105- AutoScale: autoScale(), NativeZoom: nativeZoom, Version: version}109+ AutoScale: autoScale(), NativeZoom: nativeZoom, Version: version, Platform: platform()}106110 if err != nil {107111 out.Error = err.Error()108112 return out@@ -729,6 +729,7 @@ export namespace main {
729729 autoScale: number;730730 nativeZoom?: boolean;731731 version: string;732+ platform: string;732733 733734 static createFrom(source: any = {}) {734735 return new Boot(source);@@ -746,6 +747,7 @@ export namespace main {
746747 this.autoScale = source["autoScale"];747748 this.nativeZoom = source["nativeZoom"];748749 this.version = source["version"];750+ this.platform = source["platform"];749751 }750752 751753 convertValues(a: any, classs: any, asMap: boolean = false): any {@@ -82,6 +82,19 @@ func autoScale() int {
8282 return 1008383 }8484 85+// platform is the frontend's experience: a console's under gamescope, else86+// a desktop's, unless AIRWAVES_PLATFORM names one.87+func platform() string {88+ switch p := os.Getenv("AIRWAVES_PLATFORM"); p {89+ case "desktop", "console", "tv":90+ return p91+ }92+ if gamescope() {93+ return "console"94+ }95+ return "desktop"96+}97+8598 // gamescope tells whether the app runs under gamescope: SteamOS Game Mode,8699 // on a TV.87100 func gamescope() bool {