ApolloInput Nova 0.2.0
Standalone virtual gamepad library
Loading...
Searching...
No Matches
apollo::input Namespace Reference

Namespaces

namespace  detail

Classes

struct  Feedback
 Feedback payload from the operating system or a game. More...
class  Device
 One created virtual input device. More...
class  Backend
 Factory for virtual input devices. More...
struct  ControllerDescription
 Capabilities reported by a client controller. More...
struct  GamepadState
 One complete gamepad input report. More...
struct  TouchpadState
 Optional touchpad report. More...
struct  ImuSample
 Optional inertial measurement unit sample. More...
struct  Capabilities
 Features a backend can expose for a profile. More...
struct  ProfileIdentity
 USB identity used by backends that create HID-style devices. More...
struct  AnalogDeadzone
 Host-side analog filtering used to remove drift and resting noise. More...
struct  DeviceInfo
 Description of a created virtual device. More...

Typedefs

using FeedbackCallback = std::function<void(const Feedback &)>
 Callback invoked when the virtual device receives feedback.

Enumerations

enum class  BackendKind { automatic = 0 , vigem , uinput , null_backend }
 Kind of backend selected by the caller. More...
enum class  FeedbackType { rumble = 0 , led , adaptive_trigger , unknown }
 Feedback message received from the virtual device. More...
enum class  Profile {
  xbox_360 , xbox_one , xbox_series , xbox_elite ,
  dualshock4 , dualsense , dualsense_edge , switch_pro ,
  steam_controller , steam_deck , generic
}
 Virtual controller profile exposed by a backend. More...
enum class  ControllerFamily {
  unknown , xbox , playstation , nintendo ,
  steam , steam_deck
}
 Physical controller family reported by a streaming client. More...
enum class  Button : std::uint32_t {
  a = 0 , b , x , y ,
  dpad_up , dpad_down , dpad_left , dpad_right ,
  start , back , guide , left_thumb ,
  right_thumb , left_shoulder , right_shoulder , touchpad ,
  touchpad_click , share , options , paddle1 ,
  paddle2 , paddle3 , paddle4 , misc2
}
 Digital gamepad buttons shared by all backends. More...

Functions

std::unique_ptr< Backend > create_backend (BackendKind kind=BackendKind::automatic)
 Create a backend for the current platform.
const char * to_string (BackendKind kind)
 Convert a backend kind to a stable short name.
bool backend_from_string (const std::string &name, BackendKind &kind)
 Parse a backend kind from its short name or a compatible alias.
constexpr std::uint32_t button_bit (Button button)
 Bit mask for one digital button.
void sanitize_gamepad_state (GamepadState &state, const AnalogDeadzone &deadzone={})
 Remove stick drift, trigger resting noise, and center jitter.
const char * to_string (Profile profile)
 Convert a profile to a stable short name.
bool profile_from_string (const std::string &name, Profile &profile)
 Parse a profile from its short name or a compatible alias.
const char * to_string (ControllerFamily family)
 Convert a controller family to a stable short name.
bool controller_family_from_string (const std::string &name, ControllerFamily &family)
 Parse a controller family from its short name or alias.
Capabilities profile_capabilities (Profile profile)
 Features a profile can expose when the backend supports them.
ProfileIdentity profile_identity (Profile profile)
 USB identity associated with a profile.
Profile recommended_profile (const ControllerDescription &controller)
 Pick the most capable virtual profile for a client controller.
std::vector< Profile > profile_compatibility_chain (Profile profile)
 Return a profile followed by progressively simpler alternatives.

Typedef Documentation

◆ FeedbackCallback

using apollo::input::FeedbackCallback = std::function<void(const Feedback &)>

Callback invoked when the virtual device receives feedback.

Definition at line 53 of file backend.hpp.

Enumeration Type Documentation

◆ BackendKind

enum class apollo::input::BackendKind
strong

Kind of backend selected by the caller.

Enumerator
automatic 

Best backend for the current platform.

vigem 

ViGEmBus on Windows.

uinput 

Linux uinput.

null_backend 

No-op backend useful for tests and previews.

Definition at line 19 of file backend.hpp.

◆ Button

enum class apollo::input::Button : std::uint32_t
strong

Digital gamepad buttons shared by all backends.

Enumerator
a 
b 
x 
y 
dpad_up 
dpad_down 
dpad_left 
dpad_right 
start 
back 
guide 
left_thumb 
right_thumb 
left_shoulder 
right_shoulder 
touchpad 
touchpad_click 
share 
options 
paddle1 
paddle2 
paddle3 
paddle4 
misc2 

Second miscellaneous button, when a controller exposes one.

Definition at line 65 of file gamepad.hpp.

◆ ControllerFamily

Physical controller family reported by a streaming client.

The family is a hint used to choose a compatible virtual profile. It does not guarantee that every feature of the physical controller can be exposed by the host backend.

Enumerator
unknown 

No reliable family information.

xbox 

Xbox 360, Xbox One, Xbox Series, or Xbox Elite controller.

playstation 

DualShock 3/4, DualSense, or another PlayStation-style pad.

nintendo 

Switch Pro Controller, Joy-Con, or another Nintendo-style pad.

steam 

Valve Steam Controller.

steam_deck 

Valve Steam Deck built-in controls.

Definition at line 37 of file gamepad.hpp.

◆ FeedbackType

enum class apollo::input::FeedbackType
strong

Feedback message received from the virtual device.

Enumerator
rumble 

