//
// Copyright(C) 2026
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// DESCRIPTION:
//   Embedded HTTP/WebSocket server letting a phone browser join a
//   local splitscreen slot and drive it over the LAN. Spike/proof of
//   concept for the QR-code mobile-controller join flow - see
//   G_SetRemoteInputState (g_game.h) for how received input reaches
//   the game.
//

#ifndef __I_WEBINPUT__
#define __I_WEBINPUT__

#include "doomtype.h"

// Starts the listener thread on the given TCP port. Safe to call once
// at startup; does nothing on platforms without a POSIX sockets
// implementation (currently Windows).
void I_WebInputInit (int port);

// Call once per game tic (see D_ProcessEvents). Binds newly-connected
// phones to local player slots, releases slots whose phone disconnected,
// and pushes each connected slot's latest input state into the game via
// G_SetRemoteInputState.
void I_WebInputTic (void);

// Whether -qrstart is active and there's a join URL to show (see
// i_webinput.c's PrintJoinURL). Checked by R_RenderSplitViews to
// decide whether an empty splitscreen grid cell should get a join QR
// instead of staying plain black.
boolean I_WebInputQrEnabled (void);

// Draws a join QR code, fit and centered, into the screen-buffer
// rectangle (x, y, w, h). No-op if I_WebInputQrEnabled() is false.
void I_WebInputDrawJoinQR (int x, int y, int w, int h);

// Whether -nolocal was passed (no local keyboard/mouse player - every
// player, including the first, joins via phone).
boolean I_WebInputNoLocalEnabled (void);

#endif
