Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Game.Client/C_Soundscape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ public static class SoundscapeGlobals
public static void Soundscape_OnStopAllSounds() => g_SoundscapeSystem.OnStopAllSounds();
public static void Soundscape_Update(ref AudioParams audio) => g_SoundscapeSystem.UpdateAudioParams(ref audio);
public static ConVar soundscape_fadetime = new("soundscape_fadetime", "3.0", FCvar.Cheat, "Time to crossfade sound effects between soundscapes");

[ConCommand(helpText: "Flushes the client side soundscapes", flags: FCvar.ServerCanExecute | FCvar.Cheat)]
static void cl_soundscape_flush() {
g_SoundscapeSystem.GetAudioParams(out AudioParams tmp);

g_SoundscapeSystem.Shutdown();
g_SoundscapeSystem.Init();

Soundscape_Update(ref tmp);
}
}

public struct LoopingSound
Expand Down Expand Up @@ -206,7 +216,7 @@ public void UpdateAudioParams(ref AudioParams audio) {
}
}

public void GetAudioParams(out AudioParams outParams) => throw new NotImplementedException();
public void GetAudioParams(out AudioParams outParams) => outParams = Params;

public int GetCurrentSoundscape() => throw new NotImplementedException();

Expand Down
2 changes: 0 additions & 2 deletions Game.Client/GarrysMod/C_GMOD_Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace Game.Client.GarrysMod;
[NetworkName("CGMOD_Player")]
public partial class C_GMOD_Player() : C_HL2MP_Player()
{
static ConVar cl_playercolor = new("1.0 0.0 0.0", FCvar.UserInfo | FCvar.Archive | FCvar.ServerCanExecute, "Default Player Model");

[NetworkTable]
public static readonly new NetworkProp[] Props = [
nameof(GModPlayerFlags),
Expand Down
10 changes: 10 additions & 0 deletions Game.Client/HLTVCamera.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Source.Common.Commands;

namespace Game.Client;

public static class HLTVCameraGlobals
{
public static readonly ConVar spec_autodirector = new("spec_autodirector", "1", FCvar.ClientDLL | FCvar.ClientCmdCanExecute, "Auto-director chooses best view modes while spectating");

// todo: C_HLTVCamera
}
127 changes: 127 additions & 0 deletions Game.Client/InJoystick.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using Source.Common.Commands;

namespace Game.Client;

public enum GameAxis
{
None = 0,
Forward,
Pitch,
Side,
Yaw,
Max
}

public enum JoystickAxis
{
X = 0,
Y,
Z,
R,
U,
V,
Max
}

public struct JoyAxis
{
public uint AxisMap;
public uint ControlMap;
}

public partial class Input
{
const uint JOY_ABSOLUTE_AXIS = 0x00000000;
const uint JOY_RELATIVE_AXIS = 0x00000010;

static readonly ConVar joy_name = new("joy_name", "joystick", FCvar.Archive);
static readonly ConVar joy_advanced = new("joy_advanced", "1", FCvar.Archive);
static readonly ConVar joy_advaxisx = new("joy_advaxisx", "4", FCvar.Archive);
static readonly ConVar joy_advaxisy = new("joy_advaxisy", "2", FCvar.Archive);
static readonly ConVar joy_advaxisz = new("joy_advaxisz", "0", FCvar.Archive);
static readonly ConVar joy_advaxisr = new("joy_advaxisr", "1", FCvar.Archive);
static readonly ConVar joy_advaxisu = new("joy_advaxisu", "3", FCvar.Archive);
static readonly ConVar joy_advaxisv = new("joy_advaxisv", "0", FCvar.Archive);
static readonly ConVar joy_movement_stick = new("joy_movement_stick", "0", FCvar.Archive | FCvar.ArchiveXbox, "Which stick controls movement (0 is left stick)", callback: joy_movement_stick_Callback);
static readonly ConVar joy_xcontroller_cfg_loaded = new("joy_xcontroller_cfg_loaded", "0", FCvar.Archive, "If 0, the 360controller.cfg file will be executed on startup & option changes.");

// todo: the rest of in_joystick.cpp (Init_Joystick, JoyStickMove and their ConVars)

readonly JoyAxis[] Axes = new JoyAxis[(int)JoystickAxis.Max];
static ConVarRef? joy_xcontroller_found;

static void joy_movement_stick_Callback(IConVar var, in ConVarChangeContext ctx) {
engine.ClientCmd("joyadvancedupdate");
}

static ReadOnlySpan<char> DescribeAxis(uint index) {
switch ((GameAxis)index) {
case GameAxis.Forward:
return "Forward";
case GameAxis.Pitch:
return "Look";
case GameAxis.Side:
return "Side";
case GameAxis.Yaw:
return "Turn";
case GameAxis.None:
default:
return "Unknown";
}
}

static void DescribeJoystickAxis(string axis, in JoyAxis mapping) {
if (mapping.AxisMap == 0)
Msg("%s: unmapped\n", axis);
else
Msg("%s: mapped to %s (%s)\n", axis, DescribeAxis(mapping.AxisMap).ToString(), mapping.ControlMap != 0 ? "relative" : "absolute");
}

void SetJoystickAxis(JoystickAxis axis, string name, int value) {
uint temp = unchecked((uint)value);
Axes[(int)axis].AxisMap = temp & 0x0000000f;
Axes[(int)axis].ControlMap = temp & JOY_RELATIVE_AXIS;

DescribeJoystickAxis(name, in Axes[(int)axis]);
}

public void Joystick_Advanced() {
for (int i = 0; i < (int)JoystickAxis.Max; i++) {
Axes[i].AxisMap = (uint)GameAxis.None;
Axes[i].ControlMap = JOY_ABSOLUTE_AXIS;
}

if (!joy_advanced.GetBool()) {
Axes[(int)JoystickAxis.X].AxisMap = (uint)GameAxis.Yaw;
Axes[(int)JoystickAxis.Y].AxisMap = (uint)GameAxis.Forward;
}
else {
if (stricmp(joy_name.GetString(), "joystick") != 0)
Msg("Using joystick '%s' configuration\n", joy_name.GetString());

SetJoystickAxis(JoystickAxis.X, "JOY_AXIS_X", joy_movement_stick.GetBool() ? joy_advaxisu.GetInt() : joy_advaxisx.GetInt());
SetJoystickAxis(JoystickAxis.Y, "JOY_AXIS_Y", joy_movement_stick.GetBool() ? joy_advaxisr.GetInt() : joy_advaxisy.GetInt());
SetJoystickAxis(JoystickAxis.Z, "JOY_AXIS_Z", joy_advaxisz.GetInt());
SetJoystickAxis(JoystickAxis.R, "JOY_AXIS_R", joy_movement_stick.GetBool() ? joy_advaxisy.GetInt() : joy_advaxisr.GetInt());
SetJoystickAxis(JoystickAxis.U, "JOY_AXIS_U", joy_movement_stick.GetBool() ? joy_advaxisx.GetInt() : joy_advaxisu.GetInt());
SetJoystickAxis(JoystickAxis.V, "JOY_AXIS_V", joy_advaxisv.GetInt());

Msg("Advanced Joystick settings initialized\n");
}

ConVarRef found = joy_xcontroller_found ??= new("joy_xcontroller_found");
if (found.IsValid() && found.GetBool() && in_joystick.GetBool()) {
if (joy_xcontroller_cfg_loaded.GetInt() < 2) {
engine.ClientCmd_Unrestricted("exec 360controller.cfg");
#if LINUX
engine.ClientCmd_Unrestricted("exec 360controller-linux.cfg");
#endif
joy_xcontroller_cfg_loaded.SetValue(2);
}
}
else if (joy_xcontroller_cfg_loaded.GetInt() > 0) {
engine.ClientCmd_Unrestricted("exec undo360controller.cfg");
joy_xcontroller_cfg_loaded.SetValue(0);
}
}
}
Loading
Loading