DDraceNetwork Documentation
Loading...
Searching...
No Matches
CInput Class Reference

#include <input.h>

Inheritance diagram for CInput:
[legend]
Collaboration diagram for CInput:
[legend]

Classes

class  CJoystick

Public Member Functions

 CInput ()
void Init () override
int Update () override
void Shutdown () override
void ConsumeEvents (std::function< void(const CEvent &Event)> Consumer) const override
void Clear () override
float GetUpdateTime () const override
bool ModifierIsPressed () const override
bool ShiftIsPressed () const override
bool AltIsPressed () const override
bool KeyIsPressed (int Key) const override
bool KeyPress (int Key) const override
const char * KeyName (int Key) const override
int FindKeyByName (const char *pKeyName) const override
size_t NumJoysticks () const override
CJoystickGetJoystick (size_t Index) override
CJoystickGetActiveJoystick () override
void SetActiveJoystick (size_t Index) override
bool MouseRelative (float *pX, float *pY) override
void MouseModeAbsolute () override
void MouseModeRelative () override
vec2 NativeMousePos () const override
bool NativeMousePressed (int Index) const override
const std::vector< CTouchFingerState > & TouchFingerStates () const override
void ClearTouchDeltas () override
std::string GetClipboardText () override
void SetClipboardText (const char *pText) override
void StartTextInput () override
void StopTextInput () override
void EnsureScreenKeyboardShown () override
const char * GetComposition () const override
bool HasComposition () const override
int GetCompositionCursor () const override
int GetCompositionLength () const override
const char * GetCandidate (int Index) const override
int GetCandidateCount () const override
int GetCandidateSelectedIndex () const override
void SetCompositionWindowPosition (float X, float Y, float H) override
bool GetDropFile (char *aBuf, int Len) override
Public Member Functions inherited from IInput
ECursorType CursorRelative (float *pX, float *pY)
Public Member Functions inherited from IInterface
 IInterface ()
virtual ~IInterface ()=default

Private Member Functions

IEngineGraphicsGraphics () const
IConsoleConsole () const
void InitJoysticks ()
bool OpenJoystick (int JoystickIndex)
void CloseJoysticks ()
void UpdateActiveJoystick ()
float GetJoystickDeadzone ()
void AddKeyEvent (int Key, int Flags)
void AddTextEvent (const char *pText)
void HandleJoystickAxisMotionEvent (const SDL_JoyAxisEvent &Event)
void HandleJoystickButtonEvent (const SDL_JoyButtonEvent &Event)
void HandleJoystickHatMotionEvent (const SDL_JoyHatEvent &Event)
void HandleJoystickAddedEvent (const SDL_JoyDeviceEvent &Event)
void HandleJoystickRemovedEvent (const SDL_JoyDeviceEvent &Event)
void HandleTouchDownEvent (const SDL_TouchFingerEvent &Event)
void HandleTouchUpEvent (const SDL_TouchFingerEvent &Event)
void HandleTouchMotionEvent (const SDL_TouchFingerEvent &Event)
void HandleTextEditingEvent (const char *pText, int Start, int Length)
void ProcessSystemMessage (SDL_SysWMmsg *pMsg)

Static Private Member Functions

static void ConchainJoystickGuidChanged (IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)

Private Attributes

IEngineGraphicsm_pGraphics
IConsolem_pConsole
IConfigManagerm_pConfigManager
std::vector< CJoystickm_vJoysticks
CJoystickm_pActiveJoystick = nullptr
bool m_InputGrabbed
bool m_MouseFocus
std::string m_CompositionString
int m_CompositionCursor
std::vector< std::string > m_vCandidates
int m_CandidateSelectedIndex
std::vector< CEventm_vInputEvents
int64_t m_LastUpdate
float m_UpdateTime
bool m_aCurrentKeyStates [KEY_LAST]
bool m_aFrameKeyStates [KEY_LAST]
uint32_t m_InputCounter
std::vector< CTouchFingerStatem_vTouchFingerStates
char m_aDropFile [IO_MAX_PATH_LENGTH]

Additional Inherited Members

Public Types inherited from IInput
enum  { FLAG_PRESS = 1 << 0 , FLAG_RELEASE = 1 << 1 , FLAG_TEXT = 1 << 2 , FLAG_REPEAT = 1 << 3 }
enum  ECursorType { CURSOR_NONE , CURSOR_MOUSE , CURSOR_JOYSTICK }
Static Public Member Functions inherited from IEngineInput
static const char * InterfaceName ()
Static Public Member Functions inherited from IInput
static const char * InterfaceName ()
Protected Member Functions inherited from IInterface
IKernelKernel ()

Constructor & Destructor Documentation

◆ CInput()

CInput::CInput ( )

Member Function Documentation

◆ AddKeyEvent()

void CInput::AddKeyEvent ( int Key,
int Flags )
private

◆ AddTextEvent()

void CInput::AddTextEvent ( const char * pText)
private

◆ AltIsPressed()

