ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
input.cpp File Reference
#include "./asw/modules/input.h"
#include <algorithm>
#include <cmath>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include "./asw/modules/action.h"
#include "./asw/modules/display.h"
#include "./asw/modules/log.h"
Include dependency graph for input.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{input.cpp}
 

Typedefs

using anonymous_namespace{input.cpp}::ControllerState
 Data structure for controller state, including button states and axis values.
 

Functions

float anonymous_namespace{input.cpp}::rescale_dead_zone (float magnitude, float dead_zone)
 Rescale a value past the dead zone so it starts from zero.
 
asw::Vec2< float > anonymous_namespace{input.cpp}::read_stick (const ControllerState &cont, asw::input::ControllerStick stick)
 Read a stick with a radial dead zone.
 
float anonymous_namespace{input.cpp}::read_axis (const ControllerState &cont, asw::input::ControllerAxis axis)
 Read one axis with the dead zone applied.
 
template<typename Pred >
bool anonymous_namespace{input.cpp}::any_controller (uint32_t index, Pred pred)
 Check a button on one controller, or on any when index is ANY_CONTROLLER.
 
template<typename Action >
bool anonymous_namespace{input.cpp}::each_controller (uint32_t index, Action action)
 Run an action on one controller, or on all when index is ANY_CONTROLLER.
 
uint16_t anonymous_namespace{input.cpp}::to_motor_intensity (float intensity)
 Convert an intensity between 0 and 1 to SDL's motor range.
 
bool anonymous_namespace{input.cpp}::has_capability (const ControllerState &cont, const char *property)
 Read a boolean capability from a controller's properties.
 
std::string anonymous_namespace{input.cpp}::pad_identity (SDL_JoystickID id, SDL_Gamepad *pad)
 What tells a pad apart when it is plugged back in: its serial number, or its model when it has none. Two pads of one model with no serial look the same.
 
bool anonymous_namespace{input.cpp}::slot_empty (std::size_t index)
 
std::size_t anonymous_namespace{input.cpp}::pick_slot (const std::string &identity)
 Pick the slot for a pad that just connected.
 
SDL_WindowID anonymous_namespace{input.cpp}::simulated_window_id ()
 
void anonymous_namespace{input.cpp}::push_simulated_key (asw::input::Key key, bool down)
 
void anonymous_namespace{input.cpp}::push_simulated_mouse_button (asw::input::MouseButton button, bool down)
 

Variables

std::array< SDL_Cursor *, asw::input::NUM_CURSORS > anonymous_namespace{input.cpp}::cursors { nullptr }
 Active cursor stores the current active cursor. It is updated by the core.
 
std::vector< ControllerState > anonymous_namespace{input.cpp}::controller { }
 Global controller state. A slot stays at its index while its pad is unplugged, and the pad gets it back when plugged in again, so bindings keep reading the same physical pad.
 
std::vector< std::string > anonymous_namespace{input.cpp}::slot_owner { }
 The pad each slot last held, by pad_identity(). Kept after the pad is unplugged and after its slot is dropped from the end of controller, so the pad can get its slot back.
 
float anonymous_namespace{input.cpp}::default_dead_zone { 0.25F }
 Dead zone given to pads when they connect.
 
std::unordered_map< SDL_JoystickID, uint32_t > anonymous_namespace{input.cpp}::controller_id_map { }
 Map of SDL_JoystickID to controller index in the controller vector.
 
asw::input::KeyState anonymous_namespace{input.cpp}::keyboard { }
 
asw::input::MouseState anonymous_namespace{input.cpp}::mouse { }
 
std::string anonymous_namespace{input.cpp}::text_input
 
asw::input::InputDevice anonymous_namespace{input.cpp}::last_device { asw::input::InputDevice::KeyboardMouse }