|
The Game Engine
1
|
Input handler to separate input from system. More...
#include <Input.h>
Collaboration diagram for Input:Classes | |
| struct | MouseState |
| Helper container to handle mouse clicks. More... | |
Public Member Functions | |
| Input (bool isJoy=false) | |
| Point2D | getJoyMovement (JoyStick s=JoyLeft) |
| Obtain the movement Value from this input. More... | |
| bool | pressed (SDLKey key, SDLMod modifier=KMOD_NONE) |
| Whether a key is pressed (ends up being the same as gathering entire current keyboard state and polling for specific key. More... | |
| bool | triggered (SDLKey key, int ms=-1) |
| Whether a key is triggered. More... | |
| bool | doubleTapped (SDLKey key, int ms=-1) |
| Whether a key is double tapped. More... | |
| bool | pressed (JoyButton button) |
| Whether a button is pressed (ends up being the same as gathering entire current buttonboard state and polling for specific button. More... | |
| bool | triggered (JoyButton button, int ms=-1) |
| Whether a button is triggered. More... | |
| bool | doubleTapped (JoyButton button, int ms=-1) |
| Whether a button is double tapped. More... | |
Static Public Member Functions | |
| static int | getNumInputs () |
| Returns number of inputs. More... | |
| static int | updateJoysticks () |
| Initializes the Joystick subsystem to update connected joysticks. More... | |
| static Input * | getInput (unsigned int index=0) |
| Provides access to the specified Input at given index (0 is always the keyboard, 1-n are joysticks) More... | |
| static void | updateInputs (SDL_Event event) |
| Store input from SDL. More... | |
| static pair< int, int > | getDeviceCounts () |
| gets the counts of keyboards and joysticks More... | |
| static int | getNumJoysticks () |
| gets the number of joysticks on the system More... | |
| static void | addInput (Input *i) |
| Adds an input device. More... | |
| static void | removeInput (Input *i) |
| Removes an input device. More... | |
| static void | addKeyDownCallback (void(*fn)(SDLKey, SDLMod)) |
| Add a keyboard button down callback. More... | |
| static void | removeKeyDownCallback (void(*fn)(SDLKey, SDLMod)) |
| remove a keyboard button down callback More... | |
| static void | addKeyUpCallback (void(*fn)(SDLKey, SDLMod)) |
| Add a keyboard button down callback. More... | |
| static void | removeKeyUpCallback (void(*fn)(SDLKey, SDLMod)) |
| remove a keyboard button down callback More... | |
| static void | addMouseDownCallback (void(*fn)(Uint8, MouseState)) |
| Add a keyboard button down callback. More... | |
| static void | removeMouseDownCallback (void(*fn)(Uint8, MouseState)) |
| remove a keyboard button down callback More... | |
| static void | addMouseUpCallback (void(*fn)(Uint8, MouseState)) |
| Add a keyboard button down callback. More... | |
| static void | removeMouseUpCallback (void(*fn)(Uint8, MouseState)) |
| remove a keyboard button down callback More... | |
| static void | addMouseMoveCallback (void(*fn)(MouseState)) |
| Add a keyboard button down callback. More... | |
| static void | removeMouseMoveCallback (void(*fn)(MouseState)) |
| remove a keyboard button down callback More... | |
| static void | addJoyButtonDownCallback (void(*fn)(Uint8, JoyButton)) |
| Add a keyboard button down callback. More... | |
| static void | removeJoyButtonDownCallback (void(*fn)(Uint8, JoyButton)) |
| remove a keyboard button down callback More... | |
| static void | addJoyButtonUpCallback (void(*fn)(Uint8, JoyButton)) |
| Add a keyboard button down callback. More... | |
| static void | removeJoyButtonUpCallback (void(*fn)(Uint8, JoyButton)) |
| remove a keyboard button down callback More... | |
| static void | addJoyMoveCallback (void(*fn)(Uint8, JoyStick, Point2D)) |
| Add a keyboard button down callback. More... | |
| static void | removeJoyMoveCallback (void(*fn)(Uint8, JoyStick, Point2D)) |
| remove a keyboard button down callback More... | |
| static bool | getAllPressed (JoyButton b) |
| Check all joypads for values of act being down. More... | |
| static bool | getAllTriggered (JoyButton b) |
| Check all joypads for values for act being triggered (down then up) More... | |
| static Point2D | getAllJoyMovement (JoyStick s=JoyLeft) |
| Check all joypads for values of movement. More... | |
| static Point2D | getMousePos () |
| Provides an interface to obtain Mouse Position. More... | |
| static Point2D | getMouseRelPos () |
| Provides an interface to obtain Mouse Relative movement. More... | |
| static bool | pressed (MouseButton b, int button=0) |
| Whether a mouse button is pressed (ends up being the same as gathering entire current Buttonboard state and polling for specific Button. More... | |
| static bool | triggered (MouseButton b, int button=0, int ms=-1) |
| Whether a mouse button is triggered. More... | |
| static bool | doubleTapped (MouseButton b, int button=0, int ms=-1) |
| Whether a mouse button is double tapped. More... | |
Protected Attributes | |
| int | mIndex |
| input index More... | |
| bool | isJoystick |
| Represents Keyboard or Joystick. If true Joystick. More... | |
| SDL_Joystick * | mJoystick |
| Pointer to the Joystick. More... | |
| Point2D | mJoyLeftPos |
| Represents the axis values of a joystick. More... | |
| Point2D | mJoyRightPos |
| Represents JoyRight Joy pos. More... | |
| Point2D | mJoyDPos |
| Represents Dpad Joy pos. More... | |
| map< SDLKey, pair< bool, SDLMod > > | mKeyStates |
| list of key's state (active if the input is a keyboard) More... | |
| map< SDLKey, Uint32 > | mLastKeyStates |
| list of key's state trigger times (active if the input is a keyboard) More... | |
| map< SDLKey, Uint32 > | mLastKeyDoubleStates |
| list of key's state trigger times (for double click) (active if the input is a keyboard) More... | |
| vector< bool > | mJoyStates |
| list of button's state (active if the input is a Joystick) Corresponds to joyButton More... | |
| vector< Uint32 > | mLastJoyStates |
| list of button's state trigger times (active if the input is a Joystick) Corresponds to joyButton More... | |
| vector< Uint32 > | mLastJoyDoubleStates |
| list of button's double clicked state (active if the input is a Joystick) Corresponds to joyButton More... | |
| vector< MouseState > | mMouseButtonStates |
| list of mouse's state More... | |
| vector< MouseState > | mLastMouseStates |
| list of mouse's state trigger times More... | |
| vector< MouseState > | mLastMouseDoubleStates |
| list of mouse's doube click state More... | |
Static Protected Attributes | |
| static vector< Input * > | inputs = vector<Input*>() |
| list of all inputdevices we have 0 is always the keyboard (not taking into acount multiples atm) joysticks are 1..JoyCount More... | |
| static set< void(*)(SDLKey, SDLMod)> | mKeyDownCallbacks = set<void (*)(SDLKey, SDLMod)>() |
| list of callback functions for Button press More... | |
| static set< void(*)(SDLKey, SDLMod)> | mKeyUpCallbacks = set<void (*)(SDLKey, SDLMod)>() |
| list of callback functions for Button release More... | |
| static set< void(*)(Uint8, MouseState)> | mMouseDownCallbacks = set<void (*)(Uint8, MouseState)>() |
| list of callback functions for Mouse press More... | |
| static set< void(*)(Uint8, MouseState)> | mMouseUpCallbacks = set<void (*)(Uint8, MouseState)>() |
| list of callback functions for Mouse release More... | |
| static set< void(*)(MouseState)> | mMouseMoveCallbacks = set<void (*)(MouseState)>() |
| list of callback functions for Mouse movement More... | |
| static set< void(*)(Uint8, JoyButton)> | mJoyButtonDownCallbacks = set<void (*)(Uint8, JoyButton)>() |
| list of callback functions for JoyButton press requiring which joystick passed the data More... | |
| static set< void(*)(Uint8, JoyButton)> | mJoyButtonUpCallbacks = set<void (*)(Uint8, JoyButton)>() |
| list of callback functions for JoyButton release requiring which joystick passed the data More... | |
| static set< void(*)(Uint8, JoyStick, Point2D)> | mJoyMoveCallbacks = set<void (*)(Uint8, JoyStick, Point2D)>() |
| list of callback functions for JoyStick movement requiring which joystick passed the data More... | |
| static MouseState | mMouseState = MouseState() |
| Mouse state. More... | |
Input handler to separate input from system.
This class is tasked with the following:
| Input::Input | ( | bool | isJoy = false | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| bool Input::doubleTapped | ( | SDLKey | key, |
| int | ms = -1 |
||
| ) |
Whether a key is double tapped.
| key | SDLKey to check for double tapped |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
<
Definition at line 692 of file Input.cpp.
Here is the caller graph for this function:| bool Input::doubleTapped | ( | JoyButton | button, |
| int | ms = -1 |
||
| ) |
Whether a button is double tapped.
| button | JoyButton to check for double tapped |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
|
static |
Whether a mouse button is double tapped.
| b | MouseButton to check for double tapped |
| button | MouseButton (i.e. not left, right, middle, or scroll) index to check for trigger |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
|
static |
|
static |
|
static |
|
static |
Obtain the movement Value from this input.
| s | The action/Joystick to obtain movement data for |
Definition at line 743 of file Input.cpp.
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
| bool Input::pressed | ( | SDLKey | key, |
| SDLMod | modifier = KMOD_NONE |
||
| ) |
Whether a key is pressed (ends up being the same as gathering entire current keyboard state and polling for specific key.
| key | SDLKey to check |
| modifier | the SDLMod representing modifier keys |
Definition at line 680 of file Input.cpp.
Here is the caller graph for this function:| bool Input::pressed | ( | JoyButton | button | ) |
|
static |
Whether a mouse button is pressed (ends up being the same as gathering entire current Buttonboard state and polling for specific Button.
| b | MouseButton to check |
| button | MouseButton (i.e. not left, right, middle, or scroll) index to check for trigger |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| bool Input::triggered | ( | SDLKey | key, |
| int | ms = -1 |
||
| ) |
Whether a key is triggered.
| key | SDLKey to check for trigger |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
<
Definition at line 686 of file Input.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| bool Input::triggered | ( | JoyButton | button, |
| int | ms = -1 |
||
| ) |
Whether a button is triggered.
| button | JoyButton to check for double tapped |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
Definition at line 703 of file Input.cpp.
Here is the call graph for this function:
|
static |
Whether a mouse button is triggered.
| b | MouseButton to check for trigger |
| button | MouseButton (i.e. not left, right, middle, or scroll) index to check for trigger |
| ms | This value is an optional value that checks against the given ms instead of TRIGGERTIME (this value cannot be larger than 2^31) |
Definition at line 725 of file Input.cpp.
Here is the call graph for this function:
|
static |
Store input from SDL.
Definition at line 51 of file Input.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |