"L. Spiro Engine"
Classes | Public Member Functions | Protected Member Functions | Protected Attributes

lse::CMouse Class Reference

#include <LSEMouse.h>

List of all members.

Classes

struct  LSE_MOUSE_MOVE_POS

Public Member Functions

const CVector2 &LSE_CALL GetPos () const
const CVector2 &LSE_CALL GetLastPos () const
CVector2 LSE_CALL GetDelta () const
LSREAL LSE_CALL GetXDelta () const
LSREAL LSE_CALL GetYDelta () const
const CVector2 &LSE_CALL GetInterpPos () const
const CVector2 &LSE_CALL GetInterpLastPos () const
CVector2 LSE_CALL GetInterpDelta () const
LSREAL LSE_CALL GetInterpXDelta () const
LSREAL LSE_CALL GetInterpYDelta () const
LSVOID LSE_CALL SetPos (LSREAL _fX, LSREAL _fY)
LSVOID LSE_CALL AddPos (LSREAL _fX, LSREAL _fY)
LSVOID LSE_CALL ApplyChanges (LSUINT64 _ui64TimeStamp)
LSVOID LSE_CALL SetStartPos (LSREAL _fX, LSREAL _fY)
LSVOID LSE_CALL Snap (LSREAL _fX, LSREAL _fY, LSREAL _fRight, LSREAL _fBottom)
LSVOID LSE_CALL Click (LSUINT32 _ui32Index)
LSVOID LSE_CALL UnClick (LSUINT32 _ui32Index)
LSBOOL LSE_CALL IsMouseButtonDown (LSUINT32 _ui32Index) const
LSBOOL LSE_CALL MouseButtonJustPressed (LSUINT32 _ui32Index) const
LSBOOL LSE_CALL MouseButtonJustReleased (LSUINT32 _ui32Index) const
LSVOID LSE_CALL ResetClicks ()
const LSINT16 *LSE_CALL GetIndexMap () const

Protected Member Functions

LSUINT64 LSE_CALL GetMostRecentHistoryTime () const
LSUINT32 LSE_CALL FindTimeStampByTime (LSUINT64 _ui64Time) const
CVector2 LSE_CALL GetInterpolatedPos () const

Protected Attributes

CVector2 m_vPos
CVector2 m_vTempPos
CVector2 m_vLastPos
CVector2 m_vInterpPos
CVector2 m_vLastInterpPos
LSE_MOUSE_MOVE_POS m_mmpHistory [50]
LSUINT32 m_ui32HistorySize: 30
LSUINT32 m_ui32UpdateMoveBuffer: 2
LSUINT32 m_ui32InterpTime
LSUINT64 m_ui64TimeNow
LSINT32 m_i32ClickCountBuffer [3]
LSINT32 m_i32ClickCount [3]
LSINT32 m_i32UnClickCount [3]
LSINT32 m_i32LastClickState [3]
LSINT16 m_i16IndexMap [3]

Detailed Description

Class CMouse

Description: Track mouse movements.


Member Function Documentation

LSVOID LSE_CALL lse::CMouse::AddPos ( LSREAL  _fX,
LSREAL  _fY 
)

Update the position. This only updates m_vTempPos. The changes are applied only after a call to ApplyChanges().

Parameters:
_fXAmount to add to the X.
_fYAmount to add to the Y.
LSVOID LSE_CALL lse::CMouse::ApplyChanges ( LSUINT64  _ui64TimeStamp)

Applies changes made to the position/state of the mouse. Supply the current time in microseconds. The time should be absolute, not relative.

Parameters:
_ui64TimeStampCurrent microseconds.
LSVOID LSE_CALL lse::CMouse::Click ( LSUINT32  _ui32Index)

Click any mouse button.

Parameters:
_ui32IndexIndex of the button to click.
LSE_INLINE LSUINT32 LSE_CALL lse::CMouse::FindTimeStampByTime ( LSUINT64  _ui64Time) const [protected]

Get the index of the first history item whose timestamp is over or equal to the given timestamp. Returns __LSE_MOUSE_SMOOTH_HISTORY__ on failure.

Parameters:
_ui64TimeTime of the index of the history item to find.
Returns:
Returns the index of the first history item whose timestamp is over or equal to the given timestamp
LSE_INLINE CVector2 LSE_CALL lse::CMouse::GetDelta ( ) const

Get the delta since the last position.

Returns:
Returns the delta since the last position.
LSE_INLINE const LSINT16 *LSE_CALL lse::CMouse::GetIndexMap ( ) const

Get the index map. Used when applying a click or unclick using index mapping.

Returns:
Returns the index map.
LSE_INLINE CVector2 LSE_CALL lse::CMouse::GetInterpDelta ( ) const

Get the delta since the last interpolated (smoothened) position.

Returns:
Returns the delta since the last interpolated position.
LSE_INLINE const CVector2 &LSE_CALL lse::CMouse::GetInterpLastPos ( ) const

Get the last interpolated (smoothened) position of the cursor.

Returns:
Returns the last interpolated position of the cursor.
LSE_INLINE CVector2 LSE_CALL lse::CMouse::GetInterpolatedPos ( ) const [protected]

Get the interpolated mouse position. Uses m_ui32InterpTime and the history stack. If there is none, or the time is beyond the stack, returns m_vPos.

Returns:
Returns the interpolated mouse position.
LSE_INLINE const CVector2 &LSE_CALL lse::CMouse::GetInterpPos ( ) const

Get the interpolated (smoothened) position of the cursor.

Returns:
Returns the interpolated position of the cursor.
LSE_INLINE LSREAL LSE_CALL lse::CMouse::GetInterpXDelta ( ) const

