BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
Input Class Reference

Public Member Functions

void SetMouseInputMode (GLFWwindow *window, MouseInputMode newMode)
 Sets the mouse input mode to the given mode.
 
void SetMouseRotFunction (std::function< void(const glm::vec3 &delta)> func)
 Sets the callback function that runs whenever the mouse moves in rotation mode.
 
void SetMouseZoomFunction (std::function< void(const glm::vec3 &delta)> func)
 Sets the callback function that runs whenever the mouse moves in zoom mode.
 
void SetMouseMoveFunction (std::function< void(const glm::vec3 &delta)> func)
 Sets the callback function that runs whenever the mouse moves in move mode.
 
bool PressKey (const std::string &keyCode, int mods)
 Presses the given key with the given mod bits.
 
bool UnPressKey (const std::string &keyCode)
 Unpresses the given key.
 
bool IsKeyPressed (const std::string &keyCode) const
 Returns whether the given key is pressed or not.
 
void RunCommand (const std::string &command)
 Runs the command with the given name if it exists.
 
void AddCommand (const std::string &name, ICommand *command)
 Adds the given command to the command list.
 
int GeyKeyMods (const std::string &keyCode) const
 Returns the modifier keys of the pressed key.
 
void KeyCallback (GLFWwindow *window, int key, int scancode, int action, int mods)
 Handles keyboard key interactions.
 
void MouseButtonCallback (GLFWwindow *window, int button, int action, int mods)
 Handles mouse button interactions.
 
void CursorPositionCallback (GLFWwindow *window, double xPos, double yPos)
 Handles mouse movement interactions.
 
void ScrollCallback (GLFWwindow *window, double xOffset, double yOffset)
 Handles mouse scroll interactions.
 
 Input (ImGuiIO *io, State *state, Config *config)
 Initializes the input module with the current hotkeys.
 

Static Public Member Functions

static bool IsModKey (int key)
 Returns whether the key is a modifier key.
 
static std::string GetModCode (int mod)
 Returns the mod code as a string.
 
static std::string GetKeyCode (int key)
 Returns the key code as a string.
 
static std::string GetMouseCode (int button)
 Returns the mouse button code as a string.
 
static std::string GetActionCode (int action)
 Returns the action code as a string.
 
static bool AltPress (int mod)
 Returns whether alt is being pressed.
 
static bool ShiftPress (int mod)
 Returns whether shift is being pressed.
 
static bool CtrlPress (int mod)
 Returns whether ctrl is being pressed.
 
static void FramebufferSizeCallback (GLFWwindow *window, int width, int height)
 Handles changing the viewport size to match the window size.
 
static void DisableMouseCursor (GLFWwindow *window)
 Disables the mouse cursor, making it not move even if the user moves their mouse.
 
static void HideMouseCursor (GLFWwindow *window)
 Hides the mouse cursor, allowing the user to continue moving it in the background.
 
static void ShowMouseCursor (GLFWwindow *window)
 Shows the mouse cursor, resetting it to the default mode.
 

Constructor & Destructor Documentation

◆ Input()

Input::Input ( ImGuiIO *  io,
State state,
Config config 
)
explicit

Initializes the input module with the current hotkeys.

Parameters
ioImGui Input/Output module
stateGlobal state
configTop level config

Member Function Documentation

◆ AddCommand()

void Input::AddCommand ( const std::string &  name,
ICommand command 
)
inline

Adds the given command to the command list.

Parameters
nameName of the command
commandThe command

◆ AltPress()

static bool Input::AltPress ( int  mod)
inlinestatic

Returns whether alt is being pressed.

Parameters
modAlt/Ctrl/Shift modifiers
Returns
Whether the modifier is pressing alt

◆ CtrlPress()

static bool Input::CtrlPress ( int  mod)
inlinestatic

Returns whether ctrl is being pressed.

Parameters
modAlt/Ctrl/Shift modifiers
Returns
Whether the modifier is pressing alt

◆ CursorPositionCallback()

void Input::CursorPositionCallback ( GLFWwindow *  window,
double  xPos,
double  yPos 
)

Handles mouse movement interactions.

Parameters
windowCurrent window
xPosx position of cursor
yPosy position of cursor

◆ DisableMouseCursor()

static void Input::DisableMouseCursor ( GLFWwindow *  window)
inlinestatic

Disables the mouse cursor, making it not move even if the user moves their mouse.

Parameters
windowCurrent window

◆ FramebufferSizeCallback()

static void Input::FramebufferSizeCallback ( GLFWwindow *  window,
int  width,
int  height 
)
inlinestatic

Handles changing the viewport size to match the window size.

