DoopelPonger
Public Types | Public Member Functions | List of all members
InputActionMapper Class Reference

Class used to map actions that link to KeyCodes. More...

Inheritance diagram for InputActionMapper:
Inheritance graph
[legend]
Collaboration diagram for InputActionMapper:
Collaboration graph
[legend]

Public Types

enum  Action {
  Action.PLAYER_0_UP, Action.PLAYER_0_DOWN, Action.PLAYER_0_POWER, Action.PLAYER_0_SHIELD_PRIMARY,
  Action.PLAYER_0_SHIELD_SECONDARY, Action.PLAYER_1_UP, Action.PLAYER_1_DOWN, Action.PLAYER_1_POWER,
  Action.PLAYER_1_SHIELD_PRIMARY, Action.PLAYER_1_SHIELD_SECONDARY, Action.MENU_UP_PRIMARY, Action.MENU_UP_SECONDARY,
  Action.MENU_DOWN_PRIMARY, Action.MENU_DOWN_SECONDARY, Action.MENU_SELECT_PRIMARY, Action.MENU_SELECT_SECONDARY,
  Action.MENU_BACK_PRIMARY, Action.MENU_BACK_SECONDARY, Action.PAUSE_PRIMARY, Action.PAUSE_SECONDARY
}
 Any user input that should make the game perform some action should have a value in this enum. More...
 

Public Member Functions

void Awake ()
 Initialize the default KeyCodes by reading in the Controls.json file. More...
 
KeyCode GetKeyCode (Action action)
 
Action SetKeyCode (Action action, KeyCode keyCode)
 Set the Action to the new KeyCode. More...
 

Detailed Description

Class used to map actions that link to KeyCodes.

Class used to check if a KeyCode has been pressed for an associated Action. All types of input checking should implement this class.

Actions are user input that GameObjects need to react to. For example, moving the player, activating power up, navigating through menus, etc. Each of these actions can only be mapped to a single KeyCode but there can be multiple similar actions, for example activate shield primary and activate shield secondary where each individual action can have different KetCodes but link to the same InputManagerListener.

The way input is handled by the InputManager is that the KeyCode state is checked during the Update method, and any callbacks should be triggered in the FixedUpdate method.

Member Enumeration Documentation

◆ Action

Any user input that should make the game perform some action should have a value in this enum.

Enumerator
PLAYER_0_UP 
PLAYER_0_DOWN 
PLAYER_0_POWER 
PLAYER_0_SHIELD_PRIMARY 
PLAYER_0_SHIELD_SECONDARY 
PLAYER_1_UP 
PLAYER_1_DOWN 
PLAYER_1_POWER 
PLAYER_1_SHIELD_PRIMARY 
PLAYER_1_SHIELD_SECONDARY 
MENU_UP_PRIMARY 
MENU_UP_SECONDARY 
MENU_DOWN_PRIMARY 
MENU_DOWN_SECONDARY 
MENU_SELECT_PRIMARY 
MENU_SELECT_SECONDARY 
MENU_BACK_PRIMARY 
MENU_BACK_SECONDARY 
PAUSE_PRIMARY 
PAUSE_SECONDARY 

Member Function Documentation

◆ Awake()

void InputActionMapper.Awake ( )

Initialize the default KeyCodes by reading in the Controls.json file.

◆ GetKeyCode()

KeyCode InputActionMapper.GetKeyCode ( Action  action)
Parameters
actionThe Action to find the KeyCode for.
Returns
The KeyCode that belongs to the action.

◆ SetKeyCode()

Action InputActionMapper.SetKeyCode ( Action  action,
KeyCode  keyCode 
)

Set the Action to the new KeyCode.

Parameters
actionAction that should have the corresponding keycode overwritten.
keyCodeKeyCode to pair with the action.
Returns
If the keyCode was already mapped to an action then the action will be returned.

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