GamepadInput
- Module
- Input
- Header
#include "Input/GamepadInput.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr float | DefaultDeadzone | Deadzone (applied to stick axes) Default 0.15f. |
static constexpr float | DefaultTriggerDeadzone | Trigger deadzone. Worn analog triggers rest slightly above zero; with no floor, a bound action actuates forever from that drift and never sees a release. The live range remaps to the full 0..1. Default 0.05f. |
Constructors
| Signature | Name | Description |
|---|---|---|
GamepadInput() | GamepadInput |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | IsButtonDown | |
bool | IsButtonPressed | Sticky per-frame edges — a press+release between two Update() calls still reports both (see KeyboardInput). |
bool | IsButtonReleased | |
float | GetAxis | Axis values (-1..1 for sticks, 0..1 for triggers) |
bool | IsConnected | |
void | SetConnected | Disconnecting zeroes the device state: a pad yanked mid-stick-push otherwise leaves its last axis values latched forever and any bound action stays actuated with no release ever arriving. |
void | OnButtonDown | |
void | OnButtonUp | |
void | SetAxis | |
void | Update | Call at start of frame (copies current → previous) |
void | SetDeadzone | |
float | GetDeadzone | |
void | SetTriggerDeadzone | |
float | GetTriggerDeadzone | |
void | SetNativeHandle | Native SDL_Gamepad* handle (opaque to avoid leaking SDL into the header). |
void* | GetNativeHandle | |
bool | Rumble | Rumble (low-frequency = big motor, high-frequency = small motor). |
bool | RumbleTriggers | Trigger rumble (DualSense / Xbox Series X|S adaptive triggers). |
void | StopRumble | Stop all rumble immediately (both regular + trigger motors). |
bool | HasGyro | |
bool | HasAccel | |
SensorSample | GetGyro | |
SensorSample | GetAccel | |
bool | EnableMotionSensors | Starts the sensor stream. |
void | SetGyro | |
void | SetAccel | |
bool | HasRgbLed | Light bar / LED colour in 0..1 (DualShock 4, DualSense, Steam Deck). |
bool | SetLedColor | |
bool | HasLedColor | |
void | RestoreLed | Re-sends the last colour; Window's connect path calls it through the manager so a pad that re-pairs mid-session keeps the colour the game set. |
bool | IsMotionEnabled |
Function details
GamepadInput
GamepadInput()IsButtonDown
bool IsButtonDown(GamepadButton button) constIsButtonPressed
bool IsButtonPressed(GamepadButton button) constSticky per-frame edges — a press+release between two Update() calls still reports both (see KeyboardInput).
IsButtonReleased
bool IsButtonReleased(GamepadButton button) constGetAxis
float GetAxis(GamepadAxis axis) constAxis values (-1..1 for sticks, 0..1 for triggers)
IsConnected
bool IsConnected() constSetConnected
void SetConnected(bool connected)Disconnecting zeroes the device state: a pad yanked mid-stick-push otherwise leaves its last axis values latched forever and any bound action stays actuated with no release ever arriving.
OnButtonDown
void OnButtonDown(GamepadButton button)OnButtonUp
void OnButtonUp(GamepadButton button)SetAxis
void SetAxis(GamepadAxis axis, float value)Update
void Update()Call at start of frame (copies current → previous)
SetDeadzone
void SetDeadzone(float deadzone)GetDeadzone
float GetDeadzone() constSetTriggerDeadzone
void SetTriggerDeadzone(float deadzone)GetTriggerDeadzone
float GetTriggerDeadzone() constSetNativeHandle
void SetNativeHandle(void* sdlGamepad)Native SDL_Gamepad* handle (opaque to avoid leaking SDL into the header). Set by Window on connect / cleared to nullptr on disconnect. Required for rumble — SDL keeps haptic state per-gamepad.
GetNativeHandle
void* GetNativeHandle() constRumble
bool Rumble(float lowFreq, float highFreq, uint32_t durationMs)Rumble (low-frequency = big motor, high-frequency = small motor). Both in 0..1; durationMs == 0 stops rumble. Returns true on success. No-op when the gamepad doesn't support rumble (e.g. some 3rd-party pads).
RumbleTriggers
bool RumbleTriggers(float leftTrigger, float rightTrigger, uint32_t durationMs)Trigger rumble (DualSense / Xbox Series X|S adaptive triggers). Returns true on success; false if the controller doesn't expose trigger haptics — caller may fall back to a regular Rumble().
StopRumble
void StopRumble()Stop all rumble immediately (both regular + trigger motors).
HasGyro
bool HasGyro() constHasAccel
bool HasAccel() constGetGyro
SensorSample GetGyro() constGetAccel
SensorSample GetAccel() constEnableMotionSensors
bool EnableMotionSensors(bool enable)Starts the sensor stream. SDL leaves it off because it costs HID bandwidth, so InputManager enables it on the first gyro/accel read rather than for every pad; returns true when a gyro is streaming.
SetGyro
void SetGyro(float x, float y, float z)SetAccel
void SetAccel(float x, float y, float z)HasRgbLed
bool HasRgbLed() constLight bar / LED colour in 0..1 (DualShock 4, DualSense, Steam Deck). Returns false when the pad has no RGB LED. Remembered so a connect after the game picked a colour restores it.
SetLedColor
bool SetLedColor(float r, float g, float b)HasLedColor
bool HasLedColor() constRestoreLed
void RestoreLed()Re-sends the last colour; Window's connect path calls it through the manager so a pad that re-pairs mid-session keeps the colour the game set.
IsMotionEnabled
bool IsMotionEnabled() const