Arctic Engine
Designed to give you control and not take anything away.

Functions for handling keyboard, mouse, and controller input. More...

Collaboration diagram for Input:

Classes

struct  arctic::InputMessage
 Structure representing an input message. More...
 

Enumerations

enum  arctic::ControllerAxis {
  kAxis0 = 0 , kAxis1 , kAxis2 , kAxis3 ,
  kAxis4 , kAxis5 , kAxisCount
}
 Enumeration of controller axis identifiers.
 
enum  arctic::KeyCode {
  arctic::kKeyNone = 0 , arctic::kKeyUnknown = 1 , kKeyLeft = 4 , kKeyRight = 5 ,
  kKeyUp = 6 , kKeyDown = 7 , arctic::kKeyBackspace = 8 , arctic::kKeyTab = 9 ,
  kKeyEnter = 13 , kKeyHome = 14 , kKeyEnd = 15 , kKeyPageUp = 16 ,
  kKeyPageDown = 17 , kKeyShift = 18 , kKeyLeftShift = 19 , kKeyRightShift = 20 ,
  kKeyControl = 21 , kKeyLeftControl = 22 , kKeyRightControl = 23 , kKeyAlt = 24 ,
  kKeyLeftAlt = 25 , kKeyRightAlt = 26 , kKeyEscape = 27 , kKeySpace = 32 ,
  kKeyApostrophe = 39 , kKeyComma = 44 , kKeyMinus = 45 , kKeyPeriod = 46 ,
  kKeySlash = 47 , kKey0 = 48 , kKey1 = 49 , kKey2 = 50 ,
  kKey3 = 51 , kKey4 = 52 , kKey5 = 53 , kKey6 = 54 ,
  kKey7 = 55 , kKey8 = 56 , kKey9 = 57 , kKeySemicolon = 59 ,
  kKeyPause = 60 , kKeyEquals = 61 , kKeyNumLock = 62 , kKeyScrollLock = 63 ,
  kKeyCapsLock = 64 , kKeyA = 65 , kKeyB = 66 , kKeyC = 67 ,
  kKeyD = 68 , kKeyE = 69 , kKeyF = 70 , kKeyG = 71 ,
  kKeyH = 72 , kKeyI = 73 , kKeyJ = 74 , kKeyK = 75 ,
  kKeyL = 76 , kKeyM = 77 , kKeyN = 78 , kKeyO = 79 ,
  kKeyP = 80 , kKeyQ = 81 , kKeyR = 82 , kKeyS = 83 ,
  kKeyT = 84 , kKeyU = 85 , kKeyV = 86 , kKeyW = 87 ,
  kKeyX = 88 , kKeyY = 89 , kKeyZ = 90 , kKeyLeftSquareBracket = 91 ,
  kKeyBackslash = 92 , kKeyRightSquareBracket = 93 , kKeyGraveAccent = 96 , kKeyF1 = 97 ,
  kKeyF2 = 98 , kKeyF3 = 99 , kKeyF4 = 100 , kKeyF5 = 101 ,
  kKeyF6 = 102 , kKeyF7 = 103 , kKeyF8 = 104 , kKeyF9 = 105 ,
  kKeyF10 = 106 , kKeyF11 = 107 , kKeyF12 = 108 , kKeyNumpad0 = 109 ,
  kKeyNumpad1 = 110 , kKeyNumpad2 = 111 , kKeyNumpad3 = 112 , kKeyNumpad4 = 113 ,
  kKeyNumpad5 = 114 , kKeyNumpad6 = 115 , kKeyNumpad7 = 116 , kKeyNumpad8 = 117 ,
  kKeyNumpad9 = 118 , kKeyNumpadSlash = 119 , kKeyNumpadAsterisk = 120 , kKeyNumpadMinus = 121 ,
  kKeyNumpadPlus = 122 , kKeyNumpadPeriod = 123 , kKeyPrintScreen = 125 , kKeyInsert = 126 ,
  kKeyDelete = 127 , kKeySectionSign = 245 , kKeyMouseUnknown = 256 , kKeyMouseLeft = 257 ,
  kKeyMouseRight = 258 , kKeyMouseWheel = 259 , kKeyController0Button0 = 260 , kKeyController0Button1 = 261 ,
  kKeyController0Button2 = 262 , kKeyController0Button3 = 263 , kKeyController0Button4 = 264 , kKeyController0Button5 = 265 ,
  kKeyController0Button6 = 266 , kKeyController0Button7 = 267 , kKeyController0Button8 = 268 , kKeyController0Button9 = 269 ,
  kKeyController0Button10 = 270 , kKeyController0Button11 = 271 , kKeyController0Button12 = 272 , kKeyController0Button13 = 273 ,
  kKeyController0Button14 = 274 , kKeyController0Button15 = 275 , kKeyController0Button16 = 276 , kKeyController0Button17 = 277 ,
  kKeyController0Button18 = 278 , kKeyController0Button19 = 279 , kKeyController0Button20 = 280 , kKeyController0Button21 = 281 ,
  kKeyController0Button22 = 282 , kKeyController0Button23 = 283 , kKeyController0Button24 = 284 , kKeyController0Button25 = 285 ,
  kKeyController0Button26 = 286 , kKeyController0Button27 = 287 , kKeyController0Button28 = 288 , kKeyController0Button29 = 289 ,
  kKeyController0Button30 = 290 , kKeyController0Button31 = 291 , kKeyController1Button0 = 292 , kKeyController1Button1 = 293 ,
  kKeyController1Button2 = 294 , kKeyController1Button3 = 295 , kKeyController1Button4 = 296 , kKeyController1Button5 = 297 ,
  kKeyController1Button6 = 298 , kKeyController1Button7 = 299 , kKeyController1Button8 = 300 , kKeyController1Button9 = 301 ,
  kKeyController1Button10 = 302 , kKeyController1Button11 = 303 , kKeyController1Button12 = 304 , kKeyController1Button13 = 305 ,
  kKeyController1Button14 = 306 , kKeyController1Button15 = 307 , kKeyController1Button16 = 308 , kKeyController1Button17 = 309 ,
  kKeyController1Button18 = 310 , kKeyController1Button19 = 311 , kKeyController1Button20 = 312 , kKeyController1Button21 = 313 ,
  kKeyController1Button22 = 314 , kKeyController1Button23 = 315 , kKeyController1Button24 = 316 , kKeyController1Button25 = 317 ,
  kKeyController1Button26 = 318 , kKeyController1Button27 = 319 , kKeyController1Button28 = 320 , kKeyController1Button29 = 321 ,
  kKeyController1Button30 = 322 , kKeyController1Button31 = 323 , kKeyController2Button0 = 324 , kKeyController2Button31 = 355 ,
  kKeyController3Button0 = 356 , kKeyController3Button31 = 387 , kKeyCount = 388
}
 Enumeration of key codes for various input devices. More...
 

Key State Transition Functions

bool arctic::IsKeyDownward (const KeyCode key_code)
 
bool arctic::IsKeyDownward (const char *keys)
 
bool arctic::IsKeyDownward (const char key)
 
bool arctic::IsKeyDownward (const Si32 key_code)
 
bool arctic::IsKeyDownward (const std::string &keys)
 
bool arctic::IsKeyDown (const KeyCode key_code)
 
bool arctic::IsKeyDown (const char *keys)
 
bool arctic::IsKeyDown (const char key)
 
bool arctic::IsKeyDown (const Si32 key_code)
 
bool arctic::IsKeyDown (const std::string &keys)
 
bool arctic::IsKeyUpward (const KeyCode key_code)
 
bool arctic::IsKeyUpward (const char *keys)
 
bool arctic::IsKeyUpward (const char key)
 
bool arctic::IsKeyUpward (const Si32 key_code)
 
bool arctic::IsKeyUpward (const std::string &keys)
 

Global Key State Functions

bool arctic::IsAnyKeyDownward ()
 
bool arctic::IsAnyKeyDown ()
 
bool arctic::IsAnyKeyUpward ()
 

Key State Manipulation Functions

void arctic::SetKey (const KeyCode key_code, bool is_pressed)
 
void arctic::SetKey (const char key, bool is_pressed)
 
void arctic::ClearKeyStateTransitions ()
 

Controller and Mouse Input Functions

float arctic::ControllerAxis (Si32 controller_idx, Si32 axis_idx)
 
Vec2Si32 arctic::MousePos ()
 
Si32 arctic::MouseX ()
 
Si32 arctic::MouseY ()
 
Vec2Si32 arctic::MouseMove ()
 
Si32 arctic::MouseWheelDelta ()
 

Input Message Functions

Si32 arctic::InputMessageCount ()
 
const InputMessagearctic::GetInputMessage (Si32 idx)
 

Detailed Description

Functions for handling keyboard, mouse, and controller input.

This module provides functions for detecting key presses, mouse movements, and controller inputs. It supports various input detection methods including:

Key functions include IsKeyDown(), IsKeyDownward(), MousePos(), and ControllerAxis().

Enumeration Type Documentation

◆ KeyCode

Enumeration of key codes for various input devices.

Enumerator
kKeyNone 

Indicates absence of any key, like SQL null.

kKeyUnknown 

Indicates an unidentified key.

kKeyBackspace 

ASCII Backspace.

kKeyTab 

ASCII Horizontal Tab.

Function Documentation

◆ ClearKeyStateTransitions()

void arctic::ClearKeyStateTransitions ( )

Clears all key state transition information

Note
After calling this function, IsKeyDownward(), IsKeyUpward(), IsAnyKeyDownward(), and IsAnyKeyUpward() will return false until the next ShowFrame() call updates the transition information. IsKeyDown() and IsAnyKeyDown() are not affected.

◆ ControllerAxis()

float arctic::ControllerAxis ( Si32  controller_idx,
Si32  axis_idx 
)

Gets the position of a controller axis

Parameters
controller_idxIndex of the controller (0 for the first controller)
axis_idxIndex of the axis on the controller
Returns
The position of the axis as a float value between -1.0 and 1.0

◆ GetInputMessage()

const InputMessage & arctic::GetInputMessage ( Si32  idx)

Gets a specific input message from the last frame

Parameters
idxIndex of the message to retrieve (0 to InputMessageCount()-1)
Returns
The input message at the specified index
Here is the call graph for this function:

◆ InputMessageCount()

Si32 arctic::InputMessageCount ( )

Gets the number of input messages received during the last frame

Returns
The number of input messages

◆ IsAnyKeyDown()

bool arctic::IsAnyKeyDown ( )

Checks if any key is currently being held down

Returns
True if any key is currently in the down state

◆ IsAnyKeyDownward()

bool arctic::IsAnyKeyDownward ( )

Checks if any key was pressed down during the last frame

Returns
True if any key transitioned from up to down state during the last frame

◆ IsAnyKeyUpward()

bool arctic::IsAnyKeyUpward ( )

Checks if any key was released during the last frame

Returns
True if any key transitioned from down to up state during the last frame

◆ IsKeyDown() [1/5]

bool arctic::IsKeyDown ( const char *  keys)

Checks if any of the specified keys is currently being held down

Parameters
keysA C-string containing one or more key character codes to check
Returns
True if any of the specified keys is currently in the down state
Note
This function returns true as long as any of the keys are being held down. Use this for continuous actions like character movement or camera control. For one-time actions (e.g., menu selection, jumping), use IsKeyDownward() instead.
Here is the call graph for this function:

◆ IsKeyDown() [2/5]

bool arctic::IsKeyDown ( const char  key)

Checks if a specific key is currently being held down

Parameters
keyThe key character code to check
Returns
True if the key is currently in the down state
Note
This function returns true as long as the key is being held down. Use this for continuous actions like character movement or camera control. For one-time actions (e.g., menu selection, jumping), use IsKeyDownward() instead.

◆ IsKeyDown() [3/5]

bool arctic::IsKeyDown ( const KeyCode  key_code)

Checks if a key is currently being held down

Parameters
key_codeThe key code to check
Returns
True if the key is currently in the down state
Note
This function returns true as long as the key is being held down. Use this for continuous actions like character movement or camera control. For one-time actions (e.g., menu selection, jumping), use IsKeyDownward() instead.

◆ IsKeyDown() [4/5]

bool arctic::IsKeyDown ( const Si32  key_code)

Checks if a key is currently being held down

Parameters
key_codeThe integer key code to check
Returns
True if the key is currently in the down state
Note
This function returns true as long as the key is being held down. Use this for continuous actions like character movement or camera control. For one-time actions (e.g., menu selection, jumping), use IsKeyDownward() instead.

◆ IsKeyDown() [5/5]

bool arctic::IsKeyDown ( const std::string &  keys)

Checks if any of the specified keys is currently being held down

Parameters
keysA string containing one or more key character codes to check
Returns
True if any of the specified keys is currently in the down state
Note
This function returns true as long as any of the keys are being held down. Use this for continuous actions like character movement or camera control. For one-time actions (e.g., menu selection, jumping), use IsKeyDownward() instead.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsKeyDownward() [1/5]

bool arctic::IsKeyDownward ( const char *  keys)

Checks if any of the specified keys was pressed down during the last frame

Parameters
keysA C-string containing one or more key character codes to check
Returns
True if any of the specified keys transitioned from up to down state during the last frame
Note
This function returns true ONLY on the first frame when any of the keys are pressed. It does NOT return true while the keys are being held down. Use IsKeyDown() for continuous key press detection (e.g., character movement). Use IsKeyDownward() for one-time actions (e.g., menu selection, jumping).
Here is the call graph for this function:

◆ IsKeyDownward() [2/5]

bool arctic::IsKeyDownward ( const char  key)

Checks if a specific key was pressed down during the last frame

Parameters
keyThe key character code to check
Returns
True if the key transitioned from up to down state during the last frame
Note
This function returns true ONLY on the first frame when the key is pressed. It does NOT return true while the key is being held down. Use IsKeyDown() for continuous key press detection (e.g., character movement). Use IsKeyDownward() for one-time actions (e.g., menu selection, jumping).

◆ IsKeyDownward() [3/5]