Parameters
windowCurrent window
widthWidth of new window
heightHeight of new window

◆ GetActionCode()

static std::string Input::GetActionCode ( int  action)
inlinestatic

Returns the action code as a string.

Parameters
actionAction
Returns
Name of action

◆ GetKeyCode()

static std::string Input::GetKeyCode ( int  key)
inlinestatic

Returns the key code as a string.

Parameters
keyKey code
Returns
Name of key

◆ GetModCode()

static std::string Input::GetModCode ( int  mod)
inlinestatic

Returns the mod code as a string.

Parameters
modAlt/Ctrl/Shift modifiers
Returns
Name of mod

◆ GetMouseCode()

static std::string Input::GetMouseCode ( int  button)
inlinestatic

Returns the mouse button code as a string.

Parameters
buttonMouse button
Returns
Name of mouse button

◆ GeyKeyMods()

int Input::GeyKeyMods ( const std::string &  keyCode) const
inline

Returns the modifier keys of the pressed key.

Parameters
keyCodeKey code of the key pressed
Returns
The modifier bits of the pressed key

◆ HideMouseCursor()

static void Input::HideMouseCursor ( GLFWwindow *  window)
inlinestatic

Hides the mouse cursor, allowing the user to continue moving it in the background.

Parameters
windowCurrent window

◆ IsKeyPressed()

bool Input::IsKeyPressed ( const std::string &  keyCode) const
inline

Returns whether the given key is pressed or not.

Parameters
keyCodeKey code to check
Returns
Whether the key is pressed

◆ IsModKey()

static bool Input::IsModKey ( int  key)
inlinestatic

Returns whether the key is a modifier key.

Parameters
keyKey code to check
Returns
Is the key a modifier key?

◆ KeyCallback()

void Input::KeyCallback ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)

Handles keyboard key interactions.

Parameters
windowCurrent window
keyThe key that was pressed or unpressed
scancodeScancode of key
actionWhether the key was pressed or unpressed
modsAlt/Ctrl/Shift modifiers

◆ MouseButtonCallback()

void Input::MouseButtonCallback ( GLFWwindow *  window,
int  button,
int  action,
int  mods 
)

Handles mouse button interactions.

Parameters
windowCurrent window
buttonThe mouse button that was pressed or unpressed
actionWhether the mouse button was pressed or unpressed
modsAlt/Ctrl/Shift modifiers

◆ PressKey()

bool Input::PressKey ( const std::string &  keyCode,
int  mods 
)
inline

Presses the given key with the given mod bits.

Parameters
keyCodeKey code to press
modsModifier bits
Returns
Whether the key was successfully pressed

◆ RunCommand()

void Input::RunCommand ( const std::string &  command)
inline

Runs the command with the given name if it exists.

Parameters
commandCommand to run

◆ ScrollCallback()

void Input::ScrollCallback ( GLFWwindow *  window,
double  xOffset,
double  yOffset 
)

Handles mouse scroll interactions.

Parameters
windowCurrent window
xOffsetChange in x
yOffsetChange in y

◆ SetMouseInputMode()

void Input::SetMouseInputMode ( GLFWwindow *  window,
MouseInputMode  newMode 
)
inline

Sets the mouse input mode to the given mode.

Parameters
window
newModeMode to set input to

◆ SetMouseMoveFunction()

void Input::SetMouseMoveFunction ( std::function< void(const glm::vec3 &delta)>  func)
inline

Sets the callback function that runs whenever the mouse moves in move mode.

Parameters
funcCallback function to run

◆ SetMouseRotFunction()

void Input::SetMouseRotFunction ( std::function< void(const glm::vec3 &delta)>  func)
inline

Sets the callback function that runs whenever the mouse moves in rotation mode.

Parameters
funcCallback function to run

◆ SetMouseZoomFunction()

void Input::SetMouseZoomFunction ( std::function< void(const glm::vec3 &delta)>  func)
inline

Sets the callback function that runs whenever the mouse moves in zoom mode.

Parameters
funcCallback function to run

◆ ShiftPress()

static bool Input::ShiftPress ( int  mod)
inlinestatic

Returns whether shift is being pressed.

Parameters
modAlt/Ctrl/Shift modifiers
Returns
Whether the modifier is pressing alt

◆ ShowMouseCursor()

static void Input::ShowMouseCursor ( GLFWwindow *  window)
inlinestatic

Shows the mouse cursor, resetting it to the default mode.

Parameters
windowCurrent window

◆ UnPressKey()

bool Input::UnPressKey ( const std::string &  keyCode)
inline

Unpresses the given key.

Parameters
keyCodeKey code to unpress
Returns
Whether the key was successfully unpressed