Get only the X delta of the interpolated (smoothened) position.

Returns:
Returns only the X delta of the interpolated position.
LSE_INLINE LSREAL LSE_CALL lse::CMouse::GetInterpYDelta ( ) const

Get only the Y delta of the interpolated (smoothened) position.

Returns:
Returns only the Y delta of the interpolated position.
LSE_INLINE const CVector2 &LSE_CALL lse::CMouse::GetLastPos ( ) const

Get the last position of the cursor.

Returns:
Returns the last position of the cursor.
LSE_INLINE LSUINT64 LSE_CALL lse::CMouse::GetMostRecentHistoryTime ( ) const [protected]

Get the most recent time in the history stack.

Returns:
Returns the most recent time in the history stack.
LSE_INLINE const CVector2 &LSE_CALL lse::CMouse::GetPos ( ) const

Get the position of the cursor.

Returns:
Returns the position of the cursor.
LSE_INLINE LSREAL LSE_CALL lse::CMouse::GetXDelta ( ) const

Get only the X delta.

Returns:
Returns only the X delta.
LSE_INLINE LSREAL LSE_CALL lse::CMouse::GetYDelta ( ) const

Get only the Y delta.

Returns:
Returns only the Y delta.
LSE_INLINE LSBOOL LSE_CALL lse::CMouse::IsMouseButtonDown ( LSUINT32  _ui32Index) const

Is a mouse button down?

Parameters:
_ui32IndexIndex of the mouse button to test for being down.
Returns:
Returns true if the button at the given index is down.
LSE_INLINE LSBOOL LSE_CALL lse::CMouse::MouseButtonJustPressed ( LSUINT32  _ui32Index) const

Was a mouse button just pressed?

Parameters:
_ui32IndexIndex of the mouse button to test for being pressed.
Returns:
Returns true if the button at the given index was just pressed.
LSE_INLINE LSBOOL LSE_CALL lse::CMouse::MouseButtonJustReleased ( LSUINT32  _ui32Index) const

Was a mouse button just released?

Parameters:
_ui32IndexIndex of the mouse button to test for being released.
Returns:
Returns true if the button at the given index was just released.
LSE_INLINE LSVOID LSE_CALL lse::CMouse::ResetClicks ( )

Reset mouse clicks. Done when the game loses focus. Prevents buttons from being held indefinitely.

LSVOID LSE_CALL lse::CMouse::SetPos ( LSREAL  _fX,
LSREAL  _fY 
)

Update the position. This only updates m_vTempPos. The changes are applied only after a call to ApplyChanges().

Parameters:
_fXNew X position.
_fYNew Y position.
LSVOID LSE_CALL lse::CMouse::SetStartPos ( LSREAL  _fX,
LSREAL  _fY 
)

Set the starting position of the mouse. Updates m_vPos, m_vTempPos, and m_vLastPos to that position.

Parameters:
_fXX position.
_fYY position.
LSVOID LSE_CALL lse::CMouse::Snap ( LSREAL  _fX,
LSREAL  _fY,
LSREAL  _fRight,
LSREAL  _fBottom 
)

Snap the position to be within a box.

Parameters:
_fXX extents.
_fYY extents.
_fRightRight extents.
_fBottomBottom extents.
LSVOID LSE_CALL lse::CMouse::UnClick ( LSUINT32  _ui32Index)

Unlick any mouse button.

Parameters:
_ui32IndexIndex of the button to release.

Member Data Documentation

LSINT32 lse::CMouse::m_i32ClickCountBuffer[3] [protected]

Click count. If non-zero the mouse is clicking. Buttons are numbered. By default, on Windows, left = 0, middle = 1, and right = 2, but a mapping system in the engine allows this to be changed. This allows your game to define mouse button 0 as the activation button, but map the right mouse button to index 0 so that the right mouse button causes activation in your game.

LSINT32 lse::CMouse::m_i32UnClickCount[3] [protected]

It is theoretically possible for the user to click and unclick between frames, in which case no click event would be detected. We store the unclicks separately and update each frame in the game loop.

History of positions, used for mouse smoothening.

LSUINT32 lse::CMouse::m_ui32HistorySize [protected]

Size of the history buffer.

LSUINT32 lse::CMouse::m_ui32InterpTime [protected]

How far behind does our mouse lag? The mouse lags behind a bit so it can interpolate between the previous 2 positions. The lag time should be exactly (or as close as possible to) the time between mouse updates. That is, if Windows (for example) is updating our mouse position every 30 milliseconds, our lag time should be 30,000 microseconds, so that as soon as it interpolates to the end of the list of moves, a new move is added by Windows and interpolation will continue smoothly to it (over the course of 30 milliseconds). If the time is set too low (for example 0 microseconds) then the interpolation will be reach the end of the list of movements before the next movement is added to the list, causing some jerkiness. If the time is set too high, the level of smoothness between positions will not increase (no benefit), but there will be more noticable lag between the player motion and the in-game response. Defaults to 8000 microseconds.

Does our history buffer need updating at the next frame?

LSUINT64 lse::CMouse::m_ui64TimeNow [protected]

The actual time now. Needed for interpolation.

CVector2 lse::CMouse::m_vInterpPos [protected]

Current interpolated position.

CVector2 lse::CMouse::m_vLastInterpPos [protected]

Last interpolated position.

CVector2 lse::CMouse::m_vLastPos [protected]

Last position of the cursor.

CVector2 lse::CMouse::m_vPos [protected]

Position of the cursor.

CVector2 lse::CMouse::m_vTempPos [protected]

Temporary position of the cursor.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator