Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
KatanaEngine::InputState Class Reference

Handles the state of multiple player input devices. More...

#include <InputState.h>

Public Member Functions

 InputState ()
 
virtual ~InputState ()
 
bool IsKeyDown (Key key) const
 Determines if a keyboard key is currently being pressed down.
 
bool IsKeyUp (Key key) const
 Determines if a keyboard key is currently not being pressed down.
 
bool IsNewKeyPress (Key key) const
 Determines if a keyboard key was just pressed this frame.
 
bool IsNewKeyRelease (Key key) const
 Determines if a keyboard key was just released this frame.
 
Point GetMousePosition () const
 Gets the current screen position of the mouse cursor.
 
bool IsMouseButtonDown (MouseButton button) const
 Determines if a mouse button is currently being pressed down.
 
bool IsMouseButtonUp (MouseButton button) const
 Determines if a mouse button is currently not being pressed down.
 
bool WasMouseButtonDown (MouseButton button) const
 Determines if a mouse button was being pressed down during the previous frame.
 
bool WasMouseButtonUp (MouseButton button) const
 Determines if a mouse button was not being pressed down during the previous frame.
 
bool IsNewMouseButtonPress (MouseButton button) const
 Determines if a mouse button was just pressed this frame.
 
bool IsNewMouseButtonRelease (MouseButton button) const
 Determines if a mouse button was just released this frame.
 
bool IsButtonUp (Button button, int8_t &indexOut, int8_t controllingIndex=-1) const
 Determines if a the button on an Xbox controller is up.
 
bool IsButtonDown (Button button, int8_t &indexOut, int8_t controllingIndex=-1) const
 Determines if a the button on an Xbox controller is down.
 
bool IsNewButtonPress (Button button, int8_t &indexOut, int8_t controllingIndex=-1) const
 Determines if a the button on an Xbox controller was just pressed this frame.
 
bool IsNewButtonRelease (Button button, int8_t &indexOut, int8_t controllingIndex=-1) const
 Determines if a the button on an Xbox controller just released this frame.
 
GamePadState GetGamePadState (const int8_t gamePadIndex) const
 Get the current state of an Xbox controller.
 

Static Public Attributes

static const uint8_t MAX_NUM_GAMEPADSTATES = 4
 The maximum number of Xbox controllers that the system can manage.
 

Friends

class Game
 

Detailed Description

Handles the state of multiple player input devices.

Definition at line 21 of file InputState.h.

Constructor & Destructor Documentation

◆ InputState()

KatanaEngine::InputState::InputState ( )

Definition at line 19 of file InputState.cpp.

◆ ~InputState()

virtual KatanaEngine::InputState::~InputState ( )
inlinevirtual

Definition at line 31 of file InputState.h.

Member Function Documentation

◆ GetGamePadState()

GamePadState KatanaEngine::InputState::GetGamePadState ( const int8_t gamePadIndex) const

Get the current state of an Xbox controller.

Parameters
gamePadIndexThe index of the desired game pad state.
Returns
The game pad's current state.

Definition at line 274 of file InputState.cpp.

◆ GetMousePosition()

Point KatanaEngine::InputState::GetMousePosition ( ) const
inline

Gets the current screen position of the mouse cursor.

Returns
Returns the mouse position coordinates.

Definition at line 56 of file InputState.h.

◆ IsButtonDown()

bool KatanaEngine::InputState::IsButtonDown ( Button button,
int8_t & indexOut,
int8_t controllingIndex = -1 ) const

Determines if a the button on an Xbox controller is down.

Parameters
buttonThe button to test.
indexOutThe index of the controller with the pressed button.
controllingIndexThe index of the controller to test. If the controllingIndex is not valid, all controllers will be tested indexOut will be set to the first detected index matching the condition.
Returns
Returns true if the button is down, false otherwise.

Definition at line 215 of file InputState.cpp.

◆ IsButtonUp()

bool KatanaEngine::InputState::IsButtonUp ( Button button,
int8_t & indexOut,
int8_t controllingIndex = -1 ) const

Determines if a the button on an Xbox controller is up.

Parameters
buttonThe button to test.
indexOutThe index of the controller with the released button.
controllingIndexThe index of the controller to test. If the controllingIndex is not valid, all controllers will be tested indexOut will be set to the first detected index matching the condition.
Returns
Returns true if the button is up, false otherwise.

Definition at line 196 of file InputState.cpp.

◆ IsKeyDown()

bool KatanaEngine::InputState::IsKeyDown ( Key key) const

Determines if a keyboard key is currently being pressed down.

