Avara3D 0.2.0
C++ API reference
a3d::DesktopInputContext Class Referenceabstract

Exposes keyboard, pointer-button, pointer-motion, and scroll state. More...

#include <a3d/input/DesktopInputContext.h>

Inheritance diagram for a3d::DesktopInputContext:
[legend]

Public Types

enum class  Key : int
 Identifies keyboard keys reported by desktop-style input contexts. More...
 
enum class  MouseButton : int
 Identifies one of up to eight pointer buttons. More...
 
- Public Types inherited from a3d::InputContext
using DidUpdateCallback = std::function< void(InputContext &inputContext, const UpdateInfo &info)>
 Callback invoked after input state has been updated for the current Runner host update. More...
 

Public Member Functions

 DesktopInputContext ()
 Creates a DesktopInputContext with no active input state. More...
 
bool keyDown (Key key)
 Returns whether key is currently held down. More...
 
bool mouseButtonDown (MouseButton button)
 Returns whether button is currently held down. More...
 
bool keyPressed (Key key)
 Returns and consumes an unread press transition for key. More...
 
bool mouseButtonPressed (MouseButton button)
 Returns and consumes an unread press transition for button. More...
 
bool keyReleased (Key key)
 Returns and consumes an unread release transition for key. More...
 
bool mouseButtonReleased (MouseButton button)
 Returns and consumes an unread release transition for button. More...
 
std::unordered_set< KeykeysDown ()
 Returns a copy of all keys currently held down. More...
 
std::unordered_set< MouseButtonmouseButtonsDown ()
 Returns a copy of all pointer buttons currently held down. More...
 
std::unordered_set< KeykeysPressed ()
 Returns and consumes all currently unread key-press transitions. More...
 
std::unordered_set< MouseButtonmouseButtonsPressed ()
 Returns and consumes all currently unread pointer-button press transitions. More...
 
const math::vec2mousePosition () const
 Returns the current pointer position in logical viewport coordinates. More...
 
const math::vec2mousePositionDelta () const
 Returns pointer displacement observed during the current input update. More...
 
const math::vec2mouseScrollWheelDelta () const
 Returns scroll displacement observed during the current input update. More...
 
- Public Member Functions inherited from a3d::InputContext
 InputContext ()
 Creates an InputContext with no did-update callback. More...
 
DidUpdateCallback didUpdateCallback () const
 Returns the callback invoked after each input update. More...
 
void didUpdateCallback (DidUpdateCallback callback)
 Sets the did-update callback; an empty callback disables it. More...
 

Detailed Description

Exposes keyboard, pointer-button, pointer-motion, and scroll state.

Applications normally obtain a compatible DesktopInputContext from Window::InputContext() and install it on a Scene. Down-state queries are persistent, while pressed and released queries consume unread transitions. Pointer and scroll deltas describe the most recently completed input update.

Definition at line 27 of file DesktopInputContext.h.

Member Enumeration Documentation

◆ Key

enum class a3d::DesktopInputContext::Key : int
strong

Identifies keyboard keys reported by desktop-style input contexts.

Definition at line 33 of file DesktopInputContext.h.

◆ MouseButton

enum class a3d::DesktopInputContext::MouseButton : int
strong

Identifies one of up to eight pointer buttons.

Definition at line 160 of file DesktopInputContext.h.

Constructor & Destructor Documentation

◆ DesktopInputContext()

a3d::DesktopInputContext::DesktopInputContext ( )

Creates a DesktopInputContext with no active input state.

Member Function Documentation

◆ keyDown()

bool a3d::DesktopInputContext::keyDown ( Key  key)

Returns whether key is currently held down.

◆ keyPressed()

bool a3d::DesktopInputContext::keyPressed ( Key  key)

Returns and consumes an unread press transition for key.

◆ keyReleased()

bool a3d::DesktopInputContext::keyReleased ( Key  key)

Returns and consumes an unread release transition for key.

◆ keysDown()

std::unordered_set< Key > a3d::DesktopInputContext::keysDown ( )

Returns a copy of all keys currently held down.

◆ keysPressed()

std::unordered_set< Key > a3d::DesktopInputContext::keysPressed ( )

Returns and consumes all currently unread key-press transitions.

◆ mouseButtonDown()

bool a3d::DesktopInputContext::mouseButtonDown ( MouseButton  button)

Returns whether button is currently held down.

◆ mouseButtonPressed()

bool a3d::DesktopInputContext::mouseButtonPressed ( MouseButton  button)

Returns and consumes an unread press transition for button.

◆ mouseButtonReleased()

bool a3d::DesktopInputContext::mouseButtonReleased ( MouseButton  button)

Returns and consumes an unread release transition for button.

◆ mouseButtonsDown()

std::unordered_set< MouseButton > a3d::DesktopInputContext::mouseButtonsDown ( )

Returns a copy of all pointer buttons currently held down.

◆ mouseButtonsPressed()

std::unordered_set< MouseButton > a3d::DesktopInputContext::mouseButtonsPressed ( )

Returns and consumes all currently unread pointer-button press transitions.

◆ mousePosition()

const math::vec2 & a3d::DesktopInputContext::mousePosition ( ) const

Returns the current pointer position in logical viewport coordinates.

The origin is the upper-left corner; positive X points right and positive Y points down.

◆ mousePositionDelta()

const math::vec2 & a3d::DesktopInputContext::mousePositionDelta ( ) const

Returns pointer displacement observed during the current input update.

Positive X is rightward motion and positive Y is upward motion. The value is reset from newly accumulated pointer events on each input update.

◆ mouseScrollWheelDelta()

const math::vec2 & a3d::DesktopInputContext::mouseScrollWheelDelta ( ) const

Returns scroll displacement observed during the current input update.


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