Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
JoystickController Class Reference

#include <joystick_controller.h>

+ Collaboration diagram for JoystickController:

Public Member Functions

 JoystickController ()
 
void onJoystickConnect (const std::vector< irr::SJoystickInfo > &joystick_infos)
 
bool handleEvent (const irr::SEvent::SJoystickEvent &ev)
 
void clear ()
 
void releaseAllKeys ()
 
bool wasKeyDown (GameKeyType b)
 
bool wasKeyReleased (GameKeyType b)
 
void clearWasKeyReleased (GameKeyType b)
 
bool wasKeyPressed (GameKeyType b)
 
void clearWasKeyPressed (GameKeyType b)
 
bool isKeyDown (GameKeyType b)
 
s16 getAxis (JoystickAxis axis)
 
float getAxisWithoutDead (JoystickAxis axis)
 
float getMovementDirection ()
 
float getMovementSpeed ()
 
u8 getJoystickId () const
 

Public Attributes

f32 doubling_dtime
 

Private Member Functions

void setLayoutFromControllerName (const std::string &name)
 

Private Attributes

JoystickLayout m_layout
 
s16 m_axes_vals [JA_COUNT]
 
u8 m_joystick_id = 0
 
std::bitset< KeyType::INTERNAL_ENUM_COUNTm_keys_down
 
std::bitset< KeyType::INTERNAL_ENUM_COUNTm_keys_pressed
 
f32 m_internal_time
 
f32 m_past_pressed_time [KeyType::INTERNAL_ENUM_COUNT]
 
std::bitset< KeyType::INTERNAL_ENUM_COUNTm_past_keys_pressed
 
std::bitset< KeyType::INTERNAL_ENUM_COUNTm_keys_released
 

Constructor & Destructor Documentation

◆ JoystickController()

JoystickController::JoystickController ( )

References JoystickLayout::axes_deadzone, clear(), doubling_dtime, g_settings, Settings::getFloat(), m_layout, and m_past_pressed_time.

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void JoystickController::clear ( )

References m_axes_vals, m_keys_down, m_keys_pressed, m_keys_released, and m_past_keys_pressed.

Referenced by JoystickController(), and RealInputHandler::clear().

+ Here is the caller graph for this function:

◆ clearWasKeyPressed()

void JoystickController::clearWasKeyPressed ( GameKeyType b)
inline

References m_keys_pressed.

Referenced by Game::processPlayerInteraction().

+ Here is the caller graph for this function:

◆ clearWasKeyReleased()

void JoystickController::clearWasKeyReleased ( GameKeyType b)
inline

References m_keys_released.

Referenced by Game::processPlayerInteraction().

+ Here is the caller graph for this function:

◆ getAxis()

s16 JoystickController::getAxis ( JoystickAxis axis)
inline

References m_axes_vals.

◆ getAxisWithoutDead()

float JoystickController::getAxisWithoutDead ( JoystickAxis axis)

References JoystickLayout::axes_deadzone, m_axes_vals, and m_layout.

Referenced by getMovementDirection(), getMovementSpeed(), and Game::updateCameraOrientation().

+ Here is the caller graph for this function:

◆ getJoystickId()

u8 JoystickController::getJoystickId ( ) const
inline

References m_joystick_id.

Referenced by GUIFormSpecMenu::preprocessEvent().

+ Here is the caller graph for this function:

◆ getMovementDirection()

float JoystickController::getMovementDirection ( )

References getAxisWithoutDead(), JA_FORWARD_MOVE, and JA_SIDEWARD_MOVE.

Referenced by RealInputHandler::getJoystickDirection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMovementSpeed()

float JoystickController::getMovementSpeed ( )

References getAxisWithoutDead(), JA_FORWARD_MOVE, and JA_SIDEWARD_MOVE.

Referenced by RealInputHandler::getJoystickSpeed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleEvent()

bool JoystickController::handleEvent ( const irr::SEvent::SJoystickEvent & ev)

References JoystickLayout::axes, JoystickAxisLayout::axis_id, JoystickLayout::axis_keys, JoystickLayout::button_keys, doubling_dtime, porting::getTimeMs(), KeyType::INTERNAL_ENUM_COUNT, JoystickAxisLayout::invert, JA_COUNT, m_axes_vals, m_internal_time, m_joystick_id, m_keys_down, m_keys_pressed, m_keys_released, m_layout, m_past_keys_pressed, and m_past_pressed_time.

Referenced by MyEventReceiver::OnEvent(), and GUIFormSpecMenu::preprocessEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isKeyDown()

bool JoystickController::isKeyDown ( GameKeyType b)
inline

References m_keys_down.

Referenced by RealInputHandler::isKeyDown().

+ Here is the caller graph for this function:

◆ onJoystickConnect()

void JoystickController::onJoystickConnect ( const std::vector< irr::SJoystickInfo > & joystick_infos)

References g_settings, Settings::get(), Settings::getS32(), m_joystick_id, rangelim, and setLayoutFromControllerName().

Referenced by ClientLauncher::init_input().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ releaseAllKeys()

void JoystickController::releaseAllKeys ( )
inline

References m_keys_down, and m_keys_released.

Referenced by RealInputHandler::releaseAllKeys().

+ Here is the caller graph for this function:

◆ setLayoutFromControllerName()

void JoystickController::setLayoutFromControllerName ( const std::string & name)
private

References create_default_layout(), create_dragonrise_gamecube_layout(), create_xbox_layout(), lowercase(), and m_layout.

Referenced by onJoystickConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wasKeyDown()

bool JoystickController::wasKeyDown ( GameKeyType b)
inline

References m_past_keys_pressed.

Referenced by GUIFormSpecMenu::preprocessEvent(), and RealInputHandler::wasKeyDown().

+ Here is the caller graph for this function:

◆ wasKeyPressed()

bool JoystickController::wasKeyPressed ( GameKeyType b)
inline

References m_keys_pressed.

Referenced by RealInputHandler::wasKeyPressed().

+ Here is the caller graph for this function:

◆ wasKeyReleased()

bool JoystickController::wasKeyReleased ( GameKeyType b)
inline

References m_keys_released.

Referenced by RealInputHandler::wasKeyReleased().

+ Here is the caller graph for this function:

Member Data Documentation

◆ doubling_dtime

f32 JoystickController::doubling_dtime

Referenced by JoystickController(), and handleEvent().

◆ m_axes_vals

s16 JoystickController::m_axes_vals[JA_COUNT]
private

◆ m_internal_time

f32 JoystickController::m_internal_time
private

Referenced by handleEvent().

◆ m_joystick_id

u8 JoystickController::m_joystick_id = 0
private

◆ m_keys_down

std::bitset<KeyType::INTERNAL_ENUM_COUNT> JoystickController::m_keys_down
private

◆ m_keys_pressed

std::bitset<KeyType::INTERNAL_ENUM_COUNT> JoystickController::m_keys_pressed
private

◆ m_keys_released

std::bitset<KeyType::INTERNAL_ENUM_COUNT> JoystickController::m_keys_released
private

◆ m_layout

JoystickLayout JoystickController::m_layout
private

◆ m_past_keys_pressed

std::bitset<KeyType::INTERNAL_ENUM_COUNT> JoystickController::m_past_keys_pressed
private

Referenced by clear(), handleEvent(), and wasKeyDown().

◆ m_past_pressed_time

f32 JoystickController::m_past_pressed_time[KeyType::INTERNAL_ENUM_COUNT]
private

Referenced by JoystickController(), and handleEvent().


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