group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
InputSampleSystem.hpp File Reference

Client-only input sampling for mouse look and movement keys. More...

#include "config/InputBindings.hpp"
#include "ecs/components/Controllable.hpp"
#include "ecs/components/InputSnapshot.hpp"
#include "ecs/components/LocalPlayer.hpp"
#include "ecs/components/RespawnTimer.hpp"
#include "ecs/registry/Registry.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <cmath>
#include <glm/geometric.hpp>
#include <glm/trigonometric.hpp>
#include <glm/vec2.hpp>
Include dependency graph for InputSampleSystem.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  systems::JoystickAxis
 Gamepad axis mapping configuration for look and move axes, used to support stick swapping in user settings. More...

Namespaces

namespace  systems
 Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent).
namespace  systems::gamepad

Functions

JoystickAxis systems::getLookJoystickAxes (bool swapSticks)
 Return the SDL axes used for camera look, honoring the stick-swap setting.
JoystickAxis systems::getMoveJoystickAxes (bool swapSticks)
 Return the SDL axes used for movement, honoring the stick-swap setting.
bool systems::gamepadConnected (SDL_Gamepad *gamepad)
 True when a gamepad handle is non-null and still connected.
std::uint8_t systems::grenadeRadialIndexFromAim ()
 Convert the current grenade radial aim vector into a grenade slot index.
bool systems::consumePendingGrenadeThrow ()
 Consume and clear the queued grenade quick-throw request.
void systems::runMouseLook (Registry &registry, float mouseSensitivity, bool gravityFlipped=false)
 Sample mouse delta and accumulate into yaw / pitch.
void systems::runMovementKeys (Registry &registry, const InputBindings &bindings, bool gravityFlipped=false)
 Sample keyboard state into the movement flags.
void systems::runDeadInput (Registry &registry, const InputBindings &bindings)
 Sample skip-respawn input while the local player is dead.
void systems::runWeaponKeys (Registry &registry, const InputBindings &bindings, float dt=0.0f)
 Sample keyboard state into the weapon flags.
void systems::runInputSample (Registry &registry, const InputBindings &bindings, float mouseSensitivity=0.001f)
 Legacy combined sampler — calls both runMouseLook and runMovementKeys.
float systems::gamepad::normaliseAxis (Sint16 raw, float deadzone=k_stickDeadzone)
 Convert SDL's int16 axis value to a deadzoned float in [-1, 1].
void systems::runGamepadLook (Registry &registry, SDL_Gamepad *gamepad, float pitchSensitivity, float yawSensitivity, float deadzone, float dt, bool gravityFlipped=false, bool swapSticks=false)
 Sample the right stick into yaw / pitch.
void systems::runGamepadMovement (Registry &registry, SDL_Gamepad *gamepad, const InputBindings &bindings, float deadzone, bool gravityFlipped=false, bool swapSticks=false)
 Sample gamepad buttons / left stick into the movement flags.
void systems::runGamepadWeapon (Registry &registry, SDL_Gamepad *gamepad, const InputBindings &bindings)
 Sample gamepad buttons / right trigger into the weapon flags.
void systems::runGamepadDeadInput (Registry &registry, SDL_Gamepad *gamepad, const InputBindings &bindings)
 Sample controller skip-respawn input while the local player is dead.

Variables

bool systems::prevKillSelfKey = false
 Tracks previous-frame key state for edge detection.
bool systems::prevGrenadeKey = false
 Tracks previous-frame G key state for grenade quick-throw / radial behavior.
float systems::grenadeHeldSeconds = 0.0f
 Seconds the grenade key has been continuously held.
bool systems::grenadeRadialActive = false
 True while the grenade radial selector is open.
glm::vec2 systems::grenadeRadialAim {0.0f, -1.0f}
 Current mouse-relative aim vector inside the grenade radial selector.
bool systems::pendingGrenadeThrow = false
 Latched quick-throw request consumed by HUD/gameplay code.
constexpr float systems::k_grenadeRadialHoldSeconds = 0.24f
 Hold duration before the grenade quick-throw becomes radial selection.
constexpr float systems::k_grenadeRadialDeadzone = 18.0f
 Minimum radial aim distance required to choose a grenade slot.
constexpr float systems::k_grenadeRadialMaxDistance = 130.0f
 Maximum stored cursor distance from the grenade radial center.
bool systems::prevAbilitySelectLeft = false
 Tracks previous-frame Alt+LMB state for ability choice edge detection.
bool systems::prevAbilitySelectRight = false
 Tracks previous-frame Alt+RMB state for ability choice edge detection.
bool systems::prevGamepadAbilitySelectLeft = false
 Tracks previous-frame gamepad left ability-select chord for edge detection.
bool systems::prevGamepadAbilitySelectRight = false
 Tracks previous-frame gamepad right ability-select chord for edge detection.
constexpr float systems::gamepad::k_stickDeadzone = 0.15f
 Stick deadzone as a fraction of full deflection.
constexpr float systems::gamepad::k_triggerThreshold = 0.5f
 Trigger threshold for treating an analog trigger as "pressed".

Detailed Description

Client-only input sampling for mouse look and movement keys.