Antkeeper  0.0.1
Public Member Functions | List of all members
input::gamepad Class Reference

A virtual gamepad which generates gamepad-related input events. More...

#include <gamepad.hpp>

Inheritance diagram for input::gamepad:
input::device

Public Member Functions

 gamepad ()
 Constructs a gamepad input device. More...
 
void set_activation_threshold (gamepad_axis axis, float min, float max)
 Sets the activation threshold for a gamepad axis. More...
 
void set_response_curve (gamepad_axis axis, gamepad_response_curve curve)
 Sets the activation response curve of an axis. More...
 
void set_left_deadzone_cross (bool cross)
 Sets the type of deadzone shape for the axes on the left stick. More...
 
void set_right_deadzone_cross (bool cross)
 Sets the type of deadzone shape for the axes on the right stick. More...
 
void set_left_deadzone_roundness (float roundness)
 Sets the roundness of the deadzone for the axes on the left stick. More...
 
void set_right_deadzone_roundness (float roundness)
 Sets the roundness of the deadzone for the axes on the right stick. More...
 
void press (gamepad_button button)
 Simulates a gamepad button press. More...
 
void release (gamepad_button button)
 Simulates a gamepad button release. More...
 
void move (gamepad_axis axis, float position)
 Simulates a gamepad axis movement. More...
 
::event::channel< gamepad_button_pressed_event > & get_button_pressed_channel () noexcept
 Returns the channel through which gamepad button pressed events are published. More...
 
::event::channel< gamepad_button_released_event > & get_button_released_channel () noexcept
 Returns the channel through which gamepad button released events are published. More...
 
::event::channel< gamepad_axis_moved_event > & get_axis_moved_channel () noexcept
 Returns the channel through which gamepad axis moved events are published. More...
 
constexpr device_type get_device_type () const noexcept override
 Returns device_type::gamepad. More...
 
- Public Member Functions inherited from input::device
void connect ()
 Simulates the device being connected. More...
 
void disconnect ()
 Simulates the device being disconnected. More...
 
bool is_connected () const noexcept
 Returns true if the device is currently connected. More...
 
void set_uuid (const ::uuid &id)
 Sets the universally unique identifier (UUID) of this input device. More...
 
const ::uuidget_uuid () const noexcept
 Returns the universally unique identifier (UUID) of this input device. More...
 
::event::channel< device_connected_event > & get_connected_channel () noexcept
 Returns the channel through which device connected events are published. More...
 
::event::channel< device_disconnected_event > & get_disconnected_channel () noexcept
 Returns the channel through which device disconnected events are published. More...
 

Detailed Description

A virtual gamepad which generates gamepad-related input events.

Definition at line 48 of file gamepad.hpp.

Constructor & Destructor Documentation

◆ gamepad()

input::gamepad::gamepad ( )

Constructs a gamepad input device.

Definition at line 28 of file gamepad.cpp.

Member Function Documentation

◆ get_axis_moved_channel()

::event::channel<gamepad_axis_moved_event>& input::gamepad::get_axis_moved_channel ( )
inlinenoexcept

Returns the channel through which gamepad axis moved events are published.

Definition at line 136 of file gamepad.hpp.

◆ get_button_pressed_channel()

::event::channel<gamepad_button_pressed_event>& input::gamepad::get_button_pressed_channel ( )
inlinenoexcept

Returns the channel through which gamepad button pressed events are published.

Definition at line 124 of file gamepad.hpp.

◆ get_button_released_channel()

::event::channel<gamepad_button_released_event>& input::gamepad::get_button_released_channel ( )
inlinenoexcept

Returns the channel through which gamepad button released events are published.

Definition at line 130 of file gamepad.hpp.

◆ get_device_type()

constexpr device_type input::gamepad::get_device_type ( ) const
inlineconstexproverridevirtualnoexcept

Returns device_type::gamepad.

Implements input::device.

Definition at line 142 of file gamepad.hpp.

◆ move()

void input::gamepad::move ( gamepad_axis  axis,
float  position 
)

Simulates a gamepad axis movement.

Parameters
axisGamepad axis.
positionPosition on the axis, on [-1, 1].

@TODO Support arbitrary number of gamepad axes.

Definition at line 80 of file gamepad.cpp.

◆ press()

void input::gamepad::press ( gamepad_button  button)

Simulates a gamepad button press.

Parameters
buttonButton to press.

Definition at line 70 of file gamepad.cpp.

◆ release()

void input::gamepad::release ( gamepad_button  button)

Simulates a gamepad button release.

Parameters
buttonButton to release.

Definition at line 75 of file gamepad.cpp.

◆ set_activation_threshold()

void input::gamepad::set_activation_threshold ( gamepad_axis  axis,
float  min,
float  max 
)

Sets the activation threshold for a gamepad axis.

Parameters
axisGamepad axis.
minAxis minimum activation threshold.
maxAxis maximum activation threshold.

Definition at line 39 of file gamepad.cpp.

◆ set_left_deadzone_cross()

void input::gamepad::set_left_deadzone_cross ( bool  cross)

Sets the type of deadzone shape for the axes on the left stick.

Parameters
crossIf true, the x and y axes are independently activated, if false, activation of the x and y axes are dependent on their combined magnitude.

Definition at line 50 of file gamepad.cpp.

◆ set_left_deadzone_roundness()

void input::gamepad::set_left_deadzone_roundness ( float  roundness)

Sets the roundness of the deadzone for the axes on the left stick.

Parameters
roundnessRoundness of the deadzone shape for non-cross deadzones. A value of 0.0 results in a square deadzone, while a value of 1.0 results in a circular deadzone. Values between 0.0 and 1.0 result in a rounded rectangle deadzone.

Definition at line 60 of file gamepad.cpp.

◆ set_response_curve()

void input::gamepad::set_response_curve ( gamepad_axis  axis,
gamepad_response_curve  curve 
)

Sets the activation response curve of an axis.

Parameters
axisGamepad axis.
curveActivation response curve.

Definition at line 45 of file gamepad.cpp.

◆ set_right_deadzone_cross()

void input::gamepad::set_right_deadzone_cross ( bool  cross)

Sets the type of deadzone shape for the axes on the right stick.

Parameters
crossIf true, the x and y axes are independently activated, if false, activation of the x and y axes are dependent on their combined magnitude.

Definition at line 55 of file gamepad.cpp.

◆ set_right_deadzone_roundness()

void input::gamepad::set_right_deadzone_roundness ( float  roundness)

Sets the roundness of the deadzone for the axes on the right stick.

Parameters
roundnessRoundness of the deadzone shape for non-cross deadzones. A value of 0.0 results in a square deadzone, while a value of 1.0 results in a circular deadzone. Values between 0.0 and 1.0 result in a rounded rectangle deadzone.

Definition at line 65 of file gamepad.cpp.


The documentation for this class was generated from the following files: