JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Namespaces | Enumerations | Functions
input.hpp File Reference

Input related functions. More...

#include "Vec2.hpp"
#include <functional>
#include <memory>
#include <vector>
#include <experimental/optional>
Include dependency graph for input.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  jngl
 JNGL's main namespace.
 

Enumerations

enum  KeyType {
  Left , Up , Right , Down ,
  PageUp , PageDown , Home , End ,
  BackSpace , Tab , Clear , Return ,
  Pause , Escape , Delete , ControlL ,
  ControlR , CapsLock , AltL , AltR ,
  SuperL , SuperR , Space , ShiftL ,
  ShiftR , F1 , F2 , F3 ,
  F4 , F5 , F6 , F7 ,
  F8 , F9 , F10 , F11 ,
  F12 , Any
}
 Keyboard keys. More...
 
enum  KeyboardType { Default , Numpad }
 Whether a normal or a numbers-only keyboard should appear. More...
 
enum  Button { Left , Middle , Right }
 Mouse buttons. More...
 
enum  Button {
  LeftStickX , LeftStickXInverse , LeftStickY , LeftStickYInverse ,
  RightStickX , RightStickXInverse , RightStickY , RightStickYInverse ,
  A , B , X , Y ,
  LeftButton , RightButton , LeftTrigger , RightTrigger ,
  Start , Back , DpadUp , DpadDown ,
  DpadLeft , DpadRight , LeftStick , RightStick ,
  Last
}
 Gamepad buttons. More...
 

Functions

void setKeyboardVisible (bool)
 Display onscreen keyboard for touch devices.
 
void setKeyboardType (KeyboardType)
 Type of the onscreen keyboard.
 
KeyboardType getKeyboardType ()
 Currently active type of onscreen keyboard.
 
void setKeyPressed (const std::string &key, bool)
 Overwrite what keyPressed() should return.
 
void setKeyPressed (key::KeyType key, bool)
 Overwrite what keyPressed() should return.
 
bool keyDown (key::KeyType key)
 Whether key is down.
 
bool keyDown (char key)
 Whether key is down.
 
bool keyDown (const std::string &key)
 Whether key is down, where key should be exactly one UTF-8 character.
 
bool keyPressed (key::KeyType key)
 Whether key has been pressed since the next to last call to updateInput()
 
bool keyPressed (char key)
 Whether key has been pressed since the next to last call to updateInput()
 
bool keyPressed (const std::string &key)
 Whether key has been pressed since the next to last call to updateInput(), where key should be exactly one UTF-8 character.
 
void setRelativeMouseMode (bool relative)
 
bool getRelativeMouseMode ()
 
void setMouseVisible (bool visible)
 By default the mouse cursor of the OS is visible and can be hidden by passing false.
 
bool isMouseVisible ()
 Returns whether the mouse cursor of the OS is currently visible. More...
 
bool isMultitouch ()
 Returns true when there's more than one finger touching the screen.
 
std::vector< jngl::Vec2getTouchPositions ()
 Returns all positions where a finger touches the screen. More...
 
Vec2 getMousePos ()
 Mouse position in screen coordinates. More...
 
optional< Vec2 > getCursorPos ()
 Returns the position of the mouse pointer if a mouse is connected/available.
 
int getMouseX ()
 Retrieve mouse position in pixels. More...
 
int getMouseY ()
 Retrieve mouse position in pixels. More...
 
double getMouseWheel ()
 Returns mouse wheel movement between -100 and 100 (0 if the mousewheel doesn't move)
 
bool mouseDown (mouse::Button button=mouse::Left)
 Returns whether button is currently held down.
 
void setMouseDown (mouse::Button button, bool)
 Overwrite what mouseDown() should return.
 
bool mousePressed (mouse::Button button=mouse::Left)
 Whether button has been pressed since the next to last call to updateInput()
 
void setMousePressed (jngl::mouse::Button, bool)
 Overwrite what mouseDown() should return.
 
void setMouse (Vec2 position)
 Moves the mouse (does nothing on iOS and Android)
 
std::vector< std::shared_ptr< Controller > > getConnectedControllers ()
 Returns all controllers (gamepads) that are connected. More...
 
void onControllerChanged (std::function< void()> callback)
 Specify a function which gets called, whenever a controller gets added or removed. More...
 
std::string getTextInput ()
 Returns a string of characters that have been pressed since the last call to updateInput()
 

Detailed Description

Input related functions.

Definition in file input.hpp.

Enumeration Type Documentation

◆ KeyType

enum KeyType

Keyboard keys.

Enumerator
SuperL 

Left Windows key.

SuperR 

Right Windows key.

Definition at line 24 of file input.hpp.

◆ Button [1/2]

enum Button

Mouse buttons.

Definition at line 147 of file input.hpp.

◆ Button [2/2]

enum Button

Gamepad buttons.

Enumerator
LeftStickX 

x axis of left stick, -1 to 1

LeftStickXInverse 

-LeftStickX

LeftStickY 

y axis of left stick, -1 to 1

LeftStickYInverse 

-LeftStickY

RightStickX 

x axis of right stick, -1 to 1

RightStickXInverse 

-RightStickX

RightStickY 

y axis of right stick, -1 to 1

RightStickYInverse 

-RightStickY

LeftButton 

Left shoulder button.

RightButton 

Right shoulder button.

Start 

Start, or Options button.

Back 

Back, Menu, or Share button.

Definition at line 170 of file input.hpp.