bool CInput::AltIsPressed ( ) const
inlineoverridevirtual

Implements IInput.

◆ Clear()

void CInput::Clear ( )
overridevirtual

Clears the events and KeyPress state for this frame. Must be called at the end of each frame.

Implements IInput.

◆ ClearTouchDeltas()

void CInput::ClearTouchDeltas ( )
overridevirtual

Must be called after the touch finger states have been used during the client update to ensure that touch deltas are only accumulated until the next update. If the touch states are only used during rendering, i.e. for user interfaces, then this is called automatically by calling Clear.

Implements IInput.

◆ CloseJoysticks()

void CInput::CloseJoysticks ( )
private

◆ ConchainJoystickGuidChanged()

void CInput::ConchainJoystickGuidChanged ( IConsole::IResult * pResult,
void * pUserData,
IConsole::FCommandCallback pfnCallback,
void * pCallbackUserData )
staticprivate

◆ Console()

IConsole * CInput::Console ( ) const
inlineprivate

◆ ConsumeEvents()

void CInput::ConsumeEvents ( std::function< void(const CEvent &Event)> Consumer) const
overridevirtual

Implements IInput.

◆ EnsureScreenKeyboardShown()

void CInput::EnsureScreenKeyboardShown ( )
overridevirtual

Implements IInput.

◆ FindKeyByName()

int CInput::FindKeyByName ( const char * pKeyName) const
overridevirtual

Implements IInput.

◆ GetActiveJoystick()

CJoystick * CInput::GetActiveJoystick ( )
inlineoverridevirtual

Implements IInput.

◆ GetCandidate()

const char * CInput::GetCandidate ( int Index) const
inlineoverridevirtual

Implements IInput.

◆ GetCandidateCount()

int CInput::GetCandidateCount ( ) const
inlineoverridevirtual

Implements IInput.

◆ GetCandidateSelectedIndex()

int CInput::GetCandidateSelectedIndex ( ) const
inlineoverridevirtual

Implements IInput.

◆ GetClipboardText()

std::string CInput::GetClipboardText ( )
overridevirtual

Implements IInput.

◆ GetComposition()

const char * CInput::GetComposition ( ) const
inlineoverridevirtual

Implements IInput.

◆ GetCompositionCursor()

int CInput::GetCompositionCursor ( ) const
inlineoverridevirtual

Implements IInput.

◆ GetCompositionLength()

int CInput::GetCompositionLength ( ) const
inlineoverridevirtual

Implements IInput.

◆ GetDropFile()

bool CInput::GetDropFile ( char * aBuf,
int Len )
overridevirtual

Implements IInput.

◆ GetJoystick()

CJoystick * CInput::GetJoystick ( size_t Index)
inlineoverridevirtual

Implements IInput.

◆ GetJoystickDeadzone()

float CInput::GetJoystickDeadzone ( )
private

◆ GetUpdateTime()

float CInput::GetUpdateTime ( ) const
overridevirtual
Returns
Rolling average of the time in seconds between calls of the Update function.

Implements IInput.

◆ Graphics()

IEngineGraphics * CInput::Graphics ( ) const
inlineprivate

◆ HandleJoystickAddedEvent()

void CInput::HandleJoystickAddedEvent ( const SDL_JoyDeviceEvent & Event)
private

◆ HandleJoystickAxisMotionEvent()

void CInput::HandleJoystickAxisMotionEvent ( const SDL_JoyAxisEvent & Event)
private

◆ HandleJoystickButtonEvent()

void CInput::HandleJoystickButtonEvent ( const SDL_JoyButtonEvent & Event)
private

◆ HandleJoystickHatMotionEvent()

void CInput::HandleJoystickHatMotionEvent ( const SDL_JoyHatEvent & Event)
private

◆ HandleJoystickRemovedEvent()

void CInput::HandleJoystickRemovedEvent ( const SDL_JoyDeviceEvent & Event)
private

◆ HandleTextEditingEvent()

void CInput::HandleTextEditingEvent ( const char * pText,
int Start,
int Length )
private

◆ HandleTouchDownEvent()

void CInput::HandleTouchDownEvent ( const SDL_TouchFingerEvent & Event)
private

◆ HandleTouchMotionEvent()

void CInput::HandleTouchMotionEvent ( const SDL_TouchFingerEvent & Event)
private

◆ HandleTouchUpEvent()

void CInput::HandleTouchUpEvent ( const SDL_TouchFingerEvent & Event)
private

◆ HasComposition()

bool CInput::HasComposition ( ) const
inlineoverridevirtual

Implements IInput.

◆ Init()

void CInput::Init ( )
overridevirtual

Implements IEngineInput.

◆ InitJoysticks()

void CInput::InitJoysticks ( )
private

◆ KeyIsPressed()

bool CInput::KeyIsPressed ( int Key) const
overridevirtual

Returns whether the given key is currently pressed down. This directly represents the state of pressed keys based on all handled input events.

This function should be used to trigger behavior continuously while a specific key is held down, e.g. for showing a list of all keys that are currently being pressed.

Parameters
KeyThe key code (see keys.h).
Returns
true if key is currently pressed down, false otherwise.

Implements IInput.

◆ KeyName()

const char * CInput::KeyName ( int Key) const
overridevirtual

Implements IInput.

◆ KeyPress()

bool CInput::KeyPress ( int Key) const
overridevirtual

Returns whether the given key was pressed down during input updates for current frame. This state is cleared at the end of each frame by calling the Clear function.

This function should be used to trigger behavior only once per key press event per frame, e.g. for menu hotkeys that should activate behavior once per key press.

Parameters
KeyThe key code (see keys.h).
Returns
true if key was pressed down during input updates for the current frame, false otherwise.

Implements IInput.

◆ ModifierIsPressed()

bool CInput::ModifierIsPressed ( ) const
inlineoverridevirtual

Implements IInput.

◆ MouseModeAbsolute()

void CInput::MouseModeAbsolute ( )
overridevirtual

Implements IInput.

◆ MouseModeRelative()

void CInput::MouseModeRelative ( )
overridevirtual

Implements IInput.

◆ MouseRelative()

bool CInput::MouseRelative ( float * pX,
float * pY )
overridevirtual

Implements IInput.

◆ NativeMousePos()

vec2 CInput::NativeMousePos ( ) const
overridevirtual

Implements IInput.

◆ NativeMousePressed()

bool CInput::NativeMousePressed ( int Index) const
overridevirtual

Implements IInput.

◆ NumJoysticks()

size_t CInput::NumJoysticks ( ) const
inlineoverridevirtual

Implements IInput.

◆ OpenJoystick()

bool CInput::OpenJoystick ( int JoystickIndex)
private

◆ ProcessSystemMessage()

void CInput::ProcessSystemMessage ( SDL_SysWMmsg * pMsg)
private

◆ SetActiveJoystick()

void CInput::SetActiveJoystick ( size_t Index)
overridevirtual

Implements IInput.

◆ SetClipboardText()

void CInput::SetClipboardText ( const char * pText)
overridevirtual

Implements IInput.

◆ SetCompositionWindowPosition()

void CInput::SetCompositionWindowPosition ( float X,
float Y,
float H )
overridevirtual

Implements IInput.

◆ ShiftIsPressed()

bool CInput::ShiftIsPressed ( ) const
inlineoverridevirtual

Implements IInput.

◆ Shutdown()

void CInput::Shutdown ( )
overridevirtual

Implements IEngineInput.

◆ StartTextInput()

void CInput::StartTextInput ( )
overridevirtual

Implements IInput.

◆ StopTextInput()

void CInput::StopTextInput ( )
overridevirtual

Implements IInput.

◆ TouchFingerStates()

const std::vector< IInput::CTouchFingerState > & CInput::TouchFingerStates ( ) const
overridevirtual

Returns a vector of the states of all touch fingers currently being pressed down on touch devices. Note that this only contains fingers which are pressed down, i.e. released fingers are never stored. The order of the fingers in this vector is based on the order in which the fingers where pressed.

Returns
vector of all touch finger states

Implements IInput.

◆ Update()

int CInput::Update ( )
overridevirtual

Implements IEngineInput.

◆ UpdateActiveJoystick()

void CInput::UpdateActiveJoystick ( )
private

Member Data Documentation

◆ m_aCurrentKeyStates

bool CInput::m_aCurrentKeyStates[KEY_LAST]
private

◆ m_aDropFile

char CInput::m_aDropFile[IO_MAX_PATH_LENGTH]
private

◆ m_aFrameKeyStates

bool CInput::m_aFrameKeyStates[KEY_LAST]
private

◆ m_CandidateSelectedIndex

int CInput::m_CandidateSelectedIndex
private

◆ m_CompositionCursor

int CInput::m_CompositionCursor
private

◆ m_CompositionString

std::string CInput::m_CompositionString
private

◆ m_InputCounter

uint32_t CInput::m_InputCounter
private

◆ m_InputGrabbed

bool CInput::m_InputGrabbed
private

◆ m_LastUpdate

int64_t CInput::m_LastUpdate
private

◆ m_MouseFocus

bool CInput::m_MouseFocus
private

◆ m_pActiveJoystick

CJoystick* CInput::m_pActiveJoystick = nullptr
private

◆ m_pConfigManager

IConfigManager* CInput::m_pConfigManager
private

◆ m_pConsole

IConsole* CInput::m_pConsole
private

◆ m_pGraphics

IEngineGraphics* CInput::m_pGraphics
private

◆ m_UpdateTime

float CInput::m_UpdateTime
private

◆ m_vCandidates

std::vector<std::string> CInput::m_vCandidates
private

◆ m_vInputEvents

std::vector<CEvent> CInput::m_vInputEvents
private

◆ m_vJoysticks

std::vector<CJoystick> CInput::m_vJoysticks
private

◆ m_vTouchFingerStates

std::vector<CTouchFingerState> CInput::m_vTouchFingerStates
private

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