bool arctic::IsKeyDownward ( const KeyCode  key_code)

Checks if a key was pressed down during the last frame

Parameters
key_codeThe key code to check
Returns
True if the key transitioned from up to down state during the last frame
Note
This function returns true ONLY on the first frame when a key is pressed. It does NOT return true while the key is being held down. Use IsKeyDown() for continuous key press detection (e.g., character movement). Use IsKeyDownward() for one-time actions (e.g., menu selection, jumping).

◆ IsKeyDownward() [4/5]

bool arctic::IsKeyDownward ( const Si32  key_code)

Checks if a key was pressed down during the last frame

Parameters
key_codeThe integer key code to check
Returns
True if the key transitioned from up to down state during the last frame
Note
This function returns true ONLY on the first frame when the key is pressed. It does NOT return true while the key is being held down. Use IsKeyDown() for continuous key press detection (e.g., character movement). Use IsKeyDownward() for one-time actions (e.g., menu selection, jumping).

◆ IsKeyDownward() [5/5]

bool arctic::IsKeyDownward ( const std::string &  keys)

Checks if any of the specified keys was pressed down during the last frame

Parameters
keysA string containing one or more key character codes to check
Returns
True if any of the specified keys transitioned from up to down state during the last frame
Note
This function returns true ONLY on the first frame when any of the keys are pressed. It does NOT return true while the keys are being held down. Use IsKeyDown() for continuous key press detection (e.g., character movement). Use IsKeyDownward() for one-time actions (e.g., menu selection, jumping).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsKeyUpward() [1/5]

bool arctic::IsKeyUpward ( const char *  keys)

Checks if any of the specified keys was released during the last frame

Parameters
keysA C-string containing one or more key character codes to check
Returns
True if any of the specified keys transitioned from down to up state during the last frame
Here is the call graph for this function:

◆ IsKeyUpward() [2/5]

bool arctic::IsKeyUpward ( const char  key)

Checks if a specific key was released during the last frame

Parameters
keyThe key character code to check
Returns
True if the key transitioned from down to up state during the last frame

◆ IsKeyUpward() [3/5]

bool arctic::IsKeyUpward ( const KeyCode  key_code)

Checks if a key was released during the last frame

Parameters
key_codeThe key code to check
Returns
True if the key transitioned from down to up state during the last frame

◆ IsKeyUpward() [4/5]

bool arctic::IsKeyUpward ( const Si32  key_code)

Checks if a key was released during the last frame

Parameters
key_codeThe integer key code to check
Returns
True if the key transitioned from down to up state during the last frame

◆ IsKeyUpward() [5/5]

bool arctic::IsKeyUpward ( const std::string &  keys)

Checks if any of the specified keys was released during the last frame

Parameters
keysA string containing one or more key character codes to check
Returns
True if any of the specified keys transitioned from down to up state during the last frame
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MouseMove()

Vec2Si32 arctic::MouseMove ( )

Gets the mouse movement vector since the last frame

Returns
The mouse movement as a 2D vector (delta_x, delta_y)

◆ MousePos()

Vec2Si32 arctic::MousePos ( )

Gets the current mouse cursor position

Returns
The mouse cursor position as a 2D vector (x, y)

◆ MouseWheelDelta()

Si32 arctic::MouseWheelDelta ( )

Gets the mouse wheel rotation since the last frame

Returns
The mouse wheel delta (positive for scrolling up, negative for scrolling down)

◆ MouseX()

Si32 arctic::MouseX ( )

Gets the current mouse cursor X coordinate

Returns
The mouse cursor X coordinate

◆ MouseY()

Si32 arctic::MouseY ( )

Gets the current mouse cursor Y coordinate

Returns
The mouse cursor Y coordinate

◆ SetKey() [1/2]

void arctic::SetKey ( const char  key,
bool  is_set_down 
)

Sets the state of a key as if it was pressed or released at the end of the last frame

Parameters
keyThe key character code to modify
is_set_downTrue to set the key as pressed, false to set it as released
Note
The state is set just like it would be if the key actually transitioned up or down at the end of the last frame. This affects the results of IsKeyDownward(), IsKeyDown(), IsKeyUpward(), IsAnyKeyDownward(), IsAnyKeyDown(), and IsAnyKeyUpward() calls

◆ SetKey() [2/2]

void arctic::SetKey ( const KeyCode  key_code,
bool  is_set_down 
)

Sets the state of a key as if it was pressed or released at the end of the last frame

Parameters
key_codeThe key code to modify
is_set_downTrue to set the key as pressed, false to set it as released
Note
The state is set just like it would be if the key actually transitioned up or down at the end of the last frame. This affects the results of IsKeyDownward(), IsKeyDown(), IsKeyUpward(), IsAnyKeyDownward(), IsAnyKeyDown(), and IsAnyKeyUpward() calls