Hymn to Beauty
C++ 3D Engine
InputManager Class Reference

#include <InputManager.hpp>

Public Types

enum  Button {
  PLAYTEST = 0 , PROFILE , WINDOWMODE , CONTROL ,
  NEW , OPEN , SAVE , CAMERA ,
  FORWARD , BACKWARD , LEFT , RIGHT ,
  ZOOM , SELECT , FOCUS , W ,
  E , R , BUTTONS
}
 Button codes. More...
 
enum  Device { KEYBOARD = 0 , MOUSE , INPUT_DEVICES }
 Input device codes. More...
 

Public Member Functions

void Update ()
 Update input state. More...
 
double GetCursorX () const
 Get cursor's horizontal position. More...
 
double GetCursorY () const
 Get cursor's vertical position. More...
 
glm::vec2 GetCursorXY () const
 Get cursor's coordinates. More...
 
bool GetScrollUp () const
 Get whether user has moved scroll wheel up. More...
 
bool GetScrollDown () const
 Get whether user has moved scroll wheel down. More...
 
void AssignButton (Button button, Device device, int index)
 Assign a button binding. More...
 
bool Pressed (Button button) const
 Gets whether a button is currently down. More...
 
bool Triggered (Button button) const
 Gets whether a button was just pressed. More...
 
void CharacterCallback (unsigned int codePoint)
 GLFW character callback. More...
 
void ScrollCallback (double yOffset)
 GLFW scrolling callback. More...
 

Friends

class Hub
 

Detailed Description

Handles input devices.

Todo:
Android

Member Enumeration Documentation

◆ Button

Button codes.

Enumerator
PLAYTEST 

Start/stop playtesting the game.

PROFILE 

Show profiling information.

WINDOWMODE 

Toggle window mode.

CONTROL 

Control key.

NEW 

Create new hymn.

OPEN 

Open existing hymn.

SAVE 

Save opened hymn.

CAMERA 

Move camera.

FORWARD 

Move forward.

BACKWARD 

Move backward.

LEFT 

Move left.

RIGHT 

Move right.

ZOOM 

Zoom to entity.

SELECT 

Select object.

FOCUS 

Focus on selected object.

Key for activating the translation operation in widget.

Key for activating the rotation operation in widget.

Key for activating the scale operation in widget.

BUTTONS 

Total number of inputs.

◆ Device

Input device codes.

Enumerator
KEYBOARD 

Keyboard input.

MOUSE 

Mouse buttons.

INPUT_DEVICES 

Number of input devices.

Member Function Documentation

◆ AssignButton()

void InputManager::AssignButton ( Button  button,
Device  device,
int  index 
)

Assign a button binding.

See GLFW keyboard documentation for indices for keys. For mouse buttons, either GLFW_MOUSE_BUTTON_LEFT, GLFW_MOUSE_BUTTON_RIGHT or GLFW_MOUSE_BUTTON_MIDDLE.

Parameters
buttonWhich button to bind.
deviceWhich device (KEYBOARD or MOUSE).
indexIndex of the key.

◆ CharacterCallback()

void InputManager::CharacterCallback ( unsigned int  codePoint)

GLFW character callback.

Parameters
codePointUnicode code point.

◆ GetCursorX()

double InputManager::GetCursorX ( ) const

Get cursor's horizontal position.

Returns
X-position of the cursor

◆ GetCursorXY()

glm::vec2 InputManager::GetCursorXY ( ) const

Get cursor's coordinates.

Returns
X- and Y-position of the cursor

◆ GetCursorY()

double InputManager::GetCursorY ( ) const

Get cursor's vertical position.

Returns
Y-position of the cursor

◆ GetScrollDown()

bool InputManager::GetScrollDown ( ) const

Get whether user has moved scroll wheel down.

Returns
Whether user has scrolled down

◆ GetScrollUp()

bool InputManager::GetScrollUp ( ) const

Get whether user has moved scroll wheel up.

Returns
Whether user has scrolled up

◆ Pressed()

bool InputManager::Pressed ( Button  button) const

Gets whether a button is currently down.

Parameters
buttonThe button to check.
Returns
Whether the button is down

◆ ScrollCallback()

void InputManager::ScrollCallback ( double  yOffset)

GLFW scrolling callback.

Parameters
yOffsetOffset along the Y-axis.

◆ Triggered()

bool InputManager::Triggered ( Button  button) const

Gets whether a button was just pressed.

Checks whether a button was pressed between the last two calls to update().

Parameters
buttonThe button to check.
Returns
Whether the button was pressed

◆ Update()

void InputManager::Update ( )

Update input state.

Friends And Related Function Documentation

◆ Hub

friend class Hub
friend

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