#include <LSEMouse.h>
List of all members.
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:
-
_fX | Amount to add to the X. |
_fY | Amount 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:
-
_ui64TimeStamp | Current microseconds. |
LSVOID LSE_CALL lse::CMouse::Click |
( |
LSUINT32 |
_ui32Index | ) |
|
Click any mouse button.
- Parameters:
-
_ui32Index | Index 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:
-
_ui64Time | Time 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:
-
_ui32Index | Index 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:
-
_ui32Index | Index 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:
-
_ui32Index | Index 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:
-
_fX | New X position. |
_fY | New 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:
-
_fX | X position. |
_fY | Y position. |
LSVOID LSE_CALL lse::CMouse::Snap |
( |
LSREAL |
_fX, |
|
|
LSREAL |
_fY, |
|
|
LSREAL |
_fRight, |
|
|
LSREAL |
_fBottom |
|
) |
| |
Snap the position to be within a box.
- Parameters:
-
_fX | X extents. |
_fY | Y extents. |
_fRight | Right extents. |
_fBottom | Bottom extents. |
LSVOID LSE_CALL lse::CMouse::UnClick |
( |
LSUINT32 |
_ui32Index | ) |
|
Unlick any mouse button.
- Parameters:
-
_ui32Index | Index of the button to release. |
Member Data Documentation
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.
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.
Size of the history buffer.
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?
The actual time now. Needed for interpolation.
Current interpolated position.
Last interpolated position.
Last position of the cursor.
Temporary position of the cursor.
The documentation for this class was generated from the following file:
- F:/My Projects/LSEngine/Modules/LSEngine/Src/Input/LSEMouse.h