HTTP Permissions-Policy gamepad

Typ

Die gamepad-Direktive steuert den Zugriff auf die Gamepad API zum Lesen von Game-Controller-Eingaben.

Syntax

Die Direktive definiert eine Allowlist für Ursprünge, die Gamepad-Input abfragen dürfen.

http
Permissions-Policy: gamepad=(self)
Permissions-Policy: gamepad=(self "https://game-platform.com")
Permissions-Policy: gamepad=()

Direktiven

Die Direktive unterstützt Standard-Allowlist-Werte für präzise Zugriffssteuerung.

self
Erlaubt Gamepad-Zugriff nur für das Hauptdokument des gleichen Ursprungs. Eingebettete iFrames von anderen Ursprüngen werden blockiert.
origin-list
Liste von Ursprüngen in Anführungszeichen, z.B. "https://cloud-gaming.example.com", die zusätzlich zum Hauptdokument Gamepad-Zugriff erhalten. Für Cloud-Gaming-Dienste.

Beispiele

Die folgenden Beispiele zeigen typische Anwendungsfälle für Browser-Gaming und Cloud-Gaming-Plattformen.

Browser-Based-Game mit Gamepad-Support

Ein Browser-Spiel nutzt Gamepad API für Controller-Eingaben.

http
HTTP/1.1 200 OK
Content-Type: text/html
Permissions-Policy: gamepad=(self), fullscreen=(self)

<!DOCTYPE html>
<html>
<head><title>Racing Game</title></head>
<body>
  <canvas id="game"></canvas>
  <script>
    window.addEventListener('gamepadconnected', (e) => {
      console.log('Gamepad connected:', e.gamepad.id);
      gameLoop();
    });

    function gameLoop() {
      const gamepads = navigator.getGamepads();
      const gp = gamepads[0];
      if (gp) {
        const steering = gp.axes[0];
        const throttle = gp.buttons[0].value;
        // Update game state
      }
      requestAnimationFrame(gameLoop);
    }
  </script>
</body>
</html>

Cloud-Gaming-Platform mit Embedded-Player

Eine Gaming-Plattform erlaubt einem Cloud-Gaming-Dienst Gamepad-Zugriff.

http
HTTP/1.1 200 OK
Content-Type: text/html
Permissions-Policy: gamepad=(self "https://stream.cloud-gaming.example.com")

<!DOCTYPE html>
<html>
<head><title>Game Library</title></head>
<body>
  <iframe src="https://stream.cloud-gaming.example.com/play/game123"
          allow="gamepad; fullscreen"></iframe>
</body>
</html>

REST-API ohne Gamepad-Support

Ein API-Endpunkt deaktiviert alle Gaming-bezogenen APIs.

http
HTTP/1.1 200 OK
Content-Type: application/json
Permissions-Policy: gamepad=(), fullscreen=()

{
  "status": "success",
  "game_metadata": {}
}

Vorteile für die Systemarchitektur

  • Verhindert unerwünschten Gamepad-Zugriff durch eingebettete Drittanbieter-Inhalte
  • Reduziert Fingerprinting-Risiken durch Controller-Hardware-Erkennung
  • Ermöglicht native Controller-Unterstützung für Web-Gaming
  • Schützt vor unerwünschtem Input-Monitoring durch iFrames

Spezifikation

Definiert in der W3C Gamepad API Spezifikation. Unterstützt Xbox, PlayStation und generische USB-Controller. Keine User-Permission erforderlich, nur Policy-Check.

Weitere Spezifikationen

Permissions-Policy Header, Content-Security-Policy Header