Rumble motors.

led 

LED or lightbar.

adaptive_trigger 

Adaptive trigger effect.

unknown 

Definition at line 29 of file backend.hpp.

◆ Profile

enum class apollo::input::Profile
strong

Virtual controller profile exposed by a backend.

Enumerator
xbox_360 
xbox_one 
xbox_series 
xbox_elite 

Xbox Elite Series 2 with rear paddles and Share.

dualshock4 
dualsense 
dualsense_edge 

DualSense Edge with rear paddles and extra function buttons.

switch_pro 
steam_controller 

Valve Steam Controller layout.

steam_deck 

Valve Steam Deck built-in controls.

generic 

Definition at line 16 of file gamepad.hpp.

Function Documentation

◆ backend_from_string()

bool apollo::input::backend_from_string ( const std::string & name,
BackendKind & kind )

Parse a backend kind from its short name or a compatible alias.

Matching is case-insensitive. Aliases include "auto", "vigembus", "linux_uinput", and "none".

Parameters
nameBackend name.
kindReceives the parsed kind.
Returns
True when the name is valid.

Definition at line 70 of file backend.cpp.

◆ button_bit()

std::uint32_t apollo::input::button_bit ( Button button)
constexpr

Bit mask for one digital button.

Parameters
buttonButton to encode.
Returns
Single-bit mask.

Definition at line 98 of file gamepad.hpp.

◆ controller_family_from_string()

bool apollo::input::controller_family_from_string ( const std::string & name,
ControllerFamily & family )

Parse a controller family from its short name or alias.

Parameters
nameFamily name or alias.
familyReceives the parsed family.
Returns
True when the name is valid.

Definition at line 191 of file gamepad.cpp.

◆ create_backend()

std::unique_ptr< Backend > apollo::input::create_backend ( BackendKind kind = BackendKind::automatic)

Create a backend for the current platform.

Parameters
kindRequested backend, or automatic.
Returns
Backend instance. Never null; falls back to the null backend.

Definition at line 101 of file backend.cpp.

◆ profile_capabilities()

Capabilities apollo::input::profile_capabilities ( Profile profile)

Features a profile can expose when the backend supports them.

This describes the target profile itself, not the capabilities of a specific backend. A backend intersects this matrix with its own support and reports the result in DeviceInfo::capabilities.

Parameters
profileVirtual controller profile.
Returns
Feature matrix for the profile.

Definition at line 201 of file gamepad.cpp.

◆ profile_compatibility_chain()

std::vector< Profile > apollo::input::profile_compatibility_chain ( Profile profile)

Return a profile followed by progressively simpler alternatives.

The first element is always the requested profile. Later elements are safe substitutes that keep standard buttons, sticks, and triggers working when the preferred profile is unavailable on a backend.

Parameters
profileRequested profile.
Returns
Compatibility chain starting with the requested profile.

Definition at line 337 of file gamepad.cpp.

◆ profile_from_string()

bool apollo::input::profile_from_string ( const std::string & name,
Profile & profile )

Parse a profile from its short name or a compatible alias.

Matching is case-insensitive. Aliases include Xbox 360/One/Series names, DS4/DS5, Switch, Elite, Edge, Steam, and Deck variants.

Parameters
nameProfile name or alias.
profileReceives the parsed profile.
Returns
True when the name is valid.

Definition at line 172 of file gamepad.cpp.

◆ profile_identity()

ProfileIdentity apollo::input::profile_identity ( Profile profile)

USB identity associated with a profile.

Backends that expose HID-style devices can use this identity so SDL, Steam, and udev apply the correct controller mapping.

Parameters
profileVirtual controller profile.
Returns
USB vendor, product, and version identifiers.

Definition at line 277 of file gamepad.cpp.

◆ recommended_profile()

Profile apollo::input::recommended_profile ( const ControllerDescription & controller)

Pick the most capable virtual profile for a client controller.

The recommendation keeps controller-specific features when possible: touchpads and motion prefer PlayStation/Steam profiles, Nintendo pads use the Switch Pro profile, and Xbox pads use Xbox Series or Xbox Elite.

Parameters
controllerClient-reported controller description.
Returns
Recommended virtual profile.

Definition at line 306 of file gamepad.cpp.

◆ sanitize_gamepad_state()

void apollo::input::sanitize_gamepad_state ( GamepadState & state,
const AnalogDeadzone & deadzone = {} )

Remove stick drift, trigger resting noise, and center jitter.

The stick deadzone is radial, so diagonal drift is handled consistently on both axes. Values outside the deadzone are rescaled to preserve full travel.

Parameters
stateGamepad state to sanitize in place.
deadzoneDeadzone configuration.

Definition at line 484 of file gamepad.cpp.

◆ to_string() [1/3]

const char * apollo::input::to_string ( BackendKind kind)

Convert a backend kind to a stable short name.

Parameters
kindBackend kind.
Returns
Static string.

Definition at line 61 of file backend.cpp.

◆ to_string() [2/3]

const char * apollo::input::to_string ( ControllerFamily family)

Convert a controller family to a stable short name.

Parameters
familyController family.
Returns
Static string such as "xbox", "playstation", or "steam_deck".

Definition at line 182 of file gamepad.cpp.

◆ to_string() [3/3]

const char * apollo::input::to_string ( Profile profile)

Convert a profile to a stable short name.

Parameters
profileProfile to convert.
Returns
Static string such as "xbox_360".

Definition at line 163 of file gamepad.cpp.