19#include <glm/geometric.hpp>
20#include <glm/trigonometric.hpp>
21#include <glm/vec2.hpp>
95 .x = swapSticks ? SDL_GAMEPAD_AXIS_LEFTX : SDL_GAMEPAD_AXIS_RIGHTX,
96 .y = swapSticks ? SDL_GAMEPAD_AXIS_LEFTY : SDL_GAMEPAD_AXIS_RIGHTY,
104 .x = swapSticks ? SDL_GAMEPAD_AXIS_RIGHTX : SDL_GAMEPAD_AXIS_LEFTX,
105 .y = swapSticks ? SDL_GAMEPAD_AXIS_RIGHTY : SDL_GAMEPAD_AXIS_LEFTY,
190 constexpr float k_maxMag = 400.0f;
192 if (mag2 > k_maxMag * k_maxMag) {
193 const float m = std::sqrt(mag2);
198 constexpr float k_deadzone = 28.0f;
199 if (mag2 < k_deadzone * k_deadzone) {
207 angle += glm::two_pi<float>();
219 const bool*
const kKeys = SDL_GetKeyboardState(
nullptr);
220 const SDL_MouseButtonFlags mouse = SDL_GetMouseState(
nullptr,
nullptr);
256 SDL_GetRelativeMouseState(&mdx, &mdy);
261 if (gravityFlipped) {
278 snap.
yaw -= mdx * mouseSensitivity;
281 snap.
yaw = std::remainder(snap.
yaw, glm::radians(360.0f));
284 snap.
pitch = std::clamp(snap.
pitch + mdy * mouseSensitivity, -glm::radians(89.0f), glm::radians(89.0f));
300 const bool*
const kKeys = SDL_GetKeyboardState(
nullptr);
301 const SDL_MouseButtonFlags mouse = SDL_GetMouseState(
nullptr,
nullptr);
321 snap.
left = gravityFlipped ? right : left;
322 snap.
right = gravityFlipped ? left : right;
341 const bool*
const kKeys = SDL_GetKeyboardState(
nullptr);
342 const SDL_MouseButtonFlags mouse = SDL_GetMouseState(
nullptr,
nullptr);
360 const bool*
const kKeys = SDL_GetKeyboardState(
nullptr);
361 const SDL_MouseButtonFlags mouse = SDL_GetMouseState(
nullptr,
nullptr);
365 const bool selectLeftNow = abilityMenuHeld && shootDown;
366 const bool selectRightNow = abilityMenuHeld && scopeDown;
397 snap.
shooting = shootDown && !fireSuppressed;
398 snap.
scoped = scopeDown && !fireSuppressed;
460 const float v = std::clamp(
static_cast<float>(raw) / 32767.0f, -1.0f, 1.0f);
461 if (std::fabs(v) < deadzone)
464 const float sign = v < 0.0f ? -1.0f : 1.0f;
465 return sign * (std::fabs(v) - deadzone) / (1.0f - deadzone);
489 float pitchSensitivity,
490 float yawSensitivity,
493 bool gravityFlipped =
false,
494 bool swapSticks =
false)
513 if (rx == 0.0f && ry == 0.0f) {
518 if (gravityFlipped) {
529 constexpr float k_accelEngageMag = 0.85f;
530 constexpr float k_accelRampTime = 0.5f;
531 constexpr float k_accelMaxBoost = 1.0f;
532 const float stickMag = std::max(std::fabs(rx), std::fabs(ry));
533 if (stickMag >= k_accelEngageMag)
543 snap.
yaw -= rx * yawSensitivity * dt * accelMult;
544 snap.
yaw = std::remainder(snap.
yaw, glm::radians(360.0f));
549 std::clamp(snap.
pitch + ry * pitchSensitivity * dt * accelMult, -glm::radians(89.0f), glm::radians(89.0f));
608 bool gravityFlipped =
false,
609 bool swapSticks =
false)
622 constexpr float moveThresh = 0.3f;
623 const bool padForward = ly < -moveThresh;
624 const bool padBack = ly > moveThresh;
626 const bool padLeft = gravityFlipped ? (lx > moveThresh) : (lx < -moveThresh);
627 const bool padRight = gravityFlipped ? (lx < -moveThresh) : (lx > moveThresh);
636 snap.
back |= padBack;
637 snap.
left |= padLeft;
638 snap.
right |= padRight;
639 snap.
jump |= padJump;
667 const bool selectLeftNow = abilityMenuHeld && padShoot;
668 const bool selectRightNow = abilityMenuHeld && padScope;
696 constexpr Uint64 k_pickupHoldMs = 200;
698 bool padPickupHeld =
false;
699 const Uint64 nowMs = SDL_GetTicks();
706 padPickupHeld =
true;
716 const bool fireSuppressed = abilityMenuHeld;
719 snap.
shooting |= padShoot && !fireSuppressed;
720 snap.
scoped |= padScope && !fireSuppressed;
722 snap.
pickup |= padPickupHeld;
Client side Tag component — entity is eligible to receive player input.
Neutral catalog of selectable emotes (no animation/render deps).
Marker component identifying the locally controlled player entity.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Component for tracking player respawn times.
constexpr int kEmoteCount
Number of emotes shown on the wheel.
Definition EmoteCatalog.hpp:17
Definition InputSampleSystem.hpp:436
constexpr float k_stickDeadzone
Stick deadzone as a fraction of full deflection.
Definition InputSampleSystem.hpp:443
float normaliseAxis(Sint16 raw, float deadzone=k_stickDeadzone)
Convert SDL's int16 axis value to a deadzoned float in [-1, 1].
Definition InputSampleSystem.hpp:455
constexpr float k_triggerThreshold
Trigger threshold for treating an analog trigger as "pressed".
Definition InputSampleSystem.hpp:449
Client-only input sampling system — split into two halves so mouse look can run every iterate() (smoo...
Definition DebugUI.hpp:15
void runGamepadLook(Registry ®istry, SDL_Gamepad *gamepad, float pitchSensitivity, float yawSensitivity, float deadzone, float dt, bool gravityFlipped=false, bool swapSticks=false)
Sample the right stick into yaw / pitch.
Definition InputSampleSystem.hpp:487
bool consumePendingGrenadeCycleNext()
Consume and clear the queued "cycle to next grenade" request.
Definition InputSampleSystem.hpp:124
bool prevGamepadGrenadeCycleKey
Gamepad equivalents: CycleGrenade (D-pad Left) / ThrowGrenade (B).
Definition InputSampleSystem.hpp:35
void runInputSample(Registry ®istry, const InputBindings &bindings, float mouseSensitivity=user_settings::kDefaultMouseSensitivity)
Legacy combined sampler — calls both runMouseLook and runMovementKeys.
Definition InputSampleSystem.hpp:412
bool pendingGrenadeCyclePrev
Definition InputSampleSystem.hpp:41
void runGamepadDeadInput(Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings)
Sample controller skip-respawn input while the local player is dead.
Definition InputSampleSystem.hpp:733
bool prevGamepadEmoteKey
Definition InputSampleSystem.hpp:82
void runGamepadMovement(Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings, float deadzone, bool gravityFlipped=false, bool swapSticks=false)
Sample gamepad buttons / left stick into the movement flags.
Definition InputSampleSystem.hpp:604
bool consumePendingGrenadeThrow()
Consume and clear the queued grenade throw request.
Definition InputSampleSystem.hpp:116
int pendingEmoteRequest
Latched emote to play on wheel release; consumed once by the game loop.
Definition InputSampleSystem.hpp:79
bool consumePendingGrenadeCyclePrev()
Consume and clear the queued "cycle to previous grenade" request.
Definition InputSampleSystem.hpp:132
bool prevEmoteKey
Previous-frame Emote-binding state for open/close edge detection.
Definition InputSampleSystem.hpp:81
float emoteWheelDirX
Accumulated pointing direction used to resolve the highlighted sector.
Definition InputSampleSystem.hpp:76
JoystickAxis getMoveJoystickAxes(bool swapSticks)
Return the SDL axes used for movement, honoring the stick-swap setting.
Definition InputSampleSystem.hpp:101
bool prevGamepadAbilitySelectRight
Tracks previous-frame gamepad right ability-select chord for edge detection.
Definition InputSampleSystem.hpp:52
bool pendingGrenadeCycleNext
Latched cycle next/prev requests, consumed once per frame by the game loop.
Definition InputSampleSystem.hpp:40
void runMouseLook(Registry ®istry, float mouseSensitivity, bool gravityFlipped=false)
Sample mouse delta and accumulate into yaw / pitch.
Definition InputSampleSystem.hpp:252
void runMovementKeys(Registry ®istry, const InputBindings &bindings, bool gravityFlipped=false)
Sample keyboard state into the movement flags.
Definition InputSampleSystem.hpp:298
bool gamepadPickupHoldFired
Set once the press crossed the hold threshold (suppresses tap-swap).
Definition InputSampleSystem.hpp:56
bool prevGamepadAbilitySelectLeft
Tracks previous-frame gamepad left ability-select chord for edge detection.
Definition InputSampleSystem.hpp:50
Uint64 gamepadPickupDownMs
SDL_GetTicks at the Y press, for hold-duration timing.
Definition InputSampleSystem.hpp:55
JoystickAxis getLookJoystickAxes(bool swapSticks)
Return the SDL axes used for camera look, honoring the stick-swap setting.
Definition InputSampleSystem.hpp:92
bool prevGamepadPickupKey
Gamepad Y (Pickup binding) tap-vs-hold state: tap swaps weapon, hold picks up.
Definition InputSampleSystem.hpp:54
bool prevGamepadGrenadeThrowKey
Definition InputSampleSystem.hpp:36
void runEmoteWheelKey(const InputBindings &bindings)
Track the Emote binding (keyboard/mouse) to open/close the wheel.
Definition InputSampleSystem.hpp:217
void runGamepadWeapon(Registry ®istry, SDL_Gamepad *gamepad, const InputBindings &bindings)
Sample gamepad buttons / right trigger into the weapon flags.
Definition InputSampleSystem.hpp:656
int consumePendingEmote()
Consume and clear the latched emote-play request (-1 = none).
Definition InputSampleSystem.hpp:148
bool emoteWheelOpen
True while the emote wheel is open (Emote binding held on any device).
Definition InputSampleSystem.hpp:72
bool consumePendingAbilitySelectRight()
Consume and clear the queued right ability-choice request.
Definition InputSampleSystem.hpp:164
bool consumePendingGamepadWeaponSwap()
Consume and clear the latched tap-Y gamepad weapon swap request.
Definition InputSampleSystem.hpp:140
bool gamepadConnected(SDL_Gamepad *gamepad)
True when a gamepad handle is non-null and still connected.
Definition InputSampleSystem.hpp:110
bool pendingGrenadeThrow
Latched throw request, consumed once per frame by the game loop.
Definition InputSampleSystem.hpp:38
bool prevAbilitySelectRight
Tracks previous-frame Alt+RMB state for ability choice edge detection.
Definition InputSampleSystem.hpp:45
void runWeaponKeys(Registry ®istry, const InputBindings &bindings)
Sample keyboard state into the weapon flags.
Definition InputSampleSystem.hpp:358
bool pendingGamepadWeaponSwap
Latched tap-Y weapon swap, consumed once per frame by the game loop.
Definition InputSampleSystem.hpp:58
void runGamepadEmoteWheel(SDL_Gamepad *gamepad, const InputBindings &bindings, bool swapSticks=false)
Track the Emote binding (controller) to open/close the wheel and pick a sector from the right stick.
Definition InputSampleSystem.hpp:559
bool prevAbilitySelectLeft
Tracks previous-frame Alt+LMB state for ability choice edge detection.
Definition InputSampleSystem.hpp:43
int emoteWheelSelection
Currently highlighted emote sector while the wheel is open, or -1 (none).
Definition InputSampleSystem.hpp:74
bool pendingAbilitySelectLeft
Latched ability choice requests, consumed once per sent input batch.
Definition InputSampleSystem.hpp:47
bool pendingAbilitySelectRight
Definition InputSampleSystem.hpp:48
float gamepadLookAccel
COD-style look acceleration progress in [0, 1]; ramps while the look stick is held near full deflecti...
Definition InputSampleSystem.hpp:61
bool prevGrenadeThrowKey
Definition InputSampleSystem.hpp:33
bool prevKillSelfKey
Tracks previous-frame key state for edge detection.
Definition InputSampleSystem.hpp:30
bool prevGrenadeCycleKey
Previous-frame CycleGrenade (H) / ThrowGrenade (G) key state for edge detection (keyboard/mouse).
Definition InputSampleSystem.hpp:32
bool consumePendingAbilitySelectLeft()
Consume and clear the queued left ability-choice request.
Definition InputSampleSystem.hpp:156
void runDeadInput(Registry ®istry, const InputBindings &bindings)
Sample skip-respawn input while the local player is dead.
Definition InputSampleSystem.hpp:339
float emoteWheelDirY
Definition InputSampleSystem.hpp:77
void emoteWheelApplyPointing(float dx, float dy, bool accumulate)
Resolve emoteWheelSelection from a pointing input.
Definition InputSampleSystem.hpp:179
constexpr float kDefaultMouseSensitivity
Mouse-look sensitivity in radians per SDL relative mouse unit.
Definition UserSettings.hpp:15
Client side Tag component — entity is eligible to receive player input.
Definition Controllable.hpp:9
Marker component that tags exactly one entity per client as the locally controlled player.
Definition LocalPlayer.hpp:12
ECS component: countdown until a dead player respawns.
Definition RespawnTimer.hpp:10
Gamepad axis mapping configuration for look and move axes, used to support stick swapping in user set...
Definition InputSampleSystem.hpp:86
SDL_GamepadAxis x
Definition InputSampleSystem.hpp:87
SDL_GamepadAxis y
Definition InputSampleSystem.hpp:88