Processes inputs from keyboard, mouse and gamepad controllers.
More...
#include <VInputHandler.h>
|
| | VInputHandler (sf::Window *window) |
| |
| void | SetButtonInput (const sf::String &name, int key=-1, int gamepad=-1, int mouse=-1) |
| |
| void | SetAxisInput (const sf::String &name, int keyA=-1, int keyB=-1, int gamepad=-1) |
| |
| bool | GetButtonInput (const sf::String &name, ButtonInput &input) |
| |
| bool | GetAxisInput (const sf::String &name, AxisInput &input) |
| |
| bool | IsGamepadActive () |
| |
| bool | IsButtonPressed (const sf::String &name, int ControllerIndex=0) |
| |
| bool | IsButtonDown (const sf::String &name, int ControllerIndex=0) |
| |
| bool | IsButtonUp (const sf::String &name, int ControllerIndex=0) |
| |
| bool | IsButtonReleased (const sf::String &name, int ControllerIndex=0) |
| |
| float | CurrentAxisValue (const sf::String &name, int ControllerIndex=0) |
| |
| float | LastAxisValue (const sf::String &name, int ControllerIndex=0) |
| |
| float | ScrollWheelDelta () |
| |
|
void | ResetScrollWheel () |
| | Resets the scroll wheel delta to 0.
|
| |
| void | HandleEvents (const sf::Event &event) |
| |
| void | Update (float dt) |
| |
Processes inputs from keyboard, mouse and gamepad controllers.
◆ VInputHandler()
| VInputHandler::VInputHandler |
( |
sf::Window * |
window | ) |
|
- Parameters
-
| window | The Window object, used for testing if mouse input is out of bounds. |
◆ CurrentAxisValue()
| float VInputHandler::CurrentAxisValue |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Gets the Axis value of the current frame.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- Axis value with range [-100 - 100], 0 if controller is not index.
◆ GetAxisInput()
| bool VInputHandler::GetAxisInput |
( |
const sf::String & |
name, |
|
|
AxisInput & |
input |
|
) |
| |
Gets specific Axis input data.
- Parameters
-
| name | Name of input. |
| input | Reference to Axis Input. |
- Returns
- True if reference has been found and set to the input parameter.
◆ GetButtonInput()
| bool VInputHandler::GetButtonInput |
( |
const sf::String & |
name, |
|
|
ButtonInput & |
input |
|
) |
| |
Gets specific Button input data.
- Parameters
-
| name | Name of input. |
| input | Reference to Button Input. |
- Returns
- True if reference has been found and set to the input parameter.
◆ HandleEvents()
| void VInputHandler::HandleEvents |
( |
const sf::Event & |
event | ) |
|
- Parameters
-
| event | The current event that can be processed. |
◆ IsButtonDown()
| bool VInputHandler::IsButtonDown |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Checks if a button is pushed down.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- True if button is down.
◆ IsButtonPressed()
| bool VInputHandler::IsButtonPressed |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Checks if a button has applied a press for a single frame.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- True if button has been pressed.
◆ IsButtonReleased()
| bool VInputHandler::IsButtonReleased |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Checks if a button has applied a release for a single frame.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- True if button has been released.
◆ IsButtonUp()
| bool VInputHandler::IsButtonUp |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Checks if a button is not pushed down.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- True if button is up.
◆ IsGamepadActive()
| bool VInputHandler::IsGamepadActive |
( |
| ) |
|
- Returns
- True if any gamepad input is recieved, returns false if other input is recieved.
◆ LastAxisValue()
| float VInputHandler::LastAxisValue |
( |
const sf::String & |
name, |
|
|
int |
ControllerIndex = 0 |
|
) |
| |
Gets the Axis value of the last frame.
- Parameters
-
| name | Name of Input. |
| ControllerIndex | Player Index for specific controller. (e.g. 0 = Player 1, 1 = Player 2 ect) |
- Returns
- Axis value with range [-100 - 100], 0 if controller is not index.
◆ ScrollWheelDelta()
| float VInputHandler::ScrollWheelDelta |
( |
| ) |
|
- Returns
- The scroll wheel delta from the mouse.
◆ SetAxisInput()
| void VInputHandler::SetAxisInput |
( |
const sf::String & |
name, |
|
|
int |
keyA = -1, |
|
|
int |
keyB = -1, |
|
|
int |
gamepad = -1 |
|
) |
| |
Sets the input values for a game axis. (i.e. analog sticks)
- Parameters
-
| name | Name of input type. |
| keyA | Key Code for the negative axis input. |
| keyB | Key Code for the positive axis input. |
| gamepad | Gamepad value for axis Input. |
◆ SetButtonInput()
| void VInputHandler::SetButtonInput |
( |
const sf::String & |
name, |
|
|
int |
key = -1, |
|
|
int |
gamepad = -1, |
|
|
int |
mouse = -1 |
|
) |
| |
Set the input values for a game button.
- Parameters
-
| name | Name of input type. |
| key | Key Code for Input. |
| gamepad | Gamepad value for Input. |
| mouse | Mouse value for Input. |
◆ Update()
| void VInputHandler::Update |
( |
float |
dt | ) |
|
Updates the inputs.
- Parameters
-
| dt | Delta Time between the current and previous frames of the game. |
The documentation for this class was generated from the following file: