![]() |
ezEngine Release 26.9
|
#include <MouseKeyboard.h>

Public Member Functions | |
| void | SetShowMouseCursor (bool bShow) |
| bool | GetShowMouseCursor () const |
| virtual ezUInt32 | GetHardwareCursorSize () const |
| void | SetClipMouseCursor (ezMouseCursorClipMode::Enum mode) |
| ezMouseCursorClipMode::Enum | GetClipMouseCursor () const |
| virtual void | SetDisableOSHotkeys (bool bDisable) |
| bool | GetDisableOSHotkeys () const |
| Returns whether OS hotkey suppression is currently requested. | |
| virtual void | SetMouseSpeed (const ezVec2 &vScale) |
| Sets the scaling factor that is applied on all (relative) mouse input. | |
| ezVec2 | GetMouseSpeed () const |
| Returns the scaling factor that is applied on all (relative) mouse input. | |
| bool | IsMouseOver () const |
| Returns the number of the ezWindow over which the mouse moved last. | |
| bool | IsFocused () |
| Returns if the associated ezWindow has focus. | |
| ezVec2 | GetLocalMouseCoordinates () const |
Public Member Functions inherited from ezInputDevice | |
| ezInputDevice () | |
| Default Constructor. | |
| float | GetInputSlotState (ezStringView sSlot) const |
| Allows to query current input values for the given slot. | |
| bool | HasDeviceBeenUsedLastFrame () const |
| Returns true, if the device was 'used' during the last frame, ie. when it generated input due to some user interaction. | |
Public Member Functions inherited from ezReflectedClass | |
| virtual const ezRTTI * | GetDynamicRTTI () const |
| bool | IsInstanceOf (const ezRTTI *pType) const |
| Returns whether the type of this instance is of the given type or derived from it. | |
| template<typename T > | |
| EZ_ALWAYS_INLINE bool | IsInstanceOf () const |
| Returns whether the type of this instance is of the given type or derived from it. | |
Protected Member Functions | |
| virtual void | UpdateInputSlotValues () override |
| Override this, if you need to query the state of the hardware to update the input slots. | |
| virtual void | ApplyShowMouseCursor (bool bShow, bool bCustomCursorActive)=0 |
| virtual void | ApplyClipMouseCursor (ezMouseCursorClipMode::Enum mode)=0 |
| Platform implementation of confining the OS cursor. | |
| void | UpdateEffectiveMouseCursorState () |
Protected Member Functions inherited from ezInputDevice | |
| virtual void | InitializeDevice ()=0 |
| Override this if you need to do device specific initialization before the first use. | |
| virtual void | ResetInputSlotValues () |
| Override this, if you need to reset certain input slot values to zero, after the ezInputManager is finished with the current frame update. | |
| virtual void | RegisterInputSlots ()=0 |
| Override this to register all the input slots that this device exposes. | |
| virtual void | UpdateHardwareState (ezTime tTimeDifference) |
| This function is called once after ezInputManager::Update with the same time delta value. It allows to update hardware state, such as the vibration of gamepad motors. | |
Protected Attributes | |
| ezTime | m_DoubleClickTime = ezTime::MakeFromMilliseconds(500) |
| ezVec2 | m_vLocalMouseCoordinates = ezVec2(0.0f) |
| bool | m_bDisableOSHotkeys = false |
| bool | m_bShowMouseCursorDesired = true |
| ezMouseCursorClipMode::Enum | m_ClipModeDesired = ezMouseCursorClipMode::NoClip |
| bool | m_bShowMouseCursorEffective = true |
| ezMouseCursorClipMode::Enum | m_ClipModeEffective = ezMouseCursorClipMode::NoClip |
Protected Attributes inherited from ezInputDevice | |
| bool | m_bOverridesAbsoluteInput = false |
| Whether this device is authoritative for absolute-value slots (a position, not a delta) it writes, such as the mouse position - see ezInputManager::GatherDeviceInputSlotValues(). | |
| ezMap< ezString, float > | m_InputSlotValues |
| Stores all the values for all input slots that this device handles. | |
| ezStringBuilder | m_sLastCharacters |
| If this input device type handles character input, append every typed character (Unicode codepoint) it receives to this, one Append() call per character event. Append rather than overwrite, so several characters typed within one frame - which happens whenever the OS delivers input faster than the game updates - are all preserved instead of all but the last being silently dropped. The ezInputManager calls RetrieveLastCharacters() to query what the user typed since the last update. | |
Protected Attributes inherited from ezEnumerable< ezInputDevice, ezReflectedClass > | |
| ezEnumerable * | m_pNextInstance |
Static Protected Attributes | |
| static ezInputDevice * | s_pMouseOver = nullptr |
Friends | |
| class | ezInputManager |
Additional Inherited Members | |
Static Public Member Functions inherited from ezNoBase | |
| static const ezRTTI * | GetStaticRTTI () |
Static Protected Member Functions inherited from ezInputDevice | |
| static void | RegisterInputSlot (ezStringView sName, ezStringView sDefaultDisplayName, ezBitflags< ezInputSlotFlags > SlotFlags) |
| Calls RegisterInputSlot() on the ezInputManager and passes the parameters through. | |
This is the base class for all input devices that handle mouse and keyboard input.
This class is derived from ezInputDevice but adds interface functions to handle mouse and keyboard input. It is typically instantiated on a per-window basis.
|
protectedpure virtual |
Platform implementation of confining the OS cursor.
Implemented in ezInputDeviceMouseKeyboard_NoImpl, and ezInputDeviceMouseKeyboard_Win.
|
protectedpure virtual |
Platform implementation of showing / hiding the OS cursor.
Called by the base class only, and only when the effective state actually changed, so implementations don't need to filter out redundant calls themselves.
| bShow | The state to apply. |
| bCustomCursorActive | Whether the cursor is hidden because a custom ('software') cursor is drawn instead. In that case the mouse must keep reporting absolute in-window positions, ie. the cursor may be hidden, but must not be captured. |
Implemented in ezInputDeviceMouseKeyboard_NoImpl, and ezInputDeviceMouseKeyboard_Win.
|
inline |
Returns how the application wants the mouse to be confined to the window.
This ignores any overrides, ie. it returns exactly what was passed to SetClipMouseCursor().
|
inlinevirtual |
Returns the edge length of the operating system's mouse cursor, in pixels.
This takes both the display's DPI scaling and the user's mouse pointer size setting into account, so it is the value to use to render a custom cursor at the size that the user expects, independent of resolution, window size and monitor.
Returns 0 if the platform can't report it.
Querying this involves system calls. Prefer ezInputManager::GetHardwareCursorSize(), which caches the value and provides a fallback.
Reimplemented in ezInputDeviceMouseKeyboard_Win.
|
inline |
Returns the current (normalized) mouse position within the window.
Coordinates are in [0; 1] range ([0,0] = top left, [1,1] = bottom right of the window).
|
inline |
Returns whether the application wants the mouse cursor to be shown.
This ignores any overrides, ie. it returns exactly what was passed to SetShowMouseCursor().
| void ezInputDeviceMouseKeyboard::SetClipMouseCursor | ( | ezMouseCursorClipMode::Enum | mode | ) |
Will trap the mouse inside the application window. Should usually be enabled, to prevent accidental task switches.
Especially on multi-monitor systems, the mouse can easily leave the application window (even in fullscreen mode). Do NOT use this function when you have multiple windows and require absolute mouse positions.
Like SetShowMouseCursor(), this only stores what the application wants. Overlay UI may temporarily force ezMouseCursorClipMode::NoClip.
|
inlinevirtual |
If enabled, the OS will not handle system hotkeys (e.g. the Windows key) while this device is active.
Can be called before or after device initialization. On platforms that support it, calling this after initialization will re-register the input device with the updated setting.
Reimplemented in ezInputDeviceMouseKeyboard_Win.
| void ezInputDeviceMouseKeyboard::SetShowMouseCursor | ( | bool | bShow | ) |
Shows or hides the mouse cursor inside the application window.
This only stores what the application wants. Overlay UI (such as the in-game console) may temporarily override this through ezInputManager::PushMouseCursorOverride(), and a custom ('software') cursor (see ezInputManager::SetMouseCursor()) hides the OS cursor as well. Once those no longer apply, the state set here is restored automatically, so callers never need to save and restore it themselves.
|
protected |
Recomputes the effective cursor state from the desired state and the overrides that are registered at the ezInputManager, and forwards it to the platform, if it changed.
|
overrideprotectedvirtual |
Override this, if you need to query the state of the hardware to update the input slots.
Implements ezInputDevice.
Reimplemented in ezInputDeviceMouseKeyboard_Win.