Parameters
keyThe key to test.
Returns
Returns true if the key is down, false otherwise.

Definition at line 176 of file InputState.cpp.

◆ IsKeyUp()

bool KatanaEngine::InputState::IsKeyUp ( Key key) const

Determines if a keyboard key is currently not being pressed down.

Parameters
keyThe key to test.
Returns
Returns true if the key is up, false otherwise.

Definition at line 181 of file InputState.cpp.

◆ IsMouseButtonDown()

bool KatanaEngine::InputState::IsMouseButtonDown ( MouseButton button) const
inline

Determines if a mouse button is currently being pressed down.

Parameters
buttonThe button to test.
Returns
Returns true if the button is down, false otherwise.

Definition at line 61 of file InputState.h.

◆ IsMouseButtonUp()

bool KatanaEngine::InputState::IsMouseButtonUp ( MouseButton button) const
inline

Determines if a mouse button is currently not being pressed down.

Parameters
buttonThe button to test.
Returns
Returns true if the button is up, false otherwise.

Definition at line 66 of file InputState.h.

◆ IsNewButtonPress()

bool KatanaEngine::InputState::IsNewButtonPress ( Button button,
int8_t & indexOut,
int8_t controllingIndex = -1 ) const

Determines if a the button on an Xbox controller was just pressed this frame.

Parameters
buttonThe button to test.
indexOutThe index of the controller with the pressed button.
controllingIndexThe index of the controller to test. If the controllingIndex is not valid, all controllers will be tested indexOut will be set to the first detected index matching the condition.
Returns
Returns true if the button was just pressed, false otherwise.

Definition at line 234 of file InputState.cpp.

◆ IsNewButtonRelease()

bool KatanaEngine::InputState::IsNewButtonRelease ( Button button,
int8_t & indexOut,
int8_t controllingIndex = -1 ) const

Determines if a the button on an Xbox controller just released this frame.

Parameters
buttonThe button to test.
indexOutThe index of the controller with the released button.
controllingIndexThe index of the controller to test. If the controllingIndex is not valid, all controllers will be tested indexOut will be set to the first detected index matching the condition.
Returns
Returns true if the button was just released, false otherwise.

Definition at line 254 of file InputState.cpp.

◆ IsNewKeyPress()

bool KatanaEngine::InputState::IsNewKeyPress ( Key key) const

Determines if a keyboard key was just pressed this frame.

Parameters
keyThe key to test.
Returns
Returns true if the key was just pressed, false otherwise.

Definition at line 186 of file InputState.cpp.

◆ IsNewKeyRelease()

bool KatanaEngine::InputState::IsNewKeyRelease ( Key key) const

Determines if a keyboard key was just released this frame.

Parameters
keyThe key to test.
Returns
Returns true if the key was just released, false otherwise.

Definition at line 191 of file InputState.cpp.

◆ IsNewMouseButtonPress()

bool KatanaEngine::InputState::IsNewMouseButtonPress ( MouseButton button) const
inline

Determines if a mouse button was just pressed this frame.

Parameters
buttonThe button to test.
Returns
Returns true if the button was just pressed, false otherwise.

Definition at line 81 of file InputState.h.

◆ IsNewMouseButtonRelease()

bool KatanaEngine::InputState::IsNewMouseButtonRelease ( MouseButton button) const
inline

Determines if a mouse button was just released this frame.

Parameters
buttonThe button to test.
Returns
Returns true if the button was just released, false otherwise.

Definition at line 86 of file InputState.h.

◆ WasMouseButtonDown()

bool KatanaEngine::InputState::WasMouseButtonDown ( MouseButton button) const
inline

Determines if a mouse button was being pressed down during the previous frame.

Parameters
buttonThe button to test.
Returns
Returns true if the button was down during the last frame, false otherwise.

Definition at line 71 of file InputState.h.

◆ WasMouseButtonUp()

bool KatanaEngine::InputState::WasMouseButtonUp ( MouseButton button) const
inline

Determines if a mouse button was not being pressed down during the previous frame.

Parameters
buttonThe button to test.
Returns
Returns true if the button was up during the last frame, false otherwise.

Definition at line 76 of file InputState.h.

Friends And Related Symbol Documentation

◆ Game

friend class Game
friend

Definition at line 23 of file InputState.h.

Member Data Documentation

◆ MAX_NUM_GAMEPADSTATES

const uint8_t KatanaEngine::InputState::MAX_NUM_GAMEPADSTATES = 4
static

The maximum number of Xbox controllers that the system can manage.

Definition at line 28 of file InputState